changeset 9880:83d9bc20973d jdk9-b12

Merge
author lana
date Thu, 01 May 2014 14:21:29 -0700
parents 9c7285a47776 (current diff) 9ea90ce2b8d9 (diff)
children ac1b3c46ed4d 32ef8cd730ec
files src/macosx/native/sun/awt/CClipboard.h src/share/classes/javax/swing/text/html/ResourceLoader.java src/share/classes/javax/swing/text/html/parser/ResourceLoader.java src/share/classes/sun/awt/EventListenerAggregate.java
diffstat 299 files changed, 18739 insertions(+), 2729 deletions(-) [+]
line wrap: on
line diff
--- a/make/data/jdwp/jdwp.spec	Thu May 01 12:51:13 2014 -0700
+++ b/make/data/jdwp/jdwp.spec	Thu May 01 14:21:29 2014 -0700
@@ -1147,7 +1147,8 @@
         (ErrorSet
             (Error INVALID_CLASS     "clazz is not the ID of a class.")
             (Error INVALID_OBJECT    "clazz is not a known ID.")
-            (Error INVALID_METHODID  "methodID is not the ID of a method.")
+            (Error INVALID_METHODID  "methodID is not the ID of a static method in "
+                                     "this class type or one of its superclasses.")
             (Error INVALID_THREAD)
             (Error THREAD_NOT_SUSPENDED)
             (Error VM_DEAD)
@@ -1250,6 +1251,83 @@
     )
 )
 (CommandSet InterfaceType=5
+    (Command InvokeMethod=1
+        "Invokes a static method. "
+        "The method must not be a static initializer. "
+        "The method must be a member of the interface type. "
+        "<p>Since JDWP version 1.8 "
+        "<p>"
+        "The method invocation will occur in the specified thread. "
+        "Method invocation can occur only if the specified thread "
+        "has been suspended by an event. "
+        "Method invocation is not supported "
+        "when the target VM has been suspended by the front-end. "
+        "<p>"
+        "The specified method is invoked with the arguments in the specified "
+        "argument list. "
+        "The method invocation is synchronous; the reply packet is not "
+        "sent until the invoked method returns in the target VM. "
+        "The return value (possibly the void value) is "
+        "included in the reply packet. "
+        "If the invoked method throws an exception, the "
+        "exception object ID is set in the reply packet; otherwise, the "
+        "exception object ID is null. "
+        "<p>"
+        "For primitive arguments, the argument value's type must match the "
+        "argument's type exactly. For object arguments, there must exist a "
+        "widening reference conversion from the argument value's type to the "
+        "argument's type and the argument's type must be loaded. "
+        "<p>"
+        "By default, all threads in the target VM are resumed while "
+        "the method is being invoked if they were previously "
+        "suspended by an event or by a command. "
+        "This is done to prevent the deadlocks "
+        "that will occur if any of the threads own monitors "
+        "that will be needed by the invoked method. It is possible that "
+        "breakpoints or other events might occur during the invocation. "
+        "Note, however, that this implicit resume acts exactly like "
+        "the ThreadReference resume command, so if the thread's suspend "
+        "count is greater than 1, it will remain in a suspended state "
+        "during the invocation. By default, when the invocation completes, "
+        "all threads in the target VM are suspended, regardless their state "
+        "before the invocation. "
+        "<p>"
+        "The resumption of other threads during the invoke can be prevented "
+        "by specifying the INVOKE_SINGLE_THREADED "
+        "bit flag in the <code>options</code> field; however, "
+        "there is no protection against or recovery from the deadlocks "
+        "described above, so this option should be used with great caution. "
+        "Only the specified thread will be resumed (as described for all "
+        "threads above). Upon completion of a single threaded invoke, the invoking thread "
+        "will be suspended once again. Note that any threads started during "
+        "the single threaded invocation will not be suspended when the "
+        "invocation completes. "
+        "<p>"
+        "If the target VM is disconnected during the invoke (for example, through "
+        "the VirtualMachine dispose command) the method invocation continues. "
+        (Out
+            (interfaceType clazz "The interface type ID.")
+            (threadObject thread "The thread in which to invoke.")
+            (method methodID "The method to invoke.")
+            (Repeat arguments
+                (value arg "The argument value.")
+            )
+            (int options "Invocation <a href=\"#JDWP_InvokeOptions\">options</a>")
+        )
+        (Reply
+            (value returnValue "The returned value.")
+            (tagged-object exception "The thrown exception.")
+        )
+        (ErrorSet
+            (Error INVALID_CLASS     "clazz is not the ID of an interface.")
+            (Error INVALID_OBJECT    "clazz is not a known ID.")
+            (Error INVALID_METHODID  "methodID is not the ID of a static method in this "
+                                     "interface type or is the ID of a static initializer.")
+            (Error INVALID_THREAD)
+            (Error THREAD_NOT_SUSPENDED)
+            (Error VM_DEAD)
+        )
+    )
 )
 (CommandSet Method=6
     (Command LineTable=1
@@ -1543,7 +1621,7 @@
         "<p>"
         "By default, all threads in the target VM are resumed while "
         "the method is being invoked if they were previously "
-        "suspended by an event or by command. "
+        "suspended by an event or by a command. "
         "This is done to prevent the deadlocks "
         "that will occur if any of the threads own monitors "
         "that will be needed by the invoked method. It is possible that "
@@ -1586,7 +1664,9 @@
             (Error INVALID_OBJECT)
             (Error INVALID_CLASS     "clazz is not the ID of a reference "
                                      "type.")
-            (Error INVALID_METHODID  "methodID is not the ID of a method.")
+            (Error INVALID_METHODID  "methodID is not the ID of an instance method "
+                                     "in this object's type or one of its superclasses, "
+                                     "superinterfaces, or implemented interfaces.")
             (Error INVALID_THREAD)
             (Error THREAD_NOT_SUSPENDED)
             (Error VM_DEAD)
--- a/make/lib/Awt2dLibraries.gmk	Thu May 01 12:51:13 2014 -0700
+++ b/make/lib/Awt2dLibraries.gmk	Thu May 01 14:21:29 2014 -0700
@@ -798,6 +798,10 @@
   BUILD_LIBFONTMANAGER_ExtensionSubtables.cpp_CXXFLAGS := -fno-strict-aliasing
 endif
 
+# Libfontmanager doesn't actually need X_LIBS to link, but if building
+# on a Solaris machine without X installed, using a devkit, linking
+# to libawt_xawt will fail without the -L parameters from X_LIBS. Filter
+# out the -R parameters since they aren't needed.
 $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
     LIBRARY := fontmanager, \
     OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
@@ -816,7 +820,8 @@
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LDFLAGS_SUFFIX := $(BUILD_LIBFONTMANAGER_FONTLIB), \
     LDFLAGS_SUFFIX_linux := -lawt $(LIBM) $(LIBCXX) -ljava -ljvm -lc, \
-    LDFLAGS_SUFFIX_solaris := -lawt -lawt_xawt -lc $(LIBM) $(LIBCXX) -ljava -ljvm, \
+    LDFLAGS_SUFFIX_solaris := $(filter-out -R%, $(X_LIBS)) \
+        -lawt -lawt_xawt -lc $(LIBM) $(LIBCXX) -ljava -ljvm, \
     LDFLAGS_SUFFIX_aix := -lawt -lawt_xawt $(LIBM) $(LIBCXX) -ljava -ljvm,\
     LDFLAGS_SUFFIX_macosx := -lawt $(LIBM) $(LIBCXX) -undefined dynamic_lookup \
         -ljava -ljvm, \
--- a/src/macosx/classes/apple/laf/JRSUIConstants.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/classes/apple/laf/JRSUIConstants.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,13 @@
 import java.lang.annotation.Native;
 
 public final class JRSUIConstants {
+
+    /**
+     * There is no way to get width of focus border, so it is hardcoded here.
+     * All components, which can be focused should take care about it.
+     */
+    public static final int FOCUS_SIZE = 4;
+
     private static native long getPtrForConstant(final int constant);
 
     static class Key {
--- a/src/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,8 @@
 import com.apple.laf.AquaUtilControlSize.*;
 import com.apple.laf.AquaUtils.RecyclableSingleton;
 
+import static apple.laf.JRSUIConstants.FOCUS_SIZE;
+
 /**
  * All the "magic numbers" in this class should go away once
  * <rdar://problem/4613866> "default font" and sizes for controls in Java Aqua Look and Feel
@@ -145,7 +147,8 @@
     protected static Map<String, TypeSpecifier> getAllTypes() {
         final Map<String, TypeSpecifier> specifiersByName = new HashMap<String, TypeSpecifier>();
 
-        final Insets focusInsets = new Insets(4, 4, 4, 4);
+        final Insets focusInsets = new Insets(FOCUS_SIZE, FOCUS_SIZE,
+                                              FOCUS_SIZE, FOCUS_SIZE);
 
         final TypeSpecifier[] specifiers = {
             new TypeSpecifier("toolbar", true) {
--- a/src/macosx/classes/com/apple/laf/AquaIcon.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/classes/com/apple/laf/AquaIcon.java	Thu May 01 14:21:29 2014 -0700
@@ -44,7 +44,8 @@
     }
 
     static UIResource getIconFor(final JRSUIControlSpec spec, final int width, final int height) {
-        return new CachableJRSUIIcon(width, height) {
+        return new ScalingJRSUIIcon(width, height) {
+            @Override
             public void initIconPainter(final AquaPainter<JRSUIState> painter) {
                 spec.initIconPainter(painter);
             }
@@ -128,35 +129,12 @@
             if (image != null) return image;
 
             if (!GraphicsEnvironment.isHeadless()) {
-                image = getOptimizedImage();
+                image = createImage();
             }
 
             return image;
         }
 
-        private Image getOptimizedImage() {
-            final Image img = createImage();
-            // TODO: no RuntimeOptions for now
-            //if (RuntimeOptions.getRenderer(null) != RuntimeOptions.Sun) return img;
-            return getProgressiveOptimizedImage(img, getIconWidth(), getIconHeight());
-        }
-
-        static Image getProgressiveOptimizedImage(final Image img, final int w, final int h) {
-            if (img == null) return null;
-
-            final int halfImgW = img.getWidth(null) / 2;
-            final int halfImgH = img.getHeight(null) / 2;
-            if (w * 2 > halfImgW && h * 2 > halfImgH) return img;
-
-            final BufferedImage halfImage = new BufferedImage(halfImgW, halfImgH, BufferedImage.TYPE_INT_ARGB);
-            final Graphics g = halfImage.getGraphics();
-            ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
-            g.drawImage(img, 0, 0, halfImgW, halfImgH, null);
-            g.dispose();
-
-            return getProgressiveOptimizedImage(halfImage, w, h);
-        }
-
         abstract Image createImage();
 
         public boolean hasIconRef() {
@@ -189,24 +167,50 @@
 
     }
 
-    static abstract class CachableJRSUIIcon extends CachingScalingIcon implements UIResource {
-        public CachableJRSUIIcon(final int width, final int height) {
-            super(width, height);
+    static abstract class ScalingJRSUIIcon implements Icon, UIResource {
+        final int width;
+        final int height;
+
+        public ScalingJRSUIIcon(final int width, final int height) {
+            this.width = width;
+            this.height = height;
         }
 
-        Image createImage() {
-            final AquaPainter<JRSUIState> painter = AquaPainter.create(JRSUIState.getInstance());
+        @Override
+        public void paintIcon(final Component c, Graphics g,
+                final int x, final int y) {
+            if (GraphicsEnvironment.isHeadless()) {
+                return;
+            }
+
+            g = g.create();
+
+            if (g instanceof Graphics2D) {
+                // improves icon rendering quality in Quartz
+                ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING,
+                        RenderingHints.VALUE_RENDER_QUALITY);
+            }
+
+            final AquaPainter<JRSUIState> painter =
+                    AquaPainter.create(JRSUIState.getInstance());
             initIconPainter(painter);
 
-            final BufferedImage img = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
-            final Graphics g = img.getGraphics();
-            g.setClip(new Rectangle(0, 0, getIconWidth(), getIconHeight()));
-            painter.paint(g, null, 0, 0, getIconWidth(), getIconHeight());
+            g.setClip(new Rectangle(x, y, width, height));
+            painter.paint(g, c, x, y, width, height);
             g.dispose();
-            return img;
         }
 
         public abstract void initIconPainter(final AquaPainter<JRSUIState> painter);
+
+        @Override
+        public int getIconWidth() {
+            return width;
+        }
+
+        @Override
+        public int getIconHeight() {
+            return height;
+        }
     }
 
     static class FileIcon extends CachingScalingIcon {
--- a/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java	Thu May 01 14:21:29 2014 -0700
@@ -787,8 +787,9 @@
     }
 
     static final RecyclableSingleton<Icon> RESIZE_ICON = new RecyclableSingleton<Icon>() {
+        @Override
         protected Icon getInstance() {
-            return new AquaIcon.CachableJRSUIIcon(11, 11) {
+            return new AquaIcon.ScalingJRSUIIcon(11, 11) {
                 public void initIconPainter(final AquaPainter<JRSUIState> iconState) {
                     iconState.state.set(Widget.GROW_BOX_TEXTURED);
                     iconState.state.set(WindowType.UTILITY);
--- a/src/macosx/classes/com/apple/laf/AquaPainter.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/classes/com/apple/laf/AquaPainter.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -141,40 +141,71 @@
             paintFromSingleCachedImage(g, control, stateToPaint, boundsRect);
         }
 
+        /**
+         * Paints a native control, which identified by its size and a set of
+         * additional arguments using a cached image.
+         *
+         * @param  g Graphics to draw the control
+         * @param  control the reference to the native control
+         * @param  controlState the state of the native control
+         * @param  bounds the rectangle where the native part should be drawn.
+         *         Note: the focus can/will be drawn outside of this bounds.
+         */
         static void paintFromSingleCachedImage(final Graphics2D g,
-                final JRSUIControl control, final JRSUIState controlState,
-                final Rectangle bounds) {
+                                               final JRSUIControl control,
+                                               final JRSUIState controlState,
+                                               final Rectangle bounds) {
             if (bounds.width <= 0 || bounds.height <= 0) {
                 return;
             }
 
-            int scale = 1;
-            if (g instanceof SunGraphics2D) {
-                scale = ((SunGraphics2D) g).surfaceData.getDefaultScale();
+            int focus = 0;
+            if (controlState.is(JRSUIConstants.Focused.YES)) {
+                focus = JRSUIConstants.FOCUS_SIZE;
             }
+
+            final int imgX = bounds.x - focus;
+            final int imgY = bounds.y - focus;
+            final int imgW = bounds.width + (focus << 1);
+            final int imgH = bounds.height + (focus << 1);
             final GraphicsConfiguration config = g.getDeviceConfiguration();
             final ImageCache cache = ImageCache.getInstance();
-            final int imgW = bounds.width * scale;
-            final int imgH = bounds.height * scale;
-            AquaPixelsKey key = new AquaPixelsKey(config,
-                    imgW, imgH, scale, controlState);
-            BufferedImage img = (BufferedImage) cache.getImage(key);
+            final AquaPixelsKey key = new AquaPixelsKey(config, imgW, imgH,
+                                                        bounds, controlState);
+            Image img = cache.getImage(key);
             if (img == null) {
-                img = new BufferedImage(imgW, imgH, BufferedImage.TYPE_INT_ARGB_PRE);
+
+                Image baseImage = createImage(imgX, imgY, imgW, imgH, bounds,
+                                              control, controlState);
+
+                img = new MultiResolutionBufferedImage(baseImage,
+                        (rvWidth, rvHeight) -> createImage(imgX, imgY,
+                         rvWidth, rvHeight, bounds, control, controlState));
+
                 if (!controlState.is(JRSUIConstants.Animating.YES)) {
                     cache.setImage(key, img);
                 }
-
-                final WritableRaster raster = img.getRaster();
-                final DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer();
-
-                control.set(controlState);
-                control.paint(SunWritableRaster.stealData(buffer, 0),
-                        imgW, imgH, 0, 0, bounds.width, bounds.height);
-                SunWritableRaster.markDirty(buffer);
             }
 
-            g.drawImage(img, bounds.x, bounds.y, bounds.width, bounds.height, null);
+            g.drawImage(img, imgX, imgY, imgW, imgH, null);
+        }
+
+        private static Image createImage(int imgX, int imgY, int imgW, int imgH,
+                                         final Rectangle bounds,
+                                         final JRSUIControl control,
+                                         JRSUIState controlState) {
+            BufferedImage img = new BufferedImage(imgW, imgH,
+                    BufferedImage.TYPE_INT_ARGB_PRE);
+
+            final WritableRaster raster = img.getRaster();
+            final DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer();
+
+            control.set(controlState);
+            control.paint(SunWritableRaster.stealData(buffer, 0), imgW, imgH,
+                          bounds.x - imgX, bounds.y - imgY, bounds.width,
+                          bounds.height);
+            SunWritableRaster.markDirty(buffer);
+            return img;
         }
     }
 
@@ -187,21 +218,22 @@
         private final GraphicsConfiguration config;
         private final int w;
         private final int h;
-        private final int scale;
+        private final Rectangle bounds;
         private final JRSUIState state;
 
         AquaPixelsKey(final GraphicsConfiguration config,
-                final int w, final int h, final int scale,
+                final int w, final int h, final Rectangle bounds,
                 final JRSUIState state) {
             this.pixelCount = w * h;
             this.config = config;
             this.w = w;
             this.h = h;
-            this.scale = scale;
+            this.bounds = bounds;
             this.state = state;
             this.hash = hash();
         }
 
+        @Override
         public int getPixelCount() {
             return pixelCount;
         }
@@ -210,7 +242,7 @@
             int hash = config != null ? config.hashCode() : 0;
             hash = 31 * hash + w;
             hash = 31 * hash + h;
-            hash = 31 * hash + scale;
+            hash = 31 * hash + bounds.hashCode();
             hash = 31 * hash + state.hashCode();
             return hash;
         }
@@ -225,7 +257,7 @@
             if (obj instanceof AquaPixelsKey) {
                 AquaPixelsKey key = (AquaPixelsKey) obj;
                 return config == key.config && w == key.w && h == key.h
-                        && scale == key.scale && state.equals(key.state);
+                        && bounds.equals(key.bounds) && state.equals(key.state);
             }
             return false;
         }
--- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Thu May 01 14:21:29 2014 -0700
@@ -44,6 +44,7 @@
 
 import sun.awt.*;
 import sun.awt.datatransfer.DataTransferer;
+import sun.java2d.opengl.OGLRenderQueue;
 import sun.lwawt.*;
 import sun.lwawt.LWWindowPeer.PeerType;
 import sun.security.action.GetBooleanAction;
@@ -410,7 +411,11 @@
 
     @Override
     public void sync() {
-        // TODO Auto-generated method stub
+        // flush the OGL pipeline (this is a no-op if OGL is not enabled)
+        OGLRenderQueue.sync();
+        // setNeedsDisplay() selector was sent to the appropriate CALayer so now
+        // we have to flush the native selectors queue.
+        flushNativeSelectors();
     }
 
     @Override
@@ -813,6 +818,11 @@
 
     private native boolean nativeSyncQueue(long timeout);
 
+    /**
+     * Just spin a single empty block synchronously.
+     */
+    private static native void flushNativeSelectors();
+
     @Override
     public Clipboard createPlatformClipboard() {
         return new CClipboard("System");
--- a/src/macosx/native/com/apple/laf/JRSUIController.m	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/com/apple/laf/JRSUIController.m	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -199,7 +199,7 @@
     CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
     CGContextRef cgRef = CGBitmapContextCreate(rawPixelData, imgW, imgH, 8, imgW * 4, colorspace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
     CGColorSpaceRelease(colorspace);
-    CGContextScaleCTM(cgRef, imgW/w , imgH/h);
+    CGContextScaleCTM(cgRef, imgW/(w + x + x) , imgH/(h + y + y));
 
     jint status = doPaintCGContext(cgRef, controlPtr, oldProperties, newProperties, x, y, w, h);
     CGContextRelease(cgRef);
--- a/src/macosx/native/sun/awt/AWTWindow.m	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/sun/awt/AWTWindow.m	Thu May 01 14:21:29 2014 -0700
@@ -762,6 +762,10 @@
     return lastKeyWindow;
 }
 
+- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame {
+    return !NSEqualSizes(self.nsWindow.frame.size, newFrame.size);
+}
+
 
 @end // AWTWindow
 
--- a/src/macosx/native/sun/awt/CClipboard.h	Thu May 01 12:51:13 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#import <AppKit/AppKit.h>
-#import "jni.h"
-
-@interface CClipboard : NSObject {
-    jobject fClipboardOwner;
-
-    // Track pasteboard changes. Initialized once at the start, and then updated
-    // on an application resume event.  If it's different than the last time we claimed
-    // the clipboard that means we lost the clipboard to someone else.
-    NSInteger fChangeCount;
-}
-
-+ (CClipboard *) sharedClipboard;
-
-- (void) javaDeclareTypes:(NSArray *)inTypes withOwner:(jobject)inClipboard jniEnv:(JNIEnv *)inEnv;
-- (void) javaSetData:(NSData *)inData forType:(NSString *) inFormat;
-
-- (NSArray *) javaGetTypes;
-- (NSData *) javaGetDataForType:(NSString *)inFormat;
-
-@end
--- a/src/macosx/native/sun/awt/CClipboard.m	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/sun/awt/CClipboard.m	Thu May 01 14:21:29 2014 -0700
@@ -23,70 +23,28 @@
  * questions.
  */
 
-#import "CClipboard.h"
 #import "CDataTransferer.h"
 #import "ThreadUtilities.h"
 #import "jni_util.h" 
 #import <Cocoa/Cocoa.h>
 #import <JavaNativeFoundation/JavaNativeFoundation.h>
 
-static CClipboard *sClipboard = nil;
-
-//
-// CClipboardUpdate is used for mulitple calls to setData that happen before
-// the model and AppKit can get back in sync.
-//
-
-@interface CClipboardUpdate : NSObject {
-    NSData *fData;
-    NSString *fFormat;
-}
-
-- (id)initWithData:(NSData *)inData withFormat:(NSString *)inFormat;
-- (NSData *)data;
-- (NSString *)format;
-
-@end
-
-@implementation CClipboardUpdate
-
-- (id)initWithData:(NSData *)inData withFormat:(NSString *)inFormat
-{
-    self = [super init];
+@interface CClipboard : NSObject { }
+@property NSInteger changeCount;
+@property jobject clipboardOwner;
 
-    if (self != nil) {
-        fData = [inData retain];
-        fFormat = [inFormat retain];
-    }
-
-    return self;
-}
-
-- (void)dealloc
-{
-    [fData release];
-    fData = nil;
-
-    [fFormat release];
-    fFormat = nil;
-
-    [super dealloc];
-}
-
-- (NSData *)data {
-    return fData;
-}
-
-- (NSString *)format {
-    return fFormat;
-}
++ (CClipboard*)sharedClipboard;
+- (void)declareTypes:(NSArray *)types withOwner:(jobject)owner jniEnv:(JNIEnv*)env;
+- (void)checkPasteboard:(id)sender;
 @end
 
 @implementation CClipboard
+@synthesize changeCount = _changeCount;
+@synthesize clipboardOwner = _clipboardOwner;
 
-// Clipboard creation is synchronized at the Java level.
-+ (CClipboard *) sharedClipboard
-{
+// Clipboard creation is synchronized at the Java level
++ (CClipboard*)sharedClipboard {
+    static CClipboard* sClipboard = nil;
     if (sClipboard == nil) {
         sClipboard = [[CClipboard alloc] init];
         [[NSNotificationCenter defaultCenter] addObserver:sClipboard selector: @selector(checkPasteboard:)
@@ -97,90 +55,38 @@
     return sClipboard;
 }
 
-- (id) init
-{
-    self = [super init];
-
-    if (self != nil) {
-        fChangeCount = [[NSPasteboard generalPasteboard] changeCount];
+- (id)init {
+    if (self = [super init]) {
+        self.changeCount = [[NSPasteboard generalPasteboard] changeCount];
     }
-
     return self;
 }
 
-- (void) javaDeclareTypes:(NSArray *)inTypes withOwner:(jobject)inClipboard jniEnv:(JNIEnv *)inEnv {
-
+- (void)declareTypes:(NSArray*)types withOwner:(jobject)owner jniEnv:(JNIEnv*)env {
     @synchronized(self) {
-        if (inClipboard != NULL) {
-            if (fClipboardOwner != NULL) {
-                JNFDeleteGlobalRef(inEnv, fClipboardOwner);
+        if (owner != NULL) {
+            if (self.clipboardOwner != NULL) {
+                JNFDeleteGlobalRef(env, self.clipboardOwner);
             }
-            fClipboardOwner = JNFNewGlobalRef(inEnv, inClipboard);
+            self.clipboardOwner = JNFNewGlobalRef(env, owner);
         }
     }
-    [ThreadUtilities performOnMainThread:@selector(_nativeDeclareTypes:) on:self withObject:inTypes waitUntilDone:YES];
-}
-
-- (void) _nativeDeclareTypes:(NSArray *)inTypes {
-    AWT_ASSERT_APPKIT_THREAD;
-
-    fChangeCount = [[NSPasteboard generalPasteboard] declareTypes:inTypes owner:self];
-}
-
-
-- (NSArray *) javaGetTypes {
-
-    NSMutableArray *args = [NSMutableArray arrayWithCapacity:1];
-    [ThreadUtilities performOnMainThread:@selector(_nativeGetTypes:) on:self withObject:args waitUntilDone:YES];
-    return [args lastObject];
-}
-
-- (void) _nativeGetTypes:(NSMutableArray *)args {
-    AWT_ASSERT_APPKIT_THREAD;
-
-    [args addObject:[[NSPasteboard generalPasteboard] types]];
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
+        self.changeCount = [[NSPasteboard generalPasteboard] declareTypes:types owner:self];
+    }];
 }
 
-- (void) javaSetData:(NSData *)inData forType:(NSString *) inFormat {
-
-    CClipboardUpdate *newUpdate = [[CClipboardUpdate alloc] initWithData:inData withFormat:inFormat];
-    [ThreadUtilities performOnMainThread:@selector(_nativeSetData:) on:self withObject:newUpdate waitUntilDone:YES];
-    [newUpdate release];
-}
-
-- (void) _nativeSetData:(CClipboardUpdate *)newUpdate {
-    AWT_ASSERT_APPKIT_THREAD;
-
-    [[NSPasteboard generalPasteboard] setData:[newUpdate data] forType:[newUpdate format]];
-}
-
-- (NSData *) javaGetDataForType:(NSString *) inFormat {
+- (void)checkPasteboard:(id)sender {
 
-    NSMutableArray *args = [NSMutableArray arrayWithObject:inFormat];
-    [ThreadUtilities performOnMainThread:@selector(_nativeGetDataForType:) on:self withObject:args waitUntilDone:YES];
-    return [args lastObject];
-}
-
-- (void) _nativeGetDataForType:(NSMutableArray *) args {
-    AWT_ASSERT_APPKIT_THREAD;
-
-    NSData *returnValue = [[NSPasteboard generalPasteboard] dataForType:[args objectAtIndex:0]];
-
-    if (returnValue) [args replaceObjectAtIndex:0 withObject:returnValue];
-    else [args removeLastObject];
-}
-
-- (void) checkPasteboard:(id)application {
-    AWT_ASSERT_APPKIT_THREAD;
-    
     // This is called via NSApplicationDidBecomeActiveNotification.
     
     // If the change count on the general pasteboard is different than when we set it
     // someone else put data on the clipboard.  That means the current owner lost ownership.
+    
     NSInteger newChangeCount = [[NSPasteboard generalPasteboard] changeCount];
-    
-    if (fChangeCount != newChangeCount) {
-        fChangeCount = newChangeCount;    
+
+    if (self.changeCount != newChangeCount) {
+        self.changeCount = newChangeCount;
 
         // Notify that the content might be changed
         static JNF_CLASS_CACHE(jc_CClipboard, "sun/lwawt/macosx/CClipboard");
@@ -191,11 +97,11 @@
         // If we have a Java pasteboard owner, tell it that it doesn't own the pasteboard anymore.
         static JNF_MEMBER_CACHE(jm_lostOwnership, jc_CClipboard, "notifyLostOwnership", "()V");
         @synchronized(self) {
-            if (fClipboardOwner) {
+            if (self.clipboardOwner) {
                 JNIEnv *env = [ThreadUtilities getJNIEnv];
-                JNFCallVoidMethod(env, fClipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event)
-                JNFDeleteGlobalRef(env, fClipboardOwner);
-                fClipboardOwner = NULL;
+                JNFCallVoidMethod(env, self.clipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event)
+                JNFDeleteGlobalRef(env, self.clipboardOwner);
+                self.clipboardOwner = NULL;
             }
         }
     }
@@ -225,7 +131,7 @@
     }
 
     (*env)->ReleasePrimitiveArrayCritical(env, inTypes, elements, JNI_ABORT);
-    [[CClipboard sharedClipboard] javaDeclareTypes:formatArray withOwner:inJavaClip jniEnv:env];
+    [[CClipboard sharedClipboard] declareTypes:formatArray withOwner:inJavaClip jniEnv:env];
 JNF_COCOA_EXIT(env);
 }
 
@@ -248,7 +154,9 @@
     NSData *bytesAsData = [NSData dataWithBytes:rawBytes length:nBytes];
     (*env)->ReleasePrimitiveArrayCritical(env, inBytes, rawBytes, JNI_ABORT);
     NSString *format = formatForIndex(inFormat);
-    [[CClipboard sharedClipboard] javaSetData:bytesAsData forType:format];
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
+        [[NSPasteboard generalPasteboard] setData:bytesAsData forType:format];
+    }];
 JNF_COCOA_EXIT(env);
 }
 
@@ -263,7 +171,12 @@
     jlongArray returnValue = NULL;
 JNF_COCOA_ENTER(env);
 
-    NSArray *dataTypes = [[CClipboard sharedClipboard] javaGetTypes];
+    __block NSArray* dataTypes;
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
+        dataTypes = [[[NSPasteboard generalPasteboard] types] retain];
+    }];
+    [dataTypes autorelease];
+    
     NSUInteger nFormats = [dataTypes count];
     NSUInteger knownFormats = 0;
     NSUInteger i;
@@ -320,11 +233,16 @@
 JNF_COCOA_ENTER(env);
 
     NSString *formatAsString = formatForIndex(format);
-    NSData *clipData = [[CClipboard sharedClipboard] javaGetDataForType:formatAsString];
-
+    __block NSData* clipData;
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
+        clipData = [[[NSPasteboard generalPasteboard] dataForType:formatAsString] retain];
+    }];
+    
     if (clipData == NULL) {
         [JNFException raise:env as:"java/io/IOException" reason:"Font transform has NaN position"];
         return NULL;
+    } else {
+        [clipData autorelease];
     }
 
     NSUInteger dataSize = [clipData length];
@@ -350,13 +268,13 @@
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CClipboard_checkPasteboard
 (JNIEnv *env, jobject inObject )
 {
-    JNF_COCOA_ENTER(env);
+JNF_COCOA_ENTER(env);
 
     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         [[CClipboard sharedClipboard] checkPasteboard:nil];
     }];
         
-    JNF_COCOA_EXIT(env);
+JNF_COCOA_EXIT(env);
 }
 
 
--- a/src/macosx/native/sun/awt/CImage.m	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/sun/awt/CImage.m	Thu May 01 14:21:29 2014 -0700
@@ -379,7 +379,7 @@
         return getOrder(size1.width <= size2.width && size1.height <= size2.height);
     }];
 
-    NSMutableArray *sortedPixelSizes = [[NSMutableArray alloc] init];
+    NSMutableArray *sortedPixelSizes = [[[NSMutableArray alloc] init] autorelease];
     NSSize lastSize = [[sortedImageRepresentations lastObject] size];
     
     NSUInteger i = [sortedImageRepresentations indexOfObjectPassingTest:
--- a/src/macosx/native/sun/awt/CTextPipe.m	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/sun/awt/CTextPipe.m	Thu May 01 14:21:29 2014 -0700
@@ -147,7 +147,7 @@
 
     CGAffineTransform invTx = CGAffineTransformInvert(strike->fTx);
 
-    NSUInteger i;
+    NSInteger i;
     for (i = 0; i < length; i++)
     {
         CGGlyph glyph = glyphs[i];
@@ -355,19 +355,31 @@
     static JNF_CLASS_CACHE(jc_StandardGlyphVector_GlyphTransformInfo, "sun/font/StandardGlyphVector$GlyphTransformInfo");
     static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_transforms, jc_StandardGlyphVector_GlyphTransformInfo, "transforms", "[D");
     jdoubleArray g_gtiTransformsArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_transforms); //(*env)->GetObjectField(env, gti, g_gtiTransforms);
+    if (g_gtiTransformsArray == NULL) {
+        return;
+    } 
     jdouble *g_gvTransformsAsDoubles = (*env)->GetPrimitiveArrayCritical(env, g_gtiTransformsArray, NULL);
+    if (g_gvTransformsAsDoubles == NULL) {
+        (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
+        return;
+    } 
 
     static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_indices, jc_StandardGlyphVector_GlyphTransformInfo, "indices", "[I");
     jintArray g_gtiTXIndicesArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_indices);
     jint *g_gvTXIndicesAsInts = (*env)->GetPrimitiveArrayCritical(env, g_gtiTXIndicesArray, NULL);
-
+    if (g_gvTXIndicesAsInts == NULL) {
+        (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTransformsArray, g_gvTransformsAsDoubles, JNI_ABORT);
+        (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
+        (*env)->DeleteLocalRef(env, g_gtiTXIndicesArray);
+        return;
+    }
     // slowest case, we have per-glyph transforms, and possibly glyph substitution as well
     JavaCT_DrawGlyphVector(qsdo, strike, useSubstituion, uniChars, glyphs, advances, g_gvTXIndicesAsInts, g_gvTransformsAsDoubles, length);
 
     (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTransformsArray, g_gvTransformsAsDoubles, JNI_ABORT);
-    (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
+    (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTXIndicesArray, g_gvTXIndicesAsInts, JNI_ABORT);
 
-    (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTXIndicesArray, g_gvTXIndicesAsInts, JNI_ABORT);
+    (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
     (*env)->DeleteLocalRef(env, g_gtiTXIndicesArray);
 }
 
@@ -403,6 +415,9 @@
 {
     // fill the glyph buffer
     jint *glyphsAsInts = (*env)->GetPrimitiveArrayCritical(env, glyphsArray, NULL);
+    if (glyphsAsInts == NULL) {
+        return;
+    }
 
     // if a glyph code from Java is negative, that means it is really a unicode value
     // which we can use in CoreText to strike the character in another font
@@ -429,11 +444,15 @@
     // fill the advance buffer
     static JNF_MEMBER_CACHE(jm_StandardGlyphVector_positions, jc_StandardGlyphVector, "positions", "[F");
     jfloatArray posArray = JNFGetObjectField(env, gVector, jm_StandardGlyphVector_positions);
-    if (posArray != NULL)
-    {
+    jfloat *positions = NULL;
+    if (posArray != NULL) {
         // in this case, the positions have already been pre-calculated for us on the Java side
-
-        jfloat *positions = (*env)->GetPrimitiveArrayCritical(env, posArray, NULL);
+        positions = (*env)->GetPrimitiveArrayCritical(env, posArray, NULL);
+        if (positions == NULL) {
+            (*env)->DeleteLocalRef(env, posArray);
+        }
+    }
+    if (positions != NULL) {
         CGPoint prev;
         prev.x = positions[0];
         prev.y = positions[1];
--- a/src/macosx/native/sun/awt/JavaComponentAccessibility.m	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/sun/awt/JavaComponentAccessibility.m	Thu May 01 14:21:29 2014 -0700
@@ -242,11 +242,15 @@
         jsize count = [ignoredKeys count];
 
         JNIEnv *env = [ThreadUtilities getJNIEnv];
-        jclass clazz = (*env)->FindClass(env, "java/lang/String");
-        result = (*env)->NewObjectArray(env, count, clazz, NULL); // AWT_THREADING Safe (known object)
-        (*env)->DeleteLocalRef(env, clazz);
 
-        NSUInteger i;
+        static JNF_CLASS_CACHE(jc_String, "java/lang/String");
+        result = JNFNewObjectArray(env, &jc_String, count);
+        if (!result) {
+            NSLog(@"In %s, can't create Java array of String objects", __FUNCTION__);
+            return;
+        }
+
+        NSInteger i;
         for (i = 0; i < count; i++) {
             jstring jString = JNFNSToJavaString(env, [ignoredKeys objectAtIndex:i]);
             (*env)->SetObjectArrayElement(env, result, i, jString);
@@ -281,7 +285,7 @@
     jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
     NSMutableArray *children = [NSMutableArray arrayWithCapacity:arrayLen/2]; //childrenAndRoles array contains two elements (child, role) for each child
 
-    NSUInteger i;
+    NSInteger i;
     NSUInteger childIndex = (whichChildren >= 0) ? whichChildren : 0; // if we're getting one particular child, make sure to set its index correctly
     for(i = 0; i < arrayLen; i+=2)
     {
@@ -377,8 +381,13 @@
     // Get all the other accessibility attributes states we need in one swell foop.
     // javaRole isn't pulled in because we need protected access to AccessibleRole.key
     jbooleanArray attributeStates = JNFCallStaticObjectMethod(env, jm_getInitialAttributeStates, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
-    if (attributeStates == NULL) return NULL;
+    if (attributeStates == NULL) return nil;
     jboolean *attributeStatesArray = (*env)->GetBooleanArrayElements(env, attributeStates, 0);
+    if (attributeStatesArray == NULL) {
+        // Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
+        NSLog(@"%s failed calling GetBooleanArrayElements", __FUNCTION__);
+        return nil;
+    }
 
     // if there's a component, it can be enabled and it has a size/position
     if (attributeStatesArray[0]) {
@@ -1206,7 +1215,7 @@
     // Go through the tabs and find selAccessible
     _numTabs = [tabs count];
     JavaComponentAccessibility *aTab;
-    NSUInteger i;
+    NSInteger i;
     for (i = 0; i < _numTabs; i++) {
         aTab = (JavaComponentAccessibility *)[tabs objectAtIndex:i];
         if ([aTab isAccessibleWithEnv:env forAccessible:selAccessible]) {
@@ -1233,7 +1242,7 @@
 
     NSString *tabJavaRole = JNFJavaToNSString(env, JNFGetObjectField(env, jtabJavaRole, sjf_key));
 
-    NSUInteger i;
+    NSInteger i;
     NSUInteger tabIndex = (whichTabs >= 0) ? whichTabs : 0; // if we're getting one particular child, make sure to set its index correctly
     for(i = 0; i < arrayLen; i+=2) {
         jobject jtab = (*env)->GetObjectArrayElement(env, jtabsAndRoles, i);
--- a/src/macosx/native/sun/awt/JavaTextAccessibility.m	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/sun/awt/JavaTextAccessibility.m	Thu May 01 14:21:29 2014 -0700
@@ -40,6 +40,11 @@
  */
 NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
     jint *values = (*env)->GetIntArrayElements(env, array, 0);
+    if (values == NULL) {
+        // Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
+        NSLog(@"%s failed calling GetIntArrayElements", __FUNCTION__);
+        return nil;
+    };
     NSValue *value = [NSValue valueWithRange:NSMakeRange(values[0], values[1] - values[0])];
     (*env)->ReleaseIntArrayElements(env, array, values, 0);
     return value;
@@ -285,6 +290,11 @@
 
     // We cheat because we know that the array is 4 elements long (x, y, width, height)
     jdouble *values = (*env)->GetDoubleArrayElements(env, axBounds, 0);
+    if (values == NULL) {
+        // Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
+        NSLog(@"%s failed calling GetDoubleArrayElements", __FUNCTION__); 
+        return nil;
+    };
     NSRect bounds;
     bounds.origin.x = values[0];
     bounds.origin.y = [[[[self view] window] screen] frame].size.height - values[1] - values[3]; //values[1] is y-coord from top-left of screen. Flip. Account for the height (values[3]) when flipping
--- a/src/macosx/native/sun/awt/LWCToolkit.m	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/sun/awt/LWCToolkit.m	Thu May 01 14:21:29 2014 -0700
@@ -144,6 +144,18 @@
     return JNI_FALSE;
 }
 
+/*
+ * Class:     sun_lwawt_macosx_LWCToolkit
+ * Method:    flushNativeSelectors
+ * Signature: ()J
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_flushNativeSelectors
+(JNIEnv *env, jclass clz)
+{
+JNF_COCOA_ENTER(env);
+        [ThreadUtilities performOnMainThreadWaiting:YES block:^(){}];
+JNF_COCOA_EXIT(env);
+}
 
 static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
 static JNF_MEMBER_CACHE(jf_Component_appContext, jc_Component, "appContext", "Lsun/awt/AppContext;");
--- a/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m	Thu May 01 14:21:29 2014 -0700
@@ -142,9 +142,16 @@
     splash->screenFormat.byteOrder = 1 ?  BYTE_ORDER_LSBFIRST : BYTE_ORDER_MSBFIRST;
     splash->screenFormat.depthBytes = 4;
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
-        [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
-    }];
+    // If this property is present we are running SWT and should not start a runLoop
+    // Can't check if running SWT in webstart, so splash screen in webstart SWT
+    // applications is not supported
+    char envVar[80];
+    snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
+    if (getenv(envVar) == NULL) {
+        [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
+            [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
+        }];
+    }
 }
 
 void
--- a/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Thu May 01 14:21:29 2014 -0700
@@ -154,7 +154,10 @@
                 if (pmStr != NULL) {
                     CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8);
                     CFRelease(pmStr);
-                    (*env)->SetObjectArrayElement(env, ampms, 1, (*env)->NewStringUTF(env, buf));
+                    tmp_string = (*env)->NewStringUTF(env, buf);
+                    if (tmp_string != NULL) {
+                        (*env)->SetObjectArrayElement(env, ampms, 1, tmp_string);
+                    }
                 }
             }
             CFRelease(df);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/back/InterfaceTypeImpl.c	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "util.h"
+#include "InterfaceTypeImpl.h"
+#include "inStream.h"
+#include "outStream.h"
+
+static jboolean
+invokeStatic(PacketInputStream *in, PacketOutputStream *out)
+{
+    return sharedInvoke(in, out);
+}
+
+void *InterfaceType_Cmds[] = { (void *)0x1
+    , (void *)invokeStatic
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/back/InterfaceTypeImpl.h	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+extern void *InterfaceType_Cmds[];
--- a/src/share/back/VirtualMachineImpl.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/back/VirtualMachineImpl.c	Thu May 01 14:21:29 2014 -0700
@@ -36,7 +36,7 @@
 
 static char *versionName = "Java Debug Wire Protocol (Reference Implementation)";
 static int majorVersion = 1;  /* JDWP major version */
-static int minorVersion = 6;  /* JDWP minor version */
+static int minorVersion = 8;  /* JDWP minor version */
 
 static jboolean
 version(PacketInputStream *in, PacketOutputStream *out)
--- a/src/share/back/debugDispatch.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/back/debugDispatch.c	Thu May 01 14:21:29 2014 -0700
@@ -29,6 +29,7 @@
 #include "VirtualMachineImpl.h"
 #include "ReferenceTypeImpl.h"
 #include "ClassTypeImpl.h"
+#include "InterfaceTypeImpl.h"
 #include "ArrayTypeImpl.h"
 #include "FieldImpl.h"
 #include "MethodImpl.h"
@@ -67,6 +68,7 @@
     l1Array[JDWP_COMMAND_SET(VirtualMachine)] = (void *)VirtualMachine_Cmds;
     l1Array[JDWP_COMMAND_SET(ReferenceType)] = (void *)ReferenceType_Cmds;
     l1Array[JDWP_COMMAND_SET(ClassType)] = (void *)ClassType_Cmds;
+    l1Array[JDWP_COMMAND_SET(InterfaceType)] = (void *)InterfaceType_Cmds;
     l1Array[JDWP_COMMAND_SET(ArrayType)] = (void *)ArrayType_Cmds;
 
     l1Array[JDWP_COMMAND_SET(Field)] = (void *)Field_Cmds;
--- a/src/share/back/util.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/back/util.c	Thu May 01 14:21:29 2014 -0700
@@ -591,6 +591,8 @@
         invokeType = INVOKE_CONSTRUCTOR;
     } else if (inStream_command(in) == JDWP_COMMAND(ClassType, InvokeMethod)) {
         invokeType = INVOKE_STATIC;
+    } else if (inStream_command(in) == JDWP_COMMAND(InterfaceType, InvokeMethod)) {
+        invokeType = INVOKE_STATIC;
     } else if (inStream_command(in) == JDWP_COMMAND(ObjectReference, InvokeMethod)) {
         invokeType = INVOKE_INSTANCE;
     } else {
--- a/src/share/classes/com/sun/beans/util/Cache.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/beans/util/Cache.java	Thu May 01 14:21:29 2014 -0700
@@ -119,13 +119,13 @@
         synchronized (this.queue) {
             // synchronized search improves stability
             // we must create and add new value if there are no needed entry
-            int index = index(hash, this.table);
-            current = getEntryValue(key, hash, this.table[index]);
+            current = getEntryValue(key, hash, this.table[index(hash, this.table)]);
             if (current != null) {
                 return current;
             }
             V value = create(key);
             Objects.requireNonNull(value, "value");
+            int index = index(hash, this.table);
             this.table[index] = new CacheEntry<>(hash, key, value, this.table[index]);
             if (++this.size >= this.threshold) {
                 if (this.table.length == MAXIMUM_CAPACITY) {
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifScrollBarUI.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifScrollBarUI.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,17 +24,19 @@
  */
 package com.sun.java.swing.plaf.motif;
 
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.*;
-import javax.swing.border.*;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JScrollBar;
+import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicScrollBarUI;
 
-import java.awt.Dimension;
-import java.awt.Insets;
-import java.awt.Rectangle;
-import java.awt.Graphics;
-import java.awt.Color;
+import static sun.swing.SwingUtilities2.drawHLine;
+import static sun.swing.SwingUtilities2.drawVLine;
 
 
 /**
@@ -74,17 +76,13 @@
         return new MotifScrollBarButton(orientation);
     }
 
-
     public void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)  {
         g.setColor(trackColor);
         g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height);
     }
 
-
-    public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
-    {
-
-        if(thumbBounds.isEmpty() || !scrollbar.isEnabled())     {
+    public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
+        if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
             return;
         }
 
@@ -93,15 +91,15 @@
 
         g.translate(thumbBounds.x, thumbBounds.y);
         g.setColor(thumbColor);
-        g.fillRect(0, 0, w-1, h-1);
+        g.fillRect(0, 0, w - 1, h - 1);
 
         g.setColor(thumbHighlightColor);
-        g.drawLine(0, 0, 0, h-1);
-        g.drawLine(1, 0, w-1, 0);
+        drawVLine(g, 0, 0, h - 1);
+        drawHLine(g, 1, w - 1, 0);
 
         g.setColor(thumbLightShadowColor);
-        g.drawLine(1, h-1, w-1, h-1);
-        g.drawLine(w-1, 1, w-1, h-2);
+        drawHLine(g, 1, w - 1, h - 1);
+        drawVLine(g, w - 1, 1, h - 2);
 
         g.translate(-thumbBounds.x, -thumbBounds.y);
     }
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifSliderUI.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifSliderUI.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,17 @@
 
 package com.sun.java.swing.plaf.motif;
 
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
 
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.*;
+import javax.swing.JComponent;
+import javax.swing.JSlider;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicSliderUI;
 
-import javax.swing.plaf.basic.BasicSliderUI;
+import static sun.swing.SwingUtilities2.drawHLine;
+import static sun.swing.SwingUtilities2.drawVLine;
 
 /**
  * Motif Slider
@@ -123,15 +126,15 @@
 
             // highlight
             g.setColor(getHighlightColor());
-            g.drawLine(0, 1, w - 1, 1);             // top
-            g.drawLine(0, 1, 0, h);                     // left
-            g.drawLine(w/2, 2, w/2, h-1);       // center
+            drawHLine(g, 0, w - 1, 1);      // top
+            drawVLine(g, 0, 1, h);          // left
+            drawVLine(g, w / 2, 2, h - 1);  // center
 
             // shadow
             g.setColor(getShadowColor());
-            g.drawLine(0, h, w - 1, h);         // bottom
-            g.drawLine(w - 1, 1, w - 1, h);     // right
-            g.drawLine(w/2 - 1, 2, w/2 - 1, h); // center
+            drawHLine(g, 0, w - 1, h);      // bottom
+            drawVLine(g, w - 1, 1, h);      // right
+            drawVLine(g, w / 2 - 1, 2, h);  // center
 
             g.translate(-x, -(knobBounds.y-1));
         }
@@ -143,15 +146,15 @@
 
             // highlight
             g.setColor(getHighlightColor());
-            g.drawLine(1, y, w, y);                     // top
-            g.drawLine(1, y+1, 1, y+h-1);               // left
-            g.drawLine(2, y+h/2, w-1, y+h/2);           // center
+            drawHLine(g, 1, w, y);             // top
+            drawVLine(g, 1, y + 1, y + h - 1); // left
+            drawHLine(g, 2, w - 1, y + h / 2); // center
 
             // shadow
             g.setColor(getShadowColor());
-            g.drawLine(2, y+h-1, w, y+h-1);             // bottom
-            g.drawLine(w, y+h-1, w, y);                 // right
-            g.drawLine(2, y+h/2-1, w-1, y+h/2-1);       // center
+            drawHLine(g, 2, w, y + h - 1);        // bottom
+            drawVLine(g, w, y + h - 1, y);        // right
+            drawHLine(g, 2, w - 1, y + h / 2 - 1);// center
 
             g.translate(-(knobBounds.x-1), 0);
         }
--- a/src/share/classes/com/sun/jdi/ClassType.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/jdi/ClassType.java	Thu May 01 14:21:29 2014 -0700
@@ -103,7 +103,7 @@
      * <p>
      * Object values must be assignment compatible with the field type
      * (This implies that the field type must be loaded through the
-     * enclosing class's class loader). Primitive values must be
+     * enclosing class' class loader). Primitive values must be
      * either assignment compatible with the field type or must be
      * convertible to the field type without loss of information.
      * See JLS section 5.2 for more information on assignment
@@ -153,7 +153,7 @@
      * <p>
      * Object arguments must be assignment compatible with the argument type
      * (This implies that the argument type must be loaded through the
-     * enclosing class's class loader). Primitive arguments must be
+     * enclosing class' class loader). Primitive arguments must be
      * either assignment compatible with the argument type or must be
      * convertible to the argument type without loss of information.
      * If the method being called accepts a variable number of arguments,
@@ -216,7 +216,7 @@
      * @return a {@link Value} mirror of the invoked method's return value.
      * @throws java.lang.IllegalArgumentException if the method is not
      * a member of this class or a superclass, if the size of the argument list
-     * does not match the number of declared arguemnts for the method, or
+     * does not match the number of declared arguments for the method, or
      * if the method is an initializer, constructor or static intializer.
      * @throws {@link InvalidTypeException} if any argument in the
      * argument list is not assignable to the corresponding method argument
@@ -230,7 +230,7 @@
      * @throws InvalidTypeException If the arguments do not meet this requirement --
      *         Object arguments must be assignment compatible with the argument
      *         type.  This implies that the argument type must be
-     *         loaded through the enclosing class's class loader.
+     *         loaded through the enclosing class' class loader.
      *         Primitive arguments must be either assignment compatible with the
      *         argument type or must be convertible to the argument type without loss
      *         of information. See JLS section 5.2 for more information on assignment
@@ -267,7 +267,7 @@
      * <p>
      * Object arguments must be assignment compatible with the argument type
      * (This implies that the argument type must be loaded through the
-     * enclosing class's class loader). Primitive arguments must be
+     * enclosing class' class loader). Primitive arguments must be
      * either assignment compatible with the argument type or must be
      * convertible to the argument type without loss of information.
      * If the method being called accepts a variable number of arguments,
@@ -335,7 +335,7 @@
      * @throws InvalidTypeException If the arguments do not meet this requirement --
      *         Object arguments must be assignment compatible with the argument
      *         type.  This implies that the argument type must be
-     *         loaded through the enclosing class's class loader.
+     *         loaded through the enclosing class' class loader.
      *         Primitive arguments must be either assignment compatible with the
      *         argument type or must be convertible to the argument type without loss
      *         of information. See JLS section 5.2 for more information on assignment
--- a/src/share/classes/com/sun/jdi/InterfaceType.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/jdi/InterfaceType.java	Thu May 01 14:21:29 2014 -0700
@@ -79,4 +79,123 @@
      * If none exist, returns a zero length List.
      */
     List<ClassType> implementors();
+
+    /**
+     * Invokes the specified static {@link Method} in the
+     * target VM. The
+     * specified method must be defined in this interface.
+     * The method must be a static method
+     * but not a static initializer.
+     * <p>
+     * The method invocation will occur in the specified thread.
+     * Method invocation can occur only if the specified thread
+     * has been suspended by an event which occurred in that thread.
+     * Method invocation is not supported
+     * when the target VM has been suspended through
+     * {@link VirtualMachine#suspend} or when the specified thread
+     * is suspended through {@link ThreadReference#suspend}.
+     * <p>
+     * The specified method is invoked with the arguments in the specified
+     * argument list.  The method invocation is synchronous; this method
+     * does not return until the invoked method returns in the target VM.
+     * If the invoked method throws an exception, this method will throw
+     * an {@link InvocationException} which contains a mirror to the exception
+     * object thrown.
+     * <p>
+     * Object arguments must be assignment compatible with the argument type
+     * (This implies that the argument type must be loaded through the
+     * enclosing class' class loader). Primitive arguments must be
+     * either assignment compatible with the argument type or must be
+     * convertible to the argument type without loss of information.
+     * If the method being called accepts a variable number of arguments,
+     * then the last argument type is an array of some component type.
+     * The argument in the matching position can be omitted, or can be null,
+     * an array of the same component type, or an argument of the
+     * component type followed by any number of other arguments of the same
+     * type. If the argument is omitted, then a 0 length array of the
+     * component type is passed.  The component type can be a primitive type.
+     * Autoboxing is not supported.
+     *
+     * See Section 5.2 of
+     * <cite>The Java&trade; Language Specification</cite>
+     * for more information on assignment compatibility.
+     * <p>
+     * By default, all threads in the target VM are resumed while
+     * the method is being invoked if they were previously
+     * suspended by an event or by {@link VirtualMachine#suspend} or
+     * {@link ThreadReference#suspend}. This is done to prevent the deadlocks
+     * that will occur if any of the threads own monitors
+     * that will be needed by the invoked method.
+     * Note, however, that this implicit resume acts exactly like
+     * {@link ThreadReference#resume}, so if the thread's suspend
+     * count is greater than 1, it will remain in a suspended state
+     * during the invocation and thus a deadlock could still occur.
+     * By default, when the invocation completes,
+     * all threads in the target VM are suspended, regardless their state
+     * before the invocation.
+     * It is possible that
+     * breakpoints or other events might occur during the invocation.
+     * This can cause deadlocks as described above. It can also cause a deadlock
+     * if invokeMethod is called from the client's event handler thread.  In this
+     * case, this thread will be waiting for the invokeMethod to complete and
+     * won't read the EventSet that comes in for the new event.  If this
+     * new EventSet is SUSPEND_ALL, then a deadlock will occur because no
+     * one will resume the EventSet.  To avoid this, all EventRequests should
+     * be disabled before doing the invokeMethod, or the invokeMethod should
+     * not be done from the client's event handler thread.
+     * <p>
+     * The resumption of other threads during the invocation can be prevented
+     * by specifying the {@link #INVOKE_SINGLE_THREADED}
+     * bit flag in the <code>options</code> argument; however,
+     * there is no protection against or recovery from the deadlocks
+     * described above, so this option should be used with great caution.
+     * Only the specified thread will be resumed (as described for all
+     * threads above). Upon completion of a single threaded invoke, the invoking thread
+     * will be suspended once again. Note that any threads started during
+     * the single threaded invocation will not be suspended when the
+     * invocation completes.
+     * <p>
+     * If the target VM is disconnected during the invoke (for example, through
+     * {@link VirtualMachine#dispose}) the method invocation continues.
+     *
+     * @param thread the thread in which to invoke.
+     * @param method the {@link Method} to invoke.
+     * @param arguments the list of {@link Value} arguments bound to the
+     * invoked method. Values from the list are assigned to arguments
+     * in the order they appear in the method signature.
+     * @param options the integer bit flag options.
+     * @return a {@link Value} mirror of the invoked method's return value.
+     * @throws java.lang.IllegalArgumentException if the method is not
+     * a member of this interface, if the size of the argument list
+     * does not match the number of declared arguments for the method, or
+     * if the method is not static or is a static initializer.
+     * @throws {@link InvalidTypeException} if any argument in the
+     * argument list is not assignable to the corresponding method argument
+     * type.
+     * @throws ClassNotLoadedException if any argument type has not yet been loaded
+     * through the appropriate class loader.
+     * @throws IncompatibleThreadStateException if the specified thread has not
+     * been suspended by an event.
+     * @throws InvocationException if the method invocation resulted in
+     * an exception in the target VM.
+     * @throws InvalidTypeException If the arguments do not meet this requirement --
+     *         Object arguments must be assignment compatible with the argument
+     *         type.  This implies that the argument type must be
+     *         loaded through the enclosing class' class loader.
+     *         Primitive arguments must be either assignment compatible with the
+     *         argument type or must be convertible to the argument type without loss
+     *         of information. See JLS section 5.2 for more information on assignment
+     *         compatibility.
+     * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+     *
+     * @since 1.8
+     */
+    default Value invokeMethod(ThreadReference thread, Method method,
+                       List<? extends Value> arguments, int options)
+            throws InvalidTypeException,
+            ClassNotLoadedException,
+            IncompatibleThreadStateException,
+            InvocationException {
+        throw new UnsupportedOperationException();
+    }
 }
--- a/src/share/classes/com/sun/jdi/Method.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/jdi/Method.java	Thu May 01 14:21:29 2014 -0700
@@ -138,6 +138,18 @@
     boolean isAbstract();
 
     /**
+     * Determine if this method is a default method
+     *
+     * @return <code>true</code> if the method is declared default;
+     * false otherwise
+     *
+     * @since 1.8
+     */
+    default boolean isDefault() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
      * Determine if this method is synchronized.
      *
      * @return <code>true</code> if the method is declared synchronized;
--- a/src/share/classes/com/sun/jdi/ObjectReference.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/jdi/ObjectReference.java	Thu May 01 14:21:29 2014 -0700
@@ -194,10 +194,10 @@
      * {@link #INVOKE_NONVIRTUAL} bit flag in the <code>options</code>
      * argument. If this flag is set, the specified method is invoked
      * whether or not it is overridden for this object's runtime type.
-     * The method, in this case, must not belong to an interface and
-     * must not be abstract. This option is useful for performing method
-     * invocations like those done with the <code>super</code> keyword in
-     * the Java programming language.
+     * The method, in this case, must have an implementation, either in a class
+     * or an interface. This option is useful for performing method invocations
+     * like those done with the <code>super</code> keyword in the Java programming
+     * language.
      * <p>
      * By default, all threads in the target VM are resumed while
      * the method is being invoked if they were previously
@@ -246,10 +246,10 @@
      * @return a {@link Value} mirror of the invoked method's return value.
      * @throws java.lang.IllegalArgumentException if the method is not
      * a member of this object's class, if the size of the argument list
-     * does not match the number of declared arguemnts for the method,
+     * does not match the number of declared arguments for the method,
      * if the method is a constructor or static intializer, or
      * if {@link #INVOKE_NONVIRTUAL} is specified and the method is
-     * either abstract or an interface member.
+     * either abstract or a non-default interface member.
      * @throws {@link InvalidTypeException} if any argument in the
      * argument list is not assignable to the corresponding method argument
      * type.
--- a/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -118,6 +118,7 @@
         return null;
     }
 
+    @SuppressWarnings("fallthrough")
     public void processControlLogic() {
         for (int i = 0; i < used_count; i++) {
 
@@ -170,6 +171,7 @@
                         this.delay[i][0] / 1200.0) / control_time);
                 if (stage_ix[i] < 0)
                     stage_ix[i] = 0;
+                // Fallthrough
             case EG_DELAY:
                 if (stage_ix[i] == 0) {
                     double attack = this.attack[i][0];
--- a/src/share/classes/com/sun/tools/example/debug/expr/LValue.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/tools/example/debug/expr/LValue.java	Thu May 01 14:21:29 2014 -0700
@@ -559,6 +559,9 @@
             } else if (refType instanceof ClassType) {
                 ClassType clazz = (ClassType)refType;
                 return jdiValue = clazz.invokeMethod(thread, matchingMethod, methodArguments, 0);
+            } else if (refType instanceof InterfaceType) {
+                InterfaceType iface = (InterfaceType)refType;
+                return jdiValue = iface.invokeMethod(thread, matchingMethod, methodArguments, 0);
             } else {
                 throw new InvalidTypeException("Cannot invoke static method on " +
                                          refType.name());
--- a/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java	Thu May 01 14:21:29 2014 -0700
@@ -29,9 +29,27 @@
 
 import java.util.*;
 
-public class ClassTypeImpl extends ReferenceTypeImpl
+final public class ClassTypeImpl extends InvokableTypeImpl
     implements ClassType
 {
+    private static class IResult implements InvocationResult {
+        final private JDWP.ClassType.InvokeMethod rslt;
+
+        public IResult(JDWP.ClassType.InvokeMethod rslt) {
+            this.rslt = rslt;
+        }
+
+        @Override
+        public ObjectReferenceImpl getException() {
+            return rslt.exception;
+        }
+
+        @Override
+        public ValueImpl getResult() {
+            return rslt.returnValue;
+        }
+    }
+
     private boolean cachedSuperclass = false;
     private ClassType superclass = null;
     private int lastLine = -1;
@@ -65,6 +83,7 @@
         return superclass;
     }
 
+    @Override
     public List<InterfaceType> interfaces()  {
         if (interfaces == null) {
             interfaces = getInterfaces();
@@ -72,26 +91,9 @@
         return interfaces;
     }
 
-    void addInterfaces(List<InterfaceType> list) {
-        List<InterfaceType> immediate = interfaces();
-        list.addAll(interfaces());
-
-        Iterator<InterfaceType> iter = immediate.iterator();
-        while (iter.hasNext()) {
-            InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
-            interfaze.addSuperinterfaces(list);
-        }
-
-        ClassTypeImpl superclass = (ClassTypeImpl)superclass();
-        if (superclass != null) {
-            superclass.addInterfaces(list);
-        }
-    }
-
-    public List<InterfaceType> allInterfaces()  {
-        List<InterfaceType> all = new ArrayList<InterfaceType>();
-        addInterfaces(all);
-        return all;
+    @Override
+    public List<InterfaceType> allInterfaces() {
+        return getAllInterfaces();
     }
 
     public List<ClassType> subclasses() {
@@ -159,28 +161,6 @@
         }
     }
 
-    PacketStream sendInvokeCommand(final ThreadReferenceImpl thread,
-                                   final MethodImpl method,
-                                   final ValueImpl[] args,
-                                   final int options) {
-        CommandSender sender =
-            new CommandSender() {
-                public PacketStream send() {
-                    return JDWP.ClassType.InvokeMethod.enqueueCommand(
-                                          vm, ClassTypeImpl.this, thread,
-                                          method.ref(), args, options);
-                }
-        };
-
-        PacketStream stream;
-        if ((options & INVOKE_SINGLE_THREADED) != 0) {
-            stream = thread.sendResumingCommand(sender);
-        } else {
-            stream = vm.sendResumingCommand(sender);
-        }
-        return stream;
-    }
-
     PacketStream sendNewInstanceCommand(final ThreadReferenceImpl thread,
                                    final MethodImpl method,
                                    final ValueImpl[] args,
@@ -203,52 +183,6 @@
         return stream;
     }
 
-    public Value invokeMethod(ThreadReference threadIntf, Method methodIntf,
-                              List<? extends Value> origArguments, int options)
-                                   throws InvalidTypeException,
-                                          ClassNotLoadedException,
-                                          IncompatibleThreadStateException,
-                                          InvocationException {
-        validateMirror(threadIntf);
-        validateMirror(methodIntf);
-        validateMirrorsOrNulls(origArguments);
-
-        MethodImpl method = (MethodImpl)methodIntf;
-        ThreadReferenceImpl thread = (ThreadReferenceImpl)threadIntf;
-
-        validateMethodInvocation(method);
-
-        List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments);
-
-        ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
-        JDWP.ClassType.InvokeMethod ret;
-        try {
-            PacketStream stream =
-                sendInvokeCommand(thread, method, args, options);
-            ret = JDWP.ClassType.InvokeMethod.waitForReply(vm, stream);
-        } catch (JDWPException exc) {
-            if (exc.errorCode() == JDWP.Error.INVALID_THREAD) {
-                throw new IncompatibleThreadStateException();
-            } else {
-                throw exc.toJDIException();
-            }
-        }
-
-        /*
-         * There is an implict VM-wide suspend at the conclusion
-         * of a normal (non-single-threaded) method invoke
-         */
-        if ((options & INVOKE_SINGLE_THREADED) == 0) {
-            vm.notifySuspend();
-        }
-
-        if (ret.exception != null) {
-            throw new InvocationException(ret.exception);
-        } else {
-            return ret.returnValue;
-        }
-    }
-
     public ObjectReference newInstance(ThreadReference threadIntf,
                                        Method methodIntf,
                                        List<? extends Value> origArguments,
@@ -311,58 +245,6 @@
        return method;
    }
 
-   public List<Method> allMethods() {
-        ArrayList<Method> list = new ArrayList<Method>(methods());
-
-        ClassType clazz = superclass();
-        while (clazz != null) {
-            list.addAll(clazz.methods());
-            clazz = clazz.superclass();
-        }
-
-        /*
-         * Avoid duplicate checking on each method by iterating through
-         * duplicate-free allInterfaces() rather than recursing
-         */
-        for (InterfaceType interfaze : allInterfaces()) {
-            list.addAll(interfaze.methods());
-        }
-
-        return list;
-    }
-
-    List<ReferenceType> inheritedTypes() {
-        List<ReferenceType> inherited = new ArrayList<ReferenceType>();
-        if (superclass() != null) {
-            inherited.add(0, (ReferenceType)superclass()); /* insert at front */
-        }
-        for (ReferenceType rt : interfaces()) {
-            inherited.add(rt);
-        }
-        return inherited;
-    }
-
-    void validateMethodInvocation(Method method)
-                                   throws InvalidTypeException,
-                                          InvocationException {
-        /*
-         * Method must be in this class or a superclass.
-         */
-        ReferenceTypeImpl declType = (ReferenceTypeImpl)method.declaringType();
-        if (!declType.isAssignableFrom(this)) {
-            throw new IllegalArgumentException("Invalid method");
-        }
-
-        /*
-         * Method must be a static and not a static initializer
-         */
-        if (!method.isStatic()) {
-            throw new IllegalArgumentException("Cannot invoke instance method on a class type");
-        } else if (method.isStaticInitializer()) {
-            throw new IllegalArgumentException("Cannot invoke static initializer");
-        }
-    }
-
     void validateConstructorInvocation(Method method)
                                    throws InvalidTypeException,
                                           InvocationException {
@@ -382,51 +264,33 @@
         }
     }
 
-    @Override
-    void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces) {
-        /*
-         * Add methods from
-         * parent types first, so that the methods in this class will
-         * overwrite them in the hash table
-         */
-
-        Iterator<InterfaceType> iter = interfaces().iterator();
-        while (iter.hasNext()) {
-            InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
-            if (!seenInterfaces.contains(interfaze)) {
-                interfaze.addVisibleMethods(methodMap, seenInterfaces);
-                seenInterfaces.add(interfaze);
-            }
-        }
-
-        ClassTypeImpl clazz = (ClassTypeImpl)superclass();
-        if (clazz != null) {
-            clazz.addVisibleMethods(methodMap, seenInterfaces);
-        }
-
-        addToMethodMap(methodMap, methods());
-    }
-
-    boolean isAssignableTo(ReferenceType type) {
-        ClassTypeImpl superclazz = (ClassTypeImpl)superclass();
-        if (this.equals(type)) {
-            return true;
-        } else if ((superclazz != null) && superclazz.isAssignableTo(type)) {
-            return true;
-        } else {
-            List<InterfaceType> interfaces = interfaces();
-            Iterator<InterfaceType> iter = interfaces.iterator();
-            while (iter.hasNext()) {
-                InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
-                if (interfaze.isAssignableTo(type)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
 
     public String toString() {
        return "class " + name() + " (" + loaderString() + ")";
     }
+
+    @Override
+    CommandSender getInvokeMethodSender(ThreadReferenceImpl thread,
+                                        MethodImpl method,
+                                        ValueImpl[] args,
+                                        int options) {
+        return () ->
+            JDWP.ClassType.InvokeMethod.enqueueCommand(vm,
+                                                       ClassTypeImpl.this,
+                                                       thread,
+                                                       method.ref(),
+                                                       args,
+                                                       options);
+    }
+
+    @Override
+    InvocationResult waitForReply(PacketStream stream) throws JDWPException {
+        return new IResult(JDWP.ClassType.InvokeMethod.waitForReply(vm, stream));
+    }
+
+    @Override
+    boolean canInvoke(Method method) {
+        // Method must be in this class or a superclass.
+        return ((ReferenceTypeImpl)method.declaringType()).isAssignableFrom(this);
+    }
 }
--- a/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java	Thu May 01 14:21:29 2014 -0700
@@ -29,14 +29,31 @@
 
 import java.util.List;
 import java.util.ArrayList;
-import java.util.Map;
-import java.util.Iterator;
 import java.util.Collections;
 import java.util.Set;
 import java.lang.ref.SoftReference;
 
-public class InterfaceTypeImpl extends ReferenceTypeImpl
-                               implements InterfaceType {
+final public class InterfaceTypeImpl extends InvokableTypeImpl
+                                     implements InterfaceType {
+
+    private static class IResult implements InvocationResult {
+        final private JDWP.InterfaceType.InvokeMethod rslt;
+
+        public IResult(JDWP.InterfaceType.InvokeMethod rslt) {
+            this.rslt = rslt;
+        }
+
+        @Override
+        public ObjectReferenceImpl getException() {
+            return rslt.exception;
+        }
+
+        @Override
+        public ValueImpl getResult() {
+            return rslt.returnValue;
+        }
+
+    }
 
     private SoftReference<List<InterfaceType>> superinterfacesRef = null;
 
@@ -81,102 +98,6 @@
         return implementors;
     }
 
-    @Override
-    void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces) {
-        /*
-         * Add methods from
-         * parent types first, so that the methods in this class will
-         * overwrite them in the hash table
-         */
-
-        for (InterfaceType interfaze : superinterfaces()) {
-            if (!seenInterfaces.contains(interfaze)) {
-                ((InterfaceTypeImpl)interfaze).addVisibleMethods(methodMap, seenInterfaces);
-                seenInterfaces.add(interfaze);
-            }
-        }
-
-        addToMethodMap(methodMap, methods());
-    }
-
-    public List<Method> allMethods() {
-        ArrayList<Method> list = new ArrayList<Method>(methods());
-
-        /*
-         * It's more efficient if don't do this
-         * recursively.
-         */
-        for (InterfaceType interfaze : allSuperinterfaces()) {
-            list.addAll(interfaze.methods());
-        }
-
-        return list;
-    }
-
-    List<InterfaceType> allSuperinterfaces() {
-        ArrayList<InterfaceType> list = new ArrayList<InterfaceType>();
-        addSuperinterfaces(list);
-        return list;
-    }
-
-    void addSuperinterfaces(List<InterfaceType> list) {
-        /*
-         * This code is a little strange because it
-         * builds the list with a more suitable order than the
-         * depth-first approach a normal recursive solution would
-         * take. Instead, all direct superinterfaces precede all
-         * indirect ones.
-         */
-
-        /*
-         * Get a list of direct superinterfaces that's not already in the
-         * list being built.
-         */
-        List<InterfaceType> immediate = new ArrayList<InterfaceType>(superinterfaces());
-        Iterator<InterfaceType> iter = immediate.iterator();
-        while (iter.hasNext()) {
-            InterfaceType interfaze = iter.next();
-            if (list.contains(interfaze)) {
-                iter.remove();
-            }
-        }
-
-        /*
-         * Add all new direct superinterfaces
-         */
-        list.addAll(immediate);
-
-        /*
-         * Recurse for all new direct superinterfaces.
-         */
-        iter = immediate.iterator();
-        while (iter.hasNext()) {
-            InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
-            interfaze.addSuperinterfaces(list);
-        }
-    }
-
-    boolean isAssignableTo(ReferenceType type) {
-
-        // Exact match?
-        if (this.equals(type)) {
-            return true;
-        } else {
-            // Try superinterfaces.
-            for (InterfaceType interfaze : superinterfaces()) {
-                if (((InterfaceTypeImpl)interfaze).isAssignableTo(type)) {
-                    return true;
-                }
-            }
-
-            return false;
-        }
-    }
-
-    List<InterfaceType> inheritedTypes() {
-        return superinterfaces();
-    }
-
     public boolean isInitialized() {
         return isPrepared();
     }
@@ -184,4 +105,39 @@
     public String toString() {
        return "interface " + name() + " (" + loaderString() + ")";
     }
-}
+
+    @Override
+    InvocationResult waitForReply(PacketStream stream) throws JDWPException {
+        return new IResult(JDWP.InterfaceType.InvokeMethod.waitForReply(vm, stream));
+    }
+
+    @Override
+    CommandSender getInvokeMethodSender(final ThreadReferenceImpl thread,
+                                        final MethodImpl method,
+                                        final ValueImpl[] args,
+                                        final int options) {
+        return () ->
+            JDWP.InterfaceType.InvokeMethod.enqueueCommand(vm,
+                                                           InterfaceTypeImpl.this,
+                                                           thread,
+                                                           method.ref(),
+                                                           args,
+                                                           options);
+    }
+
+    @Override
+    ClassType superclass() {
+        return null;
+    }
+
+    @Override
+    List<InterfaceType> interfaces() {
+        return superinterfaces();
+    }
+
+    @Override
+    boolean canInvoke(Method method) {
+        // method must be directly in this interface
+        return this.equals(method.declaringType());
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.jdi;
+
+import com.sun.jdi.ClassNotLoadedException;
+import com.sun.jdi.ClassType;
+import com.sun.jdi.IncompatibleThreadStateException;
+import com.sun.jdi.InterfaceType;
+import com.sun.jdi.InvalidTypeException;
+import com.sun.jdi.InvocationException;
+import com.sun.jdi.Method;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.Value;
+import com.sun.jdi.VirtualMachine;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A supertype for ReferenceTypes allowing method invocations
+ */
+abstract class InvokableTypeImpl extends ReferenceTypeImpl {
+    /**
+     * The invocation result wrapper
+     * It is necessary because both ClassType and InterfaceType
+     * use their own type to represent the invocation result
+     */
+    static interface InvocationResult {
+        ObjectReferenceImpl getException();
+        ValueImpl getResult();
+    }
+
+    InvokableTypeImpl(VirtualMachine aVm, long aRef) {
+        super(aVm, aRef);
+    }
+
+    /**
+     * Method invocation support.
+     * Shared by ClassType and InterfaceType
+     * @param threadIntf the thread in which to invoke.
+     * @param methodIntf method the {@link Method} to invoke.
+     * @param origArguments the list of {@link Value} arguments bound to the
+     * invoked method. Values from the list are assigned to arguments
+     * in the order they appear in the method signature.
+     * @param options the integer bit flag options.
+     * @return a {@link Value} mirror of the invoked method's return value.
+     * @throws java.lang.IllegalArgumentException if the method is not
+     * a member of this type, if the size of the argument list
+     * does not match the number of declared arguments for the method, or
+     * if the method is not static or is a static initializer.
+     * @throws {@link InvalidTypeException} if any argument in the
+     * argument list is not assignable to the corresponding method argument
+     * type.
+     * @throws ClassNotLoadedException if any argument type has not yet been loaded
+     * through the appropriate class loader.
+     * @throws IncompatibleThreadStateException if the specified thread has not
+     * been suspended by an event.
+     * @throws InvocationException if the method invocation resulted in
+     * an exception in the target VM.
+     * @throws InvalidTypeException If the arguments do not meet this requirement --
+     *         Object arguments must be assignment compatible with the argument
+     *         type.  This implies that the argument type must be
+     *         loaded through the enclosing class's class loader.
+     *         Primitive arguments must be either assignment compatible with the
+     *         argument type or must be convertible to the argument type without loss
+     *         of information. See JLS section 5.2 for more information on assignment
+     *         compatibility.
+     * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+     */
+    final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf,
+                                    List<? extends Value> origArguments, int options)
+                                        throws InvalidTypeException,
+                                               ClassNotLoadedException,
+                                               IncompatibleThreadStateException,
+                                               InvocationException {
+        validateMirror(threadIntf);
+        validateMirror(methodIntf);
+        validateMirrorsOrNulls(origArguments);
+        MethodImpl method = (MethodImpl) methodIntf;
+        ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf;
+        validateMethodInvocation(method);
+        List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments);
+        ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
+        InvocationResult ret;
+        try {
+            PacketStream stream = sendInvokeCommand(thread, method, args, options);
+            ret = waitForReply(stream);
+        } catch (JDWPException exc) {
+            if (exc.errorCode() == JDWP.Error.INVALID_THREAD) {
+                throw new IncompatibleThreadStateException();
+            } else {
+                throw exc.toJDIException();
+            }
+        }
+        /*
+         * There is an implict VM-wide suspend at the conclusion
+         * of a normal (non-single-threaded) method invoke
+         */
+        if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) {
+            vm.notifySuspend();
+        }
+        if (ret.getException() != null) {
+            throw new InvocationException(ret.getException());
+        } else {
+            return ret.getResult();
+        }
+    }
+
+    @Override
+    boolean isAssignableTo(ReferenceType type) {
+        ClassTypeImpl superclazz = (ClassTypeImpl) superclass();
+        if (this.equals(type)) {
+            return true;
+        } else if ((superclazz != null) && superclazz.isAssignableTo(type)) {
+            return true;
+        } else {
+            List<InterfaceType> interfaces = interfaces();
+            Iterator<InterfaceType> iter = interfaces.iterator();
+            while (iter.hasNext()) {
+                InterfaceTypeImpl interfaze = (InterfaceTypeImpl) iter.next();
+                if (interfaze.isAssignableTo(type)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    @Override
+    final void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces) {
+        /*
+         * Add methods from
+         * parent types first, so that the methods in this class will
+         * overwrite them in the hash table
+         */
+        Iterator<InterfaceType> iter = interfaces().iterator();
+        while (iter.hasNext()) {
+            InterfaceTypeImpl interfaze = (InterfaceTypeImpl) iter.next();
+            if (!seenInterfaces.contains(interfaze)) {
+                interfaze.addVisibleMethods(methodMap, seenInterfaces);
+                seenInterfaces.add(interfaze);
+            }
+        }
+        ClassTypeImpl clazz = (ClassTypeImpl) superclass();
+        if (clazz != null) {
+            clazz.addVisibleMethods(methodMap, seenInterfaces);
+        }
+        addToMethodMap(methodMap, methods());
+    }
+
+    final void addInterfaces(List<InterfaceType> list) {
+        List<InterfaceType> immediate = interfaces();
+        list.addAll(interfaces());
+        Iterator<InterfaceType> iter = immediate.iterator();
+        while (iter.hasNext()) {
+            InterfaceTypeImpl interfaze = (InterfaceTypeImpl) iter.next();
+            interfaze.addInterfaces(list);
+        }
+        ClassTypeImpl superclass = (ClassTypeImpl) superclass();
+        if (superclass != null) {
+            superclass.addInterfaces(list);
+        }
+    }
+
+    /**
+     * Returns all the implemented interfaces recursively
+     * @return A list of all the implemented interfaces (recursively)
+     */
+    final List<InterfaceType> getAllInterfaces() {
+        List<InterfaceType> all = new ArrayList<>();
+        addInterfaces(all);
+        return all;
+    }
+
+    /**
+     * Shared implementation of {@linkplain ClassType#allMethods()} and
+     * {@linkplain InterfaceType#allMethods()}
+     * @return A list of all methods (recursively)
+     */
+    public final List<Method> allMethods() {
+        ArrayList<Method> list = new ArrayList<>(methods());
+        ClassType clazz = superclass();
+        while (clazz != null) {
+            list.addAll(clazz.methods());
+            clazz = clazz.superclass();
+        }
+        /*
+         * Avoid duplicate checking on each method by iterating through
+         * duplicate-free allInterfaces() rather than recursing
+         */
+        for (InterfaceType interfaze : getAllInterfaces()) {
+            list.addAll(interfaze.methods());
+        }
+        return list;
+    }
+
+    @Override
+    final List<ReferenceType> inheritedTypes() {
+        List<ReferenceType> inherited = new ArrayList<>();
+        if (superclass() != null) {
+            inherited.add(0, superclass()); /* insert at front */
+        }
+        for (ReferenceType rt : interfaces()) {
+            inherited.add(rt);
+        }
+        return inherited;
+    }
+
+    private PacketStream sendInvokeCommand(final ThreadReferenceImpl thread,
+                                           final MethodImpl method,
+                                           final ValueImpl[] args,
+                                           final int options) {
+        CommandSender sender = getInvokeMethodSender(thread, method, args, options);
+        PacketStream stream;
+        if ((options & ClassType.INVOKE_SINGLE_THREADED) != 0) {
+            stream = thread.sendResumingCommand(sender);
+        } else {
+            stream = vm.sendResumingCommand(sender);
+        }
+        return stream;
+    }
+
+    private void validateMethodInvocation(Method method)
+                                            throws InvalidTypeException,
+                                                   InvocationException {
+        if (!canInvoke(method)) {
+            throw new IllegalArgumentException("Invalid method");
+        }
+        /*
+         * Method must be a static and not a static initializer
+         */
+        if (!method.isStatic()) {
+            throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type");
+        } else if (method.isStaticInitializer()) {
+            throw new IllegalArgumentException("Cannot invoke static initializer");
+        }
+    }
+
+    /**
+     * A subclass will provide specific {@linkplain CommandSender}
+     * @param thread the current invocation thread
+     * @param method the method to invoke
+     * @param args the arguments to pass to the method
+     * @param options the integer bit flag options
+     * @return the specific {@literal CommandSender} instance
+     */
+    abstract CommandSender getInvokeMethodSender(ThreadReferenceImpl thread,
+                                                 MethodImpl method,
+                                                 ValueImpl[] args,
+                                                 int options);
+
+    /**
+     * Waits for the reply to the last sent command
+     * @param stream the stream to listen for the reply on
+     * @return the {@linkplain InvocationResult} instance
+     * @throws JDWPException when something goes wrong in JDWP
+     */
+    abstract InvocationResult waitForReply(PacketStream stream) throws JDWPException;
+
+    /**
+     * Get the {@linkplain ReferenceType} superclass
+     * @return the superclass or null
+     */
+    abstract ClassType superclass();
+
+    /**
+     * Get the implemented/extended interfaces
+     * @return the list of implemented/extended interfaces
+     */
+    abstract List<InterfaceType> interfaces();
+
+    /**
+     * Checks the provided method whether it can be invoked
+     * @param method the method to check
+     * @return {@code TRUE} if the implementation knows how to invoke the method,
+     *         {@code FALSE} otherwise
+     */
+    abstract boolean canInvoke(Method method);
+}
--- a/src/share/classes/com/sun/tools/jdi/MethodImpl.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/tools/jdi/MethodImpl.java	Thu May 01 14:21:29 2014 -0700
@@ -187,6 +187,13 @@
         return isModifierSet(VMModifiers.ABSTRACT);
     }
 
+    public boolean isDefault() {
+        return !isModifierSet(VMModifiers.ABSTRACT) &&
+               !isModifierSet(VMModifiers.STATIC) &&
+               !isModifierSet(VMModifiers.PRIVATE) &&
+               declaringType() instanceof InterfaceType;
+    }
+
     public boolean isSynchronized() {
         return isModifierSet(VMModifiers.SYNCHRONIZED);
     }
--- a/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java	Thu May 01 14:21:29 2014 -0700
@@ -277,7 +277,6 @@
     void validateMethodInvocation(Method method, int options)
                                          throws InvalidTypeException,
                                          InvocationException {
-
         /*
          * Method must be in this object's class, a superclass, or
          * implemented interface
@@ -287,6 +286,19 @@
             throw new IllegalArgumentException("Invalid method");
         }
 
+        if (declType instanceof ClassTypeImpl) {
+            validateClassMethodInvocation(method, options);
+        } else if (declType instanceof InterfaceTypeImpl) {
+            validateIfaceMethodInvocation(method, options);
+        } else {
+            throw new InvalidTypeException();
+        }
+    }
+
+    void validateClassMethodInvocation(Method method, int options)
+                                         throws InvalidTypeException,
+                                         InvocationException {
+
         ClassTypeImpl clazz = invokableReferenceType(method);
 
         /*
@@ -300,9 +312,7 @@
          * For nonvirtual invokes, method must have a body
          */
         if ((options & INVOKE_NONVIRTUAL) != 0) {
-            if (method.declaringType() instanceof InterfaceType) {
-                throw new IllegalArgumentException("Interface method");
-            } else if (method.isAbstract()) {
+            if (method.isAbstract()) {
                 throw new IllegalArgumentException("Abstract method");
             }
         }
@@ -324,7 +334,7 @@
              */
             Method invoker = clazz.concreteMethodByName(method.name(),
                                                         method.signature());
-            //  isAssignableFrom check above guarantees non-null
+            //  invoker is supposed to be non-null under normal circumstances
             invokedClass = (ClassTypeImpl)invoker.declaringType();
         }
         /* The above code is left over from previous versions.
@@ -332,6 +342,17 @@
          */
     }
 
+    void validateIfaceMethodInvocation(Method method, int options)
+                                         throws InvalidTypeException,
+                                         InvocationException {
+        /*
+         * Only default methods allowed for nonvirtual invokes
+         */
+        if (!method.isDefault()) {
+            throw new IllegalArgumentException("Not a default method");
+        }
+    }
+
     PacketStream sendInvokeCommand(final ThreadReferenceImpl thread,
                                    final ClassTypeImpl refType,
                                    final MethodImpl method,
@@ -370,7 +391,10 @@
         ThreadReferenceImpl thread = (ThreadReferenceImpl)threadIntf;
 
         if (method.isStatic()) {
-            if (referenceType() instanceof ClassType) {
+            if (referenceType() instanceof InterfaceType) {
+                InterfaceType type = (InterfaceType)referenceType();
+                return type.invokeMethod(thread, method, origArguments, options);
+            } else if (referenceType() instanceof ClassType) {
                 ClassType type = (ClassType)referenceType();
                 return type.invokeMethod(thread, method, origArguments, options);
             } else {
--- a/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java	Thu May 01 14:21:29 2014 -0700
@@ -48,7 +48,7 @@
     private ResourceBundle messages = null;
     private int vmSequenceNumber = 0;
     private static final int majorVersion = 1;
-    private static final int minorVersion = 6;
+    private static final int minorVersion = 8;
 
     private static final Object lock = new Object();
     private static VirtualMachineManagerImpl vmm;
--- a/src/share/classes/java/awt/Container.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/awt/Container.java	Thu May 01 14:21:29 2014 -0700
@@ -263,6 +263,16 @@
                     boolean ignoreEnabled) {
                 return cont.findComponentAt(x, y, ignoreEnabled);
             }
+
+            @Override
+            public void startLWModal(Container cont) {
+                cont.startLWModal();
+            }
+
+            @Override
+            public void stopLWModal(Container cont) {
+                cont.stopLWModal();
+            }
         });
     }
 
--- a/src/share/classes/java/awt/datatransfer/Clipboard.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/awt/datatransfer/Clipboard.java	Thu May 01 14:21:29 2014 -0700
@@ -27,14 +27,13 @@
 
 import java.awt.EventQueue;
 
+import java.util.Objects;
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Arrays;
 
 import java.io.IOException;
 
-import sun.awt.EventListenerAggregate;
-
 /**
  * A class that implements a mechanism to transfer data using
  * cut/copy/paste operations.
@@ -68,7 +67,7 @@
      *
      * @since 1.5
      */
-    private EventListenerAggregate flavorListeners;
+    private Set<FlavorListener> flavorListeners;
 
     /**
      * A set of <code>DataFlavor</code>s that is available on
@@ -131,11 +130,7 @@
         this.contents = contents;
 
         if (oldOwner != null && oldOwner != owner) {
-            EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    oldOwner.lostOwnership(Clipboard.this, oldContents);
-                }
-            });
+            EventQueue.invokeLater(() -> oldOwner.lostOwnership(Clipboard.this, oldContents));
         }
         fireFlavorsChanged();
     }
@@ -261,10 +256,12 @@
         if (listener == null) {
             return;
         }
+
         if (flavorListeners == null) {
+            flavorListeners = new HashSet<>();
             currentDataFlavors = getAvailableDataFlavorSet();
-            flavorListeners = new EventListenerAggregate(FlavorListener.class);
         }
+
         flavorListeners.add(listener);
     }
 
@@ -306,7 +303,7 @@
      */
     public synchronized FlavorListener[] getFlavorListeners() {
         return flavorListeners == null ? new FlavorListener[0] :
-                (FlavorListener[])flavorListeners.getListenersCopy();
+            flavorListeners.toArray(new FlavorListener[flavorListeners.size()]);
     }
 
     /**
@@ -320,21 +317,15 @@
         if (flavorListeners == null) {
             return;
         }
+
         Set<DataFlavor> prevDataFlavors = currentDataFlavors;
         currentDataFlavors = getAvailableDataFlavorSet();
-        if (prevDataFlavors.equals(currentDataFlavors)) {
+        if (Objects.equals(prevDataFlavors, currentDataFlavors)) {
             return;
         }
-        FlavorListener[] flavorListenerArray =
-                (FlavorListener[])flavorListeners.getListenersInternal();
-        for (int i = 0; i < flavorListenerArray.length; i++) {
-            final FlavorListener listener = flavorListenerArray[i];
-            EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    listener.flavorsChanged(new FlavorEvent(Clipboard.this));
-                }
-            });
-        }
+        flavorListeners.forEach(listener ->
+                EventQueue.invokeLater(() ->
+                        listener.flavorsChanged(new FlavorEvent(Clipboard.this))));
     }
 
     /**
--- a/src/share/classes/java/awt/datatransfer/DataFlavor.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/awt/datatransfer/DataFlavor.java	Thu May 01 14:21:29 2014 -0700
@@ -25,13 +25,28 @@
 
 package java.awt.datatransfer;
 
-import java.io.*;
-import java.nio.*;
-import java.util.*;
-
 import sun.awt.datatransfer.DataTransferer;
 import sun.reflect.misc.ReflectUtil;
 
+import java.io.ByteArrayInputStream;
+import java.io.CharArrayReader;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.OptionalDataException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Objects;
+
 import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
 
 /**
@@ -92,7 +107,7 @@
  * As such, asking a {@code Transferable} for either {@code DataFlavor} returns
  * the same results.
  * <p>
- * For more information on the using data transfer with Swing see
+ * For more information on using data transfer with Swing see
  * the <a href="http://docs.oracle.com/javase/tutorial/uiswing/dnd/index.html">
  * How to Use Drag and Drop and Data Transfer</a>,
  * section in <em>Java Tutorial</em>.
@@ -390,7 +405,7 @@
      * If the <code>mimeType</code> is
      * "application/x-java-serialized-object; class=&lt;representation class&gt;",
      * the result is the same as calling
-     * <code>new DataFlavor(Class:forName(&lt;representation class&gt;)</code>.
+     * <code>new DataFlavor(Class.forName(&lt;representation class&gt;)</code>.
      * <p>
      * Otherwise:
      * <pre>
@@ -398,7 +413,7 @@
      *     mimeType            = mimeType
      * </pre>
      * @param mimeType the string used to identify the MIME type for this flavor;
-     *                 if the the <code>mimeType</code> does not specify a
+     *                 if the <code>mimeType</code> does not specify a
      *                 "class=" parameter, or if the class is not successfully
      *                 loaded, then an <code>IllegalArgumentException</code>
      *                 is thrown
@@ -433,7 +448,7 @@
      * If the mimeType is
      * "application/x-java-serialized-object; class=&lt;representation class&gt;",
      * the result is the same as calling
-     * <code>new DataFlavor(Class:forName(&lt;representation class&gt;)</code>.
+     * <code>new DataFlavor(Class.forName(&lt;representation class&gt;)</code>.
      * <p>
      * Otherwise:
      * <pre>
@@ -501,7 +516,7 @@
     * @throws ClassNotFoundException
     * @throws  NullPointerException if <code>mimeType</code> is null
     *
-    * @see tryToLoadClass
+    * @see #tryToLoadClass
     */
     private void initialize(String mimeType, String humanPresentableName, ClassLoader classLoader) throws MimeTypeParseException, ClassNotFoundException {
         if (mimeType == null) {
@@ -986,14 +1001,8 @@
             return true;
         }
 
-        if (representationClass == null) {
-            if (that.getRepresentationClass() != null) {
-                return false;
-            }
-        } else {
-            if (!representationClass.equals(that.getRepresentationClass())) {
-                return false;
-            }
+        if (!Objects.equals(this.getRepresentationClass(), that.getRepresentationClass())) {
+            return false;
         }
 
         if (mimeType == null) {
@@ -1006,34 +1015,22 @@
             }
 
             if ("text".equals(getPrimaryType())) {
-                if (DataTransferer.doesSubtypeSupportCharset(this) &&
-                    representationClass != null &&
-                    !(isRepresentationClassReader() ||
-                        String.class.equals(representationClass) ||
-                        isRepresentationClassCharBuffer() ||
-                        char[].class.equals(representationClass)))
-                {
+                if (DataTransferer.doesSubtypeSupportCharset(this)
+                        && representationClass != null
+                        && !isStandardTextRepresentationClass()) {
                     String thisCharset =
-                        DataTransferer.canonicalName(getParameter("charset"));
+                            DataTransferer.canonicalName(this.getParameter("charset"));
                     String thatCharset =
-                        DataTransferer.canonicalName(that.getParameter("charset"));
-                    if (thisCharset == null) {
-                        if (thatCharset != null) {
-                            return false;
-                        }
-                    } else {
-                        if (!thisCharset.equals(thatCharset)) {
-                            return false;
-                        }
+                            DataTransferer.canonicalName(that.getParameter("charset"));
+                    if (!Objects.equals(thisCharset, thatCharset)) {
+                        return false;
                     }
                 }
 
-                if ("html".equals(getSubType()) &&
-                        this.getParameter("document") != null )
-                {
-                   if (!this.getParameter("document").
-                            equals(that.getParameter("document")))
-                    {
+                if ("html".equals(getSubType())) {
+                    String thisDocument = this.getParameter("document");
+                    String thatDocument = that.getParameter("document");
+                    if (!Objects.equals(thisDocument, thatDocument)) {
                         return false;
                     }
                 }
@@ -1090,18 +1087,21 @@
             // MimeType.match which reports a match if one or both of the
             // subTypes is '*', regardless of the other subType.
 
-            if ("text".equals(primaryType) &&
-                DataTransferer.doesSubtypeSupportCharset(this) &&
-                representationClass != null &&
-                !(isRepresentationClassReader() ||
-                  String.class.equals(representationClass) ||
-                  isRepresentationClassCharBuffer() ||
-                  char[].class.equals(representationClass)))
-            {
-                String charset =
-                    DataTransferer.canonicalName(getParameter("charset"));
-                if (charset != null) {
-                    total += charset.hashCode();
+            if ("text".equals(primaryType)) {
+                if (DataTransferer.doesSubtypeSupportCharset(this)
+                        && representationClass != null
+                        && !isStandardTextRepresentationClass()) {
+                    String charset = DataTransferer.canonicalName(getParameter("charset"));
+                    if (charset != null) {
+                        total += charset.hashCode();
+                    }
+                }
+
+                if ("html".equals(getSubType())) {
+                    String document = this.getParameter("document");
+                    if (document != null) {
+                        total += document.hashCode();
+                    }
                 }
             }
         }
@@ -1177,6 +1177,20 @@
         return mimeType.match(mtype);
     }
 
+    /**
+     * Checks if the representation class is one of the standard text
+     * representation classes.
+     *
+     * @return true if the representation class is one of the standard text
+     *              representation classes, otherwise false
+     */
+    private boolean isStandardTextRepresentationClass() {
+        return isRepresentationClassReader()
+                || String.class.equals(representationClass)
+                || isRepresentationClassCharBuffer()
+                || char[].class.equals(representationClass);
+    }
+
    /**
     * Does the <code>DataFlavor</code> represent a serialized object?
     * @return whether or not a serialized object is represented
--- a/src/share/classes/java/awt/dnd/DragSourceContext.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/awt/dnd/DragSourceContext.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -472,7 +472,7 @@
      *               <code>ENTER</code>, <code>OVER</code>,
      *               <code>CHANGED</code>
      */
-
+    @SuppressWarnings("fallthrough")
     protected synchronized void updateCurrentCursor(int sourceAct, int targetAct, int status) {
 
         // if the cursor has been previously set then don't do any defaults
@@ -576,9 +576,9 @@
             throw new InvalidObjectException("Null trigger component");
         }
 
-        int DGRActions = newTrigger.getSourceAsDragGestureRecognizer().getSourceActions()
+        int newSourceActions = f.get("sourceActions", 0)
                 & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
-        if (DGRActions == DnDConstants.ACTION_NONE) {
+        if (newSourceActions == DnDConstants.ACTION_NONE) {
             throw new InvalidObjectException("Invalid source actions");
         }
         int triggerActions = newTrigger.getDragAction();
@@ -591,8 +591,7 @@
 
         cursor = (Cursor)f.get("cursor", null);
         useCustomCursor = f.get("useCustomCursor", false);
-        sourceActions = f.get("sourceActions", 0)
-                & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
+        sourceActions = newSourceActions;
 
         transferable = (Transferable)s.readObject();
         listener = (DragSourceListener)s.readObject();
--- a/src/share/classes/java/awt/geom/Line2D.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/awt/geom/Line2D.java	Thu May 01 14:21:29 2014 -0700
@@ -35,7 +35,7 @@
  * default coordinate system called <i>user space</i> in which the y-axis
  * values increase downward and x-axis values increase to the right.  For
  * more information on the user space coordinate system, see the
- * <a href="http://docs.oracle.com/javase/1.3/docs/guide/2d/spec/j2d-intro.fm2.html#61857">
+ * <a href="{@docRoot}/../technotes/guides/2d/spec/j2d-intro.html">
  * Coordinate Systems</a> section of the Java 2D Programmer's Guide.
  * <p>
  * This class is only the abstract superclass for all objects that
--- a/src/share/classes/java/beans/Introspector.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/beans/Introspector.java	Thu May 01 14:21:29 2014 -0700
@@ -848,7 +848,7 @@
     }
 
     private static boolean isAssignable(Class<?> current, Class<?> candidate) {
-        return current == null ? candidate == null : current.isAssignableFrom(candidate);
+        return ((current == null) || (candidate == null)) ? current == candidate : current.isAssignableFrom(candidate);
     }
 
     private PropertyDescriptor mergePropertyWithIndexedProperty(PropertyDescriptor pd, IndexedPropertyDescriptor ipd) {
--- a/src/share/classes/java/nio/package.html	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/nio/package.html	Thu May 01 14:21:29 2014 -0700
@@ -121,7 +121,7 @@
   available.  </p></li>
 
   <li><p> A byte buffer provides access to its content as either a heterogeneous
-  or homogeneous sequence of <a href="ByteBuffer.html#bin">binary data</i></a>
+  or homogeneous sequence of <a href="ByteBuffer.html#bin"><i>binary data</i></a>
   of any non-boolean primitive type, in either big-endian or little-endian <a
   href="ByteOrder.html">byte order</a>.  </p></li>
 
--- a/src/share/classes/java/sql/package.html	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/sql/package.html	Thu May 01 14:21:29 2014 -0700
@@ -323,10 +323,10 @@
 
 <ul>
   <li><a href="http://docs.oracle.com/javase/tutorial/jdbc/basics/index.html">
-          Lesson:JDBC Basics(The Javaxx Tutorials &gt; JDBC(&#0153;) Database Access)</a>
+          Lesson:JDBC Basics(The Javaxx Tutorials &gt; JDBC&trade; Database Access)</a>
 
  <li><a href="http://www.oracle.com/technetwork/java/index-142838.html">
-          <i>JDBC&#0153;API Tutorial and Reference, Third Edition</i></a>
+          <i>JDBC&trade; API Tutorial and Reference, Third Edition</i></a>
 </ul>
 
 </body>
--- a/src/share/classes/java/util/ArrayList.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/ArrayList.java	Thu May 01 14:21:29 2014 -0700
@@ -30,33 +30,33 @@
 import java.util.function.UnaryOperator;
 
 /**
- * Resizable-array implementation of the <tt>List</tt> interface.  Implements
+ * Resizable-array implementation of the {@code List} interface.  Implements
  * all optional list operations, and permits all elements, including
- * <tt>null</tt>.  In addition to implementing the <tt>List</tt> interface,
+ * {@code null}.  In addition to implementing the {@code List} interface,
  * this class provides methods to manipulate the size of the array that is
  * used internally to store the list.  (This class is roughly equivalent to
- * <tt>Vector</tt>, except that it is unsynchronized.)
+ * {@code Vector}, except that it is unsynchronized.)
  *
- * <p>The <tt>size</tt>, <tt>isEmpty</tt>, <tt>get</tt>, <tt>set</tt>,
- * <tt>iterator</tt>, and <tt>listIterator</tt> operations run in constant
- * time.  The <tt>add</tt> operation runs in <i>amortized constant time</i>,
+ * <p>The {@code size}, {@code isEmpty}, {@code get}, {@code set},
+ * {@code iterator}, and {@code listIterator} operations run in constant
+ * time.  The {@code add} operation runs in <i>amortized constant time</i>,
  * that is, adding n elements requires O(n) time.  All of the other operations
  * run in linear time (roughly speaking).  The constant factor is low compared
- * to that for the <tt>LinkedList</tt> implementation.
+ * to that for the {@code LinkedList} implementation.
  *
- * <p>Each <tt>ArrayList</tt> instance has a <i>capacity</i>.  The capacity is
+ * <p>Each {@code ArrayList} instance has a <i>capacity</i>.  The capacity is
  * the size of the array used to store the elements in the list.  It is always
  * at least as large as the list size.  As elements are added to an ArrayList,
  * its capacity grows automatically.  The details of the growth policy are not
  * specified beyond the fact that adding an element has constant amortized
  * time cost.
  *
- * <p>An application can increase the capacity of an <tt>ArrayList</tt> instance
- * before adding a large number of elements using the <tt>ensureCapacity</tt>
+ * <p>An application can increase the capacity of an {@code ArrayList} instance
+ * before adding a large number of elements using the {@code ensureCapacity}
  * operation.  This may reduce the amount of incremental reallocation.
  *
  * <p><strong>Note that this implementation is not synchronized.</strong>
- * If multiple threads access an <tt>ArrayList</tt> instance concurrently,
+ * If multiple threads access an {@code ArrayList} instance concurrently,
  * and at least one of the threads modifies the list structurally, it
  * <i>must</i> be synchronized externally.  (A structural modification is
  * any operation that adds or deletes one or more elements, or explicitly
@@ -70,9 +70,9 @@
  * unsynchronized access to the list:<pre>
  *   List list = Collections.synchronizedList(new ArrayList(...));</pre>
  *
- * <p><a name="fail-fast">
+ * <p id="fail-fast">
  * The iterators returned by this class's {@link #iterator() iterator} and
- * {@link #listIterator(int) listIterator} methods are <em>fail-fast</em>:</a>
+ * {@link #listIterator(int) listIterator} methods are <em>fail-fast</em>:
  * if the list is structurally modified at any time after the iterator is
  * created, in any way except through the iterator's own
  * {@link ListIterator#remove() remove} or
@@ -94,6 +94,8 @@
  * <a href="{@docRoot}/../technotes/guides/collections/index.html">
  * Java Collections Framework</a>.
  *
+ * @param <E> the type of elements in this list
+ *
  * @author  Josh Bloch
  * @author  Neal Gafter
  * @see     Collection
@@ -119,10 +121,17 @@
     private static final Object[] EMPTY_ELEMENTDATA = {};
 
     /**
+     * Shared empty array instance used for default sized empty instances. We
+     * distinguish this from EMPTY_ELEMENTDATA to know how much to inflate when
+     * first element is added.
+     */
+    private static final Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA = {};
+
+    /**
      * The array buffer into which the elements of the ArrayList are stored.
      * The capacity of the ArrayList is the length of this array buffer. Any
-     * empty ArrayList with elementData == EMPTY_ELEMENTDATA will be expanded to
-     * DEFAULT_CAPACITY when the first element is added.
+     * empty ArrayList with elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA
+     * will be expanded to DEFAULT_CAPACITY when the first element is added.
      */
     transient Object[] elementData; // non-private to simplify nested class access
 
@@ -141,19 +150,21 @@
      *         is negative
      */
     public ArrayList(int initialCapacity) {
-        super();
-        if (initialCapacity < 0)
+        if (initialCapacity > 0) {
+            this.elementData = new Object[initialCapacity];
+        } else if (initialCapacity == 0) {
+            this.elementData = EMPTY_ELEMENTDATA;
+        } else {
             throw new IllegalArgumentException("Illegal Capacity: "+
                                                initialCapacity);
-        this.elementData = new Object[initialCapacity];
+        }
     }
 
     /**
      * Constructs an empty list with an initial capacity of ten.
      */
     public ArrayList() {
-        super();
-        this.elementData = EMPTY_ELEMENTDATA;
+        this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA;
     }
 
     /**
@@ -166,37 +177,43 @@
      */
     public ArrayList(Collection<? extends E> c) {
         elementData = c.toArray();
-        size = elementData.length;
-        // c.toArray might (incorrectly) not return Object[] (see 6260652)
-        if (elementData.getClass() != Object[].class)
-            elementData = Arrays.copyOf(elementData, size, Object[].class);
+        if ((size = elementData.length) != 0) {
+            // c.toArray might (incorrectly) not return Object[] (see 6260652)
+            if (elementData.getClass() != Object[].class)
+                elementData = Arrays.copyOf(elementData, size, Object[].class);
+        } else {
+            // replace with empty array.
+            this.elementData = EMPTY_ELEMENTDATA;
+        }
     }
 
     /**
-     * Trims the capacity of this <tt>ArrayList</tt> instance to be the
+     * Trims the capacity of this {@code ArrayList} instance to be the
      * list's current size.  An application can use this operation to minimize
-     * the storage of an <tt>ArrayList</tt> instance.
+     * the storage of an {@code ArrayList} instance.
      */
     public void trimToSize() {
         modCount++;
         if (size < elementData.length) {
-            elementData = Arrays.copyOf(elementData, size);
+            elementData = (size == 0)
+              ? EMPTY_ELEMENTDATA
+              : Arrays.copyOf(elementData, size);
         }
     }
 
     /**
-     * Increases the capacity of this <tt>ArrayList</tt> instance, if
+     * Increases the capacity of this {@code ArrayList} instance, if
      * necessary, to ensure that it can hold at least the number of elements
      * specified by the minimum capacity argument.
      *
      * @param   minCapacity   the desired minimum capacity
      */
     public void ensureCapacity(int minCapacity) {
-        int minExpand = (elementData != EMPTY_ELEMENTDATA)
-            // any size if real element table
+        int minExpand = (elementData != DEFAULTCAPACITY_EMPTY_ELEMENTDATA)
+            // any size if not default element table
             ? 0
-            // larger than default for empty table. It's already supposed to be
-            // at default size.
+            // larger than default for default empty table. It's already
+            // supposed to be at default size.
             : DEFAULT_CAPACITY;
 
         if (minCapacity > minExpand) {
@@ -205,7 +222,7 @@
     }
 
     private void ensureCapacityInternal(int minCapacity) {
-        if (elementData == EMPTY_ELEMENTDATA) {
+        if (elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA) {
             minCapacity = Math.max(DEFAULT_CAPACITY, minCapacity);
         }
 
@@ -264,22 +281,22 @@
     }
 
     /**
-     * Returns <tt>true</tt> if this list contains no elements.
+     * Returns {@code true} if this list contains no elements.
      *
-     * @return <tt>true</tt> if this list contains no elements
+     * @return {@code true} if this list contains no elements
      */
     public boolean isEmpty() {
         return size == 0;
     }
 
     /**
-     * Returns <tt>true</tt> if this list contains the specified element.
-     * More formally, returns <tt>true</tt> if and only if this list contains
-     * at least one element <tt>e</tt> such that
+     * Returns {@code true} if this list contains the specified element.
+     * More formally, returns {@code true} if and only if this list contains
+     * at least one element {@code e} such that
      * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>.
      *
      * @param o element whose presence in this list is to be tested
-     * @return <tt>true</tt> if this list contains the specified element
+     * @return {@code true} if this list contains the specified element
      */
     public boolean contains(Object o) {
         return indexOf(o) >= 0;
@@ -288,7 +305,7 @@
     /**
      * Returns the index of the first occurrence of the specified element
      * in this list, or -1 if this list does not contain the element.
-     * More formally, returns the lowest index <tt>i</tt> such that
+     * More formally, returns the lowest index {@code i} such that
      * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
      * or -1 if there is no such index.
      */
@@ -308,7 +325,7 @@
     /**
      * Returns the index of the last occurrence of the specified element
      * in this list, or -1 if this list does not contain the element.
-     * More formally, returns the highest index <tt>i</tt> such that
+     * More formally, returns the highest index {@code i} such that
      * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
      * or -1 if there is no such index.
      */
@@ -326,10 +343,10 @@
     }
 
     /**
-     * Returns a shallow copy of this <tt>ArrayList</tt> instance.  (The
+     * Returns a shallow copy of this {@code ArrayList} instance.  (The
      * elements themselves are not copied.)
      *
-     * @return a clone of this <tt>ArrayList</tt> instance
+     * @return a clone of this {@code ArrayList} instance
      */
     public Object clone() {
         try {
@@ -372,7 +389,7 @@
      * <p>If the list fits in the specified array with room to spare
      * (i.e., the array has more elements than the list), the element in
      * the array immediately following the end of the collection is set to
-     * <tt>null</tt>.  (This is useful in determining the length of the
+     * {@code null}.  (This is useful in determining the length of the
      * list <i>only</i> if the caller knows that the list does not contain
      * any null elements.)
      *
@@ -437,7 +454,7 @@
      * Appends the specified element to the end of this list.
      *
      * @param e element to be appended to this list
-     * @return <tt>true</tt> (as specified by {@link Collection#add})
+     * @return {@code true} (as specified by {@link Collection#add})
      */
     public boolean add(E e) {
         ensureCapacityInternal(size + 1);  // Increments modCount!!
@@ -492,14 +509,14 @@
      * Removes the first occurrence of the specified element from this list,
      * if it is present.  If the list does not contain the element, it is
      * unchanged.  More formally, removes the element with the lowest index
-     * <tt>i</tt> such that
+     * {@code i} such that
      * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>
-     * (if such an element exists).  Returns <tt>true</tt> if this list
+     * (if such an element exists).  Returns {@code true} if this list
      * contained the specified element (or equivalently, if this list
      * changed as a result of the call).
      *
      * @param o element to be removed from this list, if present
-     * @return <tt>true</tt> if this list contained the specified element
+     * @return {@code true} if this list contained the specified element
      */
     public boolean remove(Object o) {
         if (o == null) {
@@ -555,7 +572,7 @@
      * list is nonempty.)
      *
      * @param c collection containing elements to be added to this list
-     * @return <tt>true</tt> if this list changed as a result of the call
+     * @return {@code true} if this list changed as a result of the call
      * @throws NullPointerException if the specified collection is null
      */
     public boolean addAll(Collection<? extends E> c) {
@@ -578,7 +595,7 @@
      * @param index index at which to insert the first element from the
      *              specified collection
      * @param c collection containing elements to be added to this list
-     * @return <tt>true</tt> if this list changed as a result of the call
+     * @return {@code true} if this list changed as a result of the call
      * @throws IndexOutOfBoundsException {@inheritDoc}
      * @throws NullPointerException if the specified collection is null
      */
@@ -736,12 +753,12 @@
     }
 
     /**
-     * Save the state of the <tt>ArrayList</tt> instance to a stream (that
+     * Save the state of the {@code ArrayList} instance to a stream (that
      * is, serialize it).
      *
-     * @serialData The length of the array backing the <tt>ArrayList</tt>
+     * @serialData The length of the array backing the {@code ArrayList}
      *             instance is emitted (int), followed by all of its elements
-     *             (each an <tt>Object</tt>) in the proper order.
+     *             (each an {@code Object}) in the proper order.
      */
     private void writeObject(java.io.ObjectOutputStream s)
         throws java.io.IOException{
@@ -763,7 +780,7 @@
     }
 
     /**
-     * Reconstitute the <tt>ArrayList</tt> instance from a stream (that is,
+     * Reconstitute the {@code ArrayList} instance from a stream (that is,
      * deserialize it).
      */
     private void readObject(java.io.ObjectInputStream s)
--- a/src/share/classes/java/util/Arrays.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/Arrays.java	Thu May 01 14:21:29 2014 -0700
@@ -2561,7 +2561,7 @@
      * arrays contain the same number of elements, and all corresponding pairs
      * of elements in the two arrays are equal.  In other words, two arrays
      * are equal if they contain the same elements in the same order.  Also,
-     * two array references are considered equal if both are <tt>null</tt>.<p>
+     * two array references are considered equal if both are <tt>null</tt>.
      *
      * @param a one array to be tested for equality
      * @param a2 the other array to be tested for equality
@@ -2590,7 +2590,7 @@
      * arrays contain the same number of elements, and all corresponding pairs
      * of elements in the two arrays are equal.  In other words, two arrays
      * are equal if they contain the same elements in the same order.  Also,
-     * two array references are considered equal if both are <tt>null</tt>.<p>
+     * two array references are considered equal if both are <tt>null</tt>.
      *
      * @param a one array to be tested for equality
      * @param a2 the other array to be tested for equality
@@ -2619,7 +2619,7 @@
      * arrays contain the same number of elements, and all corresponding pairs
      * of elements in the two arrays are equal.  In other words, two arrays
      * are equal if they contain the same elements in the same order.  Also,
-     * two array references are considered equal if both are <tt>null</tt>.<p>
+     * two array references are considered equal if both are <tt>null</tt>.
      *
      * @param a one array to be tested for equality
      * @param a2 the other array to be tested for equality
@@ -2648,7 +2648,7 @@
      * arrays contain the same number of elements, and all corresponding pairs
      * of elements in the two arrays are equal.  In other words, two arrays
      * are equal if they contain the same elements in the same order.  Also,
-     * two array references are considered equal if both are <tt>null</tt>.<p>
+     * two array references are considered equal if both are <tt>null</tt>.
      *
      * @param a one array to be tested for equality
      * @param a2 the other array to be tested for equality
@@ -2677,7 +2677,7 @@
      * arrays contain the same number of elements, and all corresponding pairs
      * of elements in the two arrays are equal.  In other words, two arrays
      * are equal if they contain the same elements in the same order.  Also,
-     * two array references are considered equal if both are <tt>null</tt>.<p>
+     * two array references are considered equal if both are <tt>null</tt>.
      *
      * @param a one array to be tested for equality
      * @param a2 the other array to be tested for equality
@@ -2706,7 +2706,7 @@
      * arrays contain the same number of elements, and all corresponding pairs
      * of elements in the two arrays are equal.  In other words, two arrays
      * are equal if they contain the same elements in the same order.  Also,
-     * two array references are considered equal if both are <tt>null</tt>.<p>
+     * two array references are considered equal if both are <tt>null</tt>.
      *
      * @param a one array to be tested for equality
      * @param a2 the other array to be tested for equality
@@ -2735,7 +2735,7 @@
      * arrays contain the same number of elements, and all corresponding pairs
      * of elements in the two arrays are equal.  In other words, two arrays
      * are equal if they contain the same elements in the same order.  Also,
-     * two array references are considered equal if both are <tt>null</tt>.<p>
+     * two array references are considered equal if both are <tt>null</tt>.
      *
      * Two doubles <tt>d1</tt> and <tt>d2</tt> are considered equal if:
      * <pre>    <tt>new Double(d1).equals(new Double(d2))</tt></pre>
@@ -2770,7 +2770,7 @@
      * arrays contain the same number of elements, and all corresponding pairs
      * of elements in the two arrays are equal.  In other words, two arrays
      * are equal if they contain the same elements in the same order.  Also,
-     * two array references are considered equal if both are <tt>null</tt>.<p>
+     * two array references are considered equal if both are <tt>null</tt>.
      *
      * Two floats <tt>f1</tt> and <tt>f2</tt> are considered equal if:
      * <pre>    <tt>new Float(f1).equals(new Float(f2))</tt></pre>
@@ -2807,7 +2807,7 @@
      * and <tt>e2</tt> are considered <i>equal</i> if <tt>(e1==null ? e2==null
      * : e1.equals(e2))</tt>.  In other words, the two arrays are equal if
      * they contain the same elements in the same order.  Also, two array
-     * references are considered equal if both are <tt>null</tt>.<p>
+     * references are considered equal if both are <tt>null</tt>.
      *
      * @param a one array to be tested for equality
      * @param a2 the other array to be tested for equality
--- a/src/share/classes/java/util/Locale.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/Locale.java	Thu May 01 14:21:29 2014 -0700
@@ -951,7 +951,6 @@
      * functionality, this method should only be used if the caller is
      * prepared to reinitialize locale-sensitive code running within the
      * same Java Virtual Machine.
-     * <p>
      *
      * @param category - the specified category to set the default locale
      * @param newLocale - the new default locale
--- a/src/share/classes/java/util/Properties.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/Properties.java	Thu May 01 14:21:29 2014 -0700
@@ -754,7 +754,6 @@
      * <p>
      * After the entries have been written, the output stream is flushed.
      * The output stream remains open after this method returns.
-     * <p>
      *
      * @param   writer      an output character stream writer.
      * @param   comments   a description of the property list.
@@ -802,7 +801,7 @@
      * <p>
      * After the entries have been written, the output stream is flushed.
      * The output stream remains open after this method returns.
-     * <p>
+     *
      * @param   out      an output stream.
      * @param   comments   a description of the property list.
      * @exception  IOException if writing this property list to the specified
--- a/src/share/classes/java/util/PropertyPermission.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/PropertyPermission.java	Thu May 01 14:21:29 2014 -0700
@@ -193,7 +193,7 @@
     /**
      * Checks two PropertyPermission objects for equality. Checks that <i>obj</i> is
      * a PropertyPermission, and has the same name and actions as this object.
-     * <P>
+     *
      * @param obj the object we are testing for equality with this object.
      * @return true if obj is a PropertyPermission, and has the same name and
      * actions as this PropertyPermission object.
@@ -369,7 +369,6 @@
     /**
      * Returns a new PermissionCollection object for storing
      * PropertyPermission objects.
-     * <p>
      *
      * @return a new PermissionCollection object suitable for storing
      * PropertyPermissions.
--- a/src/share/classes/java/util/Vector.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/Vector.java	Thu May 01 14:21:29 2014 -0700
@@ -45,9 +45,9 @@
  * capacity of a vector before inserting a large number of
  * components; this reduces the amount of incremental reallocation.
  *
- * <p><a name="fail-fast">
+ * <p id="fail-fast">
  * The iterators returned by this class's {@link #iterator() iterator} and
- * {@link #listIterator(int) listIterator} methods are <em>fail-fast</em></a>:
+ * {@link #listIterator(int) listIterator} methods are <em>fail-fast</em>:
  * if the vector is structurally modified at any time after the iterator is
  * created, in any way except through the iterator's own
  * {@link ListIterator#remove() remove} or
--- a/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java	Thu May 01 14:21:29 2014 -0700
@@ -80,7 +80,6 @@
  * {@link ReadLock#tryLock()} and {@link WriteLock#tryLock()} methods
  * do not honor this fair setting and will immediately acquire the lock
  * if it is possible, regardless of waiting threads.)
- * <p>
  * </dl>
  *
  * <li><b>Reentrancy</b>
--- a/src/share/classes/java/util/jar/Pack200.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/jar/Pack200.java	Thu May 01 14:21:29 2014 -0700
@@ -224,7 +224,7 @@
      * Note: Unless otherwise noted, passing a <tt>null</tt> argument to a
      * constructor or method in this class will cause a {@link NullPointerException}
      * to be thrown.
-     * <p>
+     *
      * @since 1.5
      */
     public interface Packer {
--- a/src/share/classes/java/util/jar/package.html	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/jar/package.html	Thu May 01 14:21:29 2014 -0700
@@ -43,8 +43,7 @@
       file format. See 
       <a href="../zip/package-summary.html#package_description">java.util.zip
       package description.</a> <p>
-      In JAR files, all file names must be encoded in the UTF-8 encoding. 
-<p>
+      In JAR files, all file names must be encoded in the UTF-8 encoding.
   <li><a href="../../../../technotes/guides/jar/jar.html">
       Manifest and Signature Specification</a> - The manifest format specification.
 </ul>
--- a/src/share/classes/java/util/logging/ConsoleHandler.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/ConsoleHandler.java	Thu May 01 14:21:29 2014 -0700
@@ -62,7 +62,7 @@
  * <li>   com.foo.MyHandler.level=INFO </li>
  * <li>   com.foo.MyHandler.formatter=java.util.logging.SimpleFormatter </li>
  * </ul>
- * <p>
+ *
  * @since 1.4
  */
 public class ConsoleHandler extends StreamHandler {
@@ -86,7 +86,7 @@
      * <p>
      * The logging request was made initially to a <tt>Logger</tt> object,
      * which initialized the <tt>LogRecord</tt> and forwarded it here.
-     * <p>
+     *
      * @param  record  description of the log event. A null record is
      *                 silently ignored and is not published
      */
--- a/src/share/classes/java/util/logging/FileHandler.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/FileHandler.java	Thu May 01 14:21:29 2014 -0700
@@ -243,7 +243,7 @@
     /**
      * Construct a default <tt>FileHandler</tt>.  This will be configured
      * entirely from <tt>LogManager</tt> properties (or their default values).
-     * <p>
+     *
      * @exception  IOException if there are IO problems opening the files.
      * @exception  SecurityException  if a security manager exists and if
      *             the caller does not have <tt>LoggingPermission("control"))</tt>.
--- a/src/share/classes/java/util/logging/Formatter.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/Formatter.java	Thu May 01 14:21:29 2014 -0700
@@ -105,7 +105,6 @@
      *     java.text.MessageFormat  is used to format the string.
      * <li>Otherwise no formatting is performed.
      * </ul>
-     * <p>
      *
      * @param  record  the log record containing the raw message
      * @return   a localized and formatted message
--- a/src/share/classes/java/util/logging/Handler.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/Handler.java	Thu May 01 14:21:29 2014 -0700
@@ -158,7 +158,7 @@
      * <p>
      * Some <tt>Handlers</tt> may not use <tt>Formatters</tt>, in
      * which case the <tt>Formatter</tt> will be remembered, but not used.
-     * <p>
+     *
      * @param newFormatter the <tt>Formatter</tt> to use (may not be null)
      * @exception  SecurityException  if a security manager exists and if
      *             the caller does not have <tt>LoggingPermission("control")</tt>.
@@ -329,7 +329,7 @@
      * may make other <tt>Handler</tt> specific checks that might prevent a
      * handler from logging the <tt>LogRecord</tt>. It will return false if
      * the <tt>LogRecord</tt> is null.
-     * <p>
+     *
      * @param record  a <tt>LogRecord</tt>
      * @return true if the <tt>LogRecord</tt> would be logged.
      *
--- a/src/share/classes/java/util/logging/Level.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/Level.java	Thu May 01 14:21:29 2014 -0700
@@ -195,7 +195,7 @@
     /**
      * Create a named Level with a given integer value and a
      * given localization resource name.
-     * <p>
+     *
      * @param name  the name of the Level, for example "SEVERE".
      * @param value an integer value for the level.
      * @param resourceBundleName name of a resource bundle to use in
--- a/src/share/classes/java/util/logging/LogManager.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/LogManager.java	Thu May 01 14:21:29 2014 -0700
@@ -1130,7 +1130,7 @@
      * is no strong reference to the Logger. The caller of this method
      * must check the return value for null in order to properly handle
      * the case where the Logger has been garbage collected.
-     * <p>
+     *
      * @param name name of the logger
      * @return  matching logger or null if none is found
      */
@@ -1151,7 +1151,7 @@
      * return value from {@code LogManager.getLogger()} for null to properly
      * handle the case where the Logger has been garbage collected in the
      * time since its name was returned by this method.
-     * <p>
+     *
      * @return  enumeration of logger name strings
      */
     public Enumeration<String> getLoggerNames() {
--- a/src/share/classes/java/util/logging/Logger.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/Logger.java	Thu May 01 14:21:29 2014 -0700
@@ -338,7 +338,7 @@
      * suitable per-Logger granularity. Developers also need to keep a
      * strong reference to their Logger objects to prevent them from
      * being garbage collected.
-     * <p>
+     *
      * @deprecated Initialization of this field is prone to deadlocks.
      * The field must be initialized by the Logger class initialization
      * which may cause deadlocks with the LogManager class initialization.
@@ -526,7 +526,7 @@
      * name is used.  If the named Logger already exists and has
      * a different resource bundle name then an IllegalArgumentException
      * is thrown.
-     * <p>
+     *
      * @param   name    A name for the logger.  This should
      *                          be a dot-separated name and should normally
      *                          be based on the package name or class name
@@ -595,7 +595,6 @@
      * from the root logger. Changing its parent via the
      * {@link #setParent(java.util.logging.Logger) setParent} method
      * will still require the security permission specified by that method.
-     * <p>
      *
      * @return a newly created private Logger
      */
@@ -621,7 +620,7 @@
      * from the root logger.  Changing its parent via the
      * {@link #setParent(java.util.logging.Logger) setParent} method
      * will still require the security permission specified by that method.
-     * <p>
+     *
      * @param   resourceBundleName  name of ResourceBundle to be used for localizing
      *                          messages for this logger.
      *          May be null if none of the messages require localization.
@@ -776,7 +775,7 @@
      * If the logger is currently enabled for the given message
      * level then the given message is forwarded to all the
      * registered output Handler objects.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   msg     The string message (or a key in the message catalog)
      */
@@ -796,7 +795,7 @@
      * level then the message is constructed by invoking the provided
      * supplier function and forwarded to all the registered output
      * Handler objects.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   msgSupplier   A function, which when called, produces the
      *                        desired log message
@@ -815,7 +814,7 @@
      * If the logger is currently enabled for the given message
      * level then a corresponding LogRecord is created and forwarded
      * to all the registered output Handler objects.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   msg     The string message (or a key in the message catalog)
      * @param   param1  parameter to the message
@@ -836,7 +835,7 @@
      * If the logger is currently enabled for the given message
      * level then a corresponding LogRecord is created and forwarded
      * to all the registered output Handler objects.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   msg     The string message (or a key in the message catalog)
      * @param   params  array of parameters to the message
@@ -861,7 +860,7 @@
      * property, rather than the LogRecord parameters property.  Thus it is
      * processed specially by output Formatters and is not treated
      * as a formatting parameter to the LogRecord message property.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   msg     The string message (or a key in the message catalog)
      * @param   thrown  Throwable associated with log message.
@@ -887,7 +886,7 @@
      * property, rather than the LogRecord parameters property.  Thus it is
      * processed specially by output Formatters and is not treated
      * as a formatting parameter to the LogRecord message property.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   thrown  Throwable associated with log message.
      * @param   msgSupplier   A function, which when called, produces the
@@ -914,7 +913,7 @@
      * If the logger is currently enabled for the given message
      * level then the given message is forwarded to all the
      * registered output Handler objects.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -938,7 +937,7 @@
      * level then the message is constructed by invoking the provided
      * supplier function and forwarded to all the registered output
      * Handler objects.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -964,7 +963,7 @@
      * If the logger is currently enabled for the given message
      * level then a corresponding LogRecord is created and forwarded
      * to all the registered output Handler objects.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -991,7 +990,7 @@
      * If the logger is currently enabled for the given message
      * level then a corresponding LogRecord is created and forwarded
      * to all the registered output Handler objects.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -1022,7 +1021,7 @@
      * property, rather than the LogRecord parameters property.  Thus it is
      * processed specially by output Formatters and is not treated
      * as a formatting parameter to the LogRecord message property.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -1054,7 +1053,7 @@
      * property, rather than the LogRecord parameters property.  Thus it is
      * processed specially by output Formatters and is not treated
      * as a formatting parameter to the LogRecord message property.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -1113,7 +1112,7 @@
      * The msg string is localized using the named resource bundle.  If the
      * resource bundle name is null, or an empty String or invalid
      * then the msg string is not localized.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -1147,7 +1146,7 @@
      * The msg string is localized using the named resource bundle.  If the
      * resource bundle name is null, or an empty String or invalid
      * then the msg string is not localized.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -1184,7 +1183,7 @@
      * The msg string is localized using the named resource bundle.  If the
      * resource bundle name is null, or an empty String or invalid
      * then the msg string is not localized.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -1220,7 +1219,7 @@
      * The {@code msg} string is localized using the given resource bundle.
      * If the resource bundle is {@code null}, then the {@code msg} string is not
      * localized.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    Name of the class that issued the logging request
      * @param   sourceMethod   Name of the method that issued the logging request
@@ -1260,7 +1259,7 @@
      * property, rather than the LogRecord parameters property.  Thus it is
      * processed specially by output Formatters and is not treated
      * as a formatting parameter to the LogRecord message property.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that issued the logging request
@@ -1301,7 +1300,7 @@
      * property, rather than the LogRecord parameters property.  Thus it is
      * processed specially by output Formatters and is not treated
      * as a formatting parameter to the LogRecord message property.
-     * <p>
+     *
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   sourceClass    Name of the class that issued the logging request
      * @param   sourceMethod   Name of the method that issued the logging request
@@ -1333,7 +1332,7 @@
      * This is a convenience method that can be used to log entry
      * to a method.  A LogRecord with message "ENTRY", log level
      * FINER, and the given sourceMethod and sourceClass is logged.
-     * <p>
+     *
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that is being entered
      */
@@ -1348,7 +1347,7 @@
      * to a method.  A LogRecord with message "ENTRY {0}", log level
      * FINER, and the given sourceMethod, sourceClass, and parameter
      * is logged.
-     * <p>
+     *
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that is being entered
      * @param   param1         parameter to the method being entered
@@ -1365,7 +1364,7 @@
      * format {N} indicator for each entry in the parameter array),
      * log level FINER, and the given sourceMethod, sourceClass, and
      * parameters is logged.
-     * <p>
+     *
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of method that is being entered
      * @param   params         array of parameters to the method being entered
@@ -1389,7 +1388,7 @@
      * This is a convenience method that can be used to log returning
      * from a method.  A LogRecord with message "RETURN", log level
      * FINER, and the given sourceMethod and sourceClass is logged.
-     * <p>
+     *
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of the method
      */
@@ -1405,7 +1404,7 @@
      * from a method.  A LogRecord with message "RETURN {0}", log level
      * FINER, and the gives sourceMethod, sourceClass, and result
      * object is logged.
-     * <p>
+     *
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod   name of the method
      * @param   result  Object that is being returned
@@ -1430,7 +1429,7 @@
      * property, rather than the LogRecord parameters property.  Thus it is
      * processed specially by output Formatters and is not treated
      * as a formatting parameter to the LogRecord message property.
-     * <p>
+     *
      * @param   sourceClass    name of class that issued the logging request
      * @param   sourceMethod  name of the method.
      * @param   thrown  The Throwable that is being thrown.
@@ -1456,7 +1455,7 @@
      * If the logger is currently enabled for the SEVERE message
      * level then the given message is forwarded to all the
      * registered output Handler objects.
-     * <p>
+     *
      * @param   msg     The string message (or a key in the message catalog)
      */
     public void severe(String msg) {
@@ -1469,7 +1468,7 @@
      * If the logger is currently enabled for the WARNING message
      * level then the given message is forwarded to all the
      * registered output Handler objects.
-     * <p>
+     *
      * @param   msg     The string message (or a key in the message catalog)
      */
     public void warning(String msg) {
@@ -1482,7 +1481,7 @@
      * If the logger is currently enabled for the INFO message
      * level then the given message is forwarded to all the
      * registered output Handler objects.
-     * <p>
+     *
      * @param   msg     The string message (or a key in the message catalog)
      */
     public void info(String msg) {
@@ -1495,7 +1494,7 @@
      * If the logger is currently enabled for the CONFIG message
      * level then the given message is forwarded to all the
      * registered output Handler objects.
-     * <p>
+     *
      * @param   msg     The string message (or a key in the message catalog)
      */
     public void config(String msg) {
@@ -1508,7 +1507,7 @@
      * If the logger is currently enabled for the FINE message
      * level then the given message is forwarded to all the
      * registered output Handler objects.
-     * <p>
+     *
      * @param   msg     The string message (or a key in the message catalog)
      */
     public void fine(String msg) {
@@ -1521,7 +1520,7 @@
      * If the logger is currently enabled for the FINER message
      * level then the given message is forwarded to all the
      * registered output Handler objects.
-     * <p>
+     *
      * @param   msg     The string message (or a key in the message catalog)
      */
     public void finer(String msg) {
@@ -1534,7 +1533,7 @@
      * If the logger is currently enabled for the FINEST message
      * level then the given message is forwarded to all the
      * registered output Handler objects.
-     * <p>
+     *
      * @param   msg     The string message (or a key in the message catalog)
      */
     public void finest(String msg) {
@@ -1554,7 +1553,7 @@
      * level then the message is constructed by invoking the provided
      * supplier function and forwarded to all the registered output
      * Handler objects.
-     * <p>
+     *
      * @param   msgSupplier   A function, which when called, produces the
      *                        desired log message
      * @since   1.8
@@ -1571,7 +1570,7 @@
      * level then the message is constructed by invoking the provided
      * supplier function and forwarded to all the registered output
      * Handler objects.
-     * <p>
+     *
      * @param   msgSupplier   A function, which when called, produces the
      *                        desired log message
      * @since   1.8
@@ -1588,7 +1587,7 @@
      * level then the message is constructed by invoking the provided
      * supplier function and forwarded to all the registered output
      * Handler objects.
-     * <p>
+     *
      * @param   msgSupplier   A function, which when called, produces the
      *                        desired log message
      * @since   1.8
@@ -1605,7 +1604,7 @@
      * level then the message is constructed by invoking the provided
      * supplier function and forwarded to all the registered output
      * Handler objects.
-     * <p>
+     *
      * @param   msgSupplier   A function, which when called, produces the
      *                        desired log message
      * @since   1.8
@@ -1622,7 +1621,7 @@
      * level then the message is constructed by invoking the provided
      * supplier function and forwarded to all the registered output
      * Handler objects.
-     * <p>
+     *
      * @param   msgSupplier   A function, which when called, produces the
      *                        desired log message
      * @since   1.8
@@ -1639,7 +1638,7 @@
      * level then the message is constructed by invoking the provided
      * supplier function and forwarded to all the registered output
      * Handler objects.
-     * <p>
+     *
      * @param   msgSupplier   A function, which when called, produces the
      *                        desired log message
      * @since   1.8
@@ -1656,7 +1655,7 @@
      * level then the message is constructed by invoking the provided
      * supplier function and forwarded to all the registered output
      * Handler objects.
-     * <p>
+     *
      * @param   msgSupplier   A function, which when called, produces the
      *                        desired log message
      * @since   1.8
@@ -1769,7 +1768,7 @@
 
     /**
      * Get the Handlers associated with this logger.
-     * <p>
+     *
      * @return  an array of all registered Handlers
      */
     public Handler[] getHandlers() {
@@ -2015,7 +2014,7 @@
      * the LogManager to update a Logger when the namespace changes.
      * <p>
      * It should not be called from application code.
-     * <p>
+     *
      * @param  parent   the new parent logger
      * @throws  SecurityException  if a security manager exists and if
      *          the caller does not have LoggingPermission("control").
--- a/src/share/classes/java/util/logging/MemoryHandler.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/MemoryHandler.java	Thu May 01 14:21:29 2014 -0700
@@ -82,7 +82,7 @@
  * <li>   com.foo.MyHandler.level=INFO </li>
  * <li>   com.foo.MyHandler.formatter=java.util.logging.SimpleFormatter </li>
  * </ul>
- * <p>
+ *
  * @since 1.4
  */
 
@@ -267,7 +267,7 @@
      * whether it satisfies any <tt>Filter</tt>.  However it does <b>not</b>
      * check whether the <tt>LogRecord</tt> would result in a "push" of the
      * buffer contents. It will return false if the <tt>LogRecord</tt> is null.
-     * <p>
+     *
      * @param record  a <tt>LogRecord</tt>
      * @return true if the <tt>LogRecord</tt> would be logged.
      *
--- a/src/share/classes/java/util/logging/StreamHandler.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/StreamHandler.java	Thu May 01 14:21:29 2014 -0700
@@ -71,7 +71,7 @@
  * <li>   com.foo.MyHandler.level=INFO </li>
  * <li>   com.foo.MyHandler.formatter=java.util.logging.SimpleFormatter </li>
  * </ul>
- * <p>
+ *
  * @since 1.4
  */
 
@@ -91,7 +91,7 @@
     /**
      * Create a <tt>StreamHandler</tt> with a given <tt>Formatter</tt>
      * and output stream.
-     * <p>
+     *
      * @param out         the target output stream
      * @param formatter   Formatter to be used to format output
      */
@@ -224,7 +224,7 @@
      * This method checks if the <tt>LogRecord</tt> has an appropriate level and
      * whether it satisfies any <tt>Filter</tt>.  It will also return false if
      * no output stream has been assigned yet or the LogRecord is null.
-     * <p>
+     *
      * @param record  a <tt>LogRecord</tt>
      * @return true if the <tt>LogRecord</tt> would be logged.
      *
--- a/src/share/classes/java/util/logging/package.html	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/logging/package.html	Thu May 01 14:21:29 2014 -0700
@@ -54,18 +54,18 @@
          When a problem occurs in the field, it may be necessary to return the captured logging
          information to the original development team for diagnosis. This logging
          information may be extremely detailed and fairly inscrutable. Such information might include
-         detailed tracing on the internal execution of particular subsystems.           
+         detailed tracing on the internal execution of particular subsystems.
 
    <LI> <I>Problem diagnosis by developers</I>. The Logging APIs may also be
            used to help debug an application under development. This may 
            include logging information generated by the target application
-           as well as logging information generated by lower-level libraries.          
+           as well as logging information generated by lower-level libraries.
            Note however that while this use is perfectly reasonable,
            the logging APIs are not intended to replace the normal debugging 
            and profiling tools that may already exist in the development environment. 
 </OL>
 
-</P>
+<p>
 The key elements of this package include:
 <UL>
    <LI> <I>Logger</I>: The main entity on which applications make 
@@ -111,7 +111,7 @@
 log, logp, logrb, severe, throwing, and warning methods)  
 will accept null values 
 for all arguments except for the initial Level argument (if any).
-<p>
+
 <H2>Related Documentation</H2>
 <P>
 For an overview of control flow, 
--- a/src/share/classes/java/util/prefs/PreferenceChangeListener.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/prefs/PreferenceChangeListener.java	Thu May 01 14:21:29 2014 -0700
@@ -39,7 +39,7 @@
     /**
      * This method gets called when a preference is added, removed or when
      * its value is changed.
-     * <p>
+     *
      * @param evt A PreferenceChangeEvent object describing the event source
      *          and the preference that has changed.
      */
--- a/src/share/classes/java/util/regex/Matcher.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/regex/Matcher.java	Thu May 01 14:21:29 2014 -0700
@@ -830,7 +830,7 @@
      *
      * <p> The replacement string may contain references to subsequences
      * captured during the previous match: Each occurrence of
-     * <tt>$</tt><i>g</i><tt></tt> will be replaced by the result of
+     * <tt>$</tt><i>g</i> will be replaced by the result of
      * evaluating {@link #group(int) group}<tt>(</tt><i>g</i><tt>)</tt>.
      * The first number after the <tt>$</tt> is always treated as part of
      * the group reference. Subsequent numbers are incorporated into g if
--- a/src/share/classes/java/util/stream/Collectors.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/stream/Collectors.java	Thu May 01 14:21:29 2014 -0700
@@ -120,17 +120,63 @@
     private Collectors() { }
 
     /**
-     * Returns a merge function, suitable for use in
-     * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or
-     * {@link #toMap(Function, Function, BinaryOperator) toMap()}, which always
-     * throws {@code IllegalStateException}.  This can be used to enforce the
-     * assumption that the elements being collected are distinct.
+     * Construct an {@code IllegalStateException} with appropriate message.
+     *
+     * @param k the duplicate key
+     * @param u 1st value to be accumulated/merged
+     * @param v 2nd value to be accumulated/merged
+     */
+    private static IllegalStateException duplicateKeyException(
+            Object k, Object u, Object v) {
+        return new IllegalStateException(String.format(
+            "Duplicate key %s (attempted merging values %s and %s)",
+            k, u, v));
+    }
+
+    /**
+     * {@code BinaryOperator<Map>} that merges the contents of its right
+     * argument into its left argument, throwing {@code IllegalStateException}
+     * if duplicate keys are encountered.
      *
-     * @param <T> the type of input arguments to the merge function
-     * @return a merge function which always throw {@code IllegalStateException}
+     * @param <K> type of the map keys
+     * @param <V> type of the map values
+     * @param <M> type of the map
+     * @return a merge function for two maps
      */
-    private static <T> BinaryOperator<T> throwingMerger() {
-        return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); };
+    private static <K, V, M extends Map<K,V>>
+    BinaryOperator<M> uniqKeysMapMerger() {
+        return (m1, m2) -> {
+            for (Map.Entry<K,V> e : m2.entrySet()) {
+                K k = e.getKey();
+                V v = Objects.requireNonNull(e.getValue());
+                V u = m1.putIfAbsent(k, v);
+                if (u != null) throw duplicateKeyException(k, u, v);
+            }
+            return m1;
+        };
+    }
+
+    /**
+     * {@code BiConsumer<Map, T>} that accumulates (key, value) pairs
+     * extracted from elements into the map, throwing {@code IllegalStateException}
+     * if duplicate keys are encountered.
+     *
+     * @param keyMapper a function that maps an element into a key
+     * @param valueMapper a function that maps an element into a value
+     * @param <T> type of elements
+     * @param <K> type of map keys
+     * @param <V> type of map values
+     * @return an accumulating consumer
+     */
+    private static <T, K, V>
+    BiConsumer<Map<K, V>, T> uniqKeysMapAccumulator(Function<? super T, ? extends K> keyMapper,
+                                                    Function<? super T, ? extends V> valueMapper) {
+        return (map, element) -> {
+            K k = keyMapper.apply(element);
+            V v = Objects.requireNonNull(valueMapper.apply(element));
+            V u = map.putIfAbsent(k, v);
+            if (u != null) throw duplicateKeyException(k, u, v);
+        };
     }
 
     @SuppressWarnings("unchecked")
@@ -1209,7 +1255,10 @@
     public static <T, K, U>
     Collector<T, ?, Map<K,U>> toMap(Function<? super T, ? extends K> keyMapper,
                                     Function<? super T, ? extends U> valueMapper) {
-        return toMap(keyMapper, valueMapper, throwingMerger(), HashMap::new);
+        return new CollectorImpl<>(HashMap::new,
+                                   uniqKeysMapAccumulator(keyMapper, valueMapper),
+                                   uniqKeysMapMerger(),
+                                   CH_ID);
     }
 
     /**
@@ -1372,7 +1421,10 @@
     public static <T, K, U>
     Collector<T, ?, ConcurrentMap<K,U>> toConcurrentMap(Function<? super T, ? extends K> keyMapper,
                                                         Function<? super T, ? extends U> valueMapper) {
-        return toConcurrentMap(keyMapper, valueMapper, throwingMerger(), ConcurrentHashMap::new);
+        return new CollectorImpl<>(ConcurrentHashMap::new,
+                                   uniqKeysMapAccumulator(keyMapper, valueMapper),
+                                   uniqKeysMapMerger(),
+                                   CH_CONCURRENT_ID);
     }
 
     /**
--- a/src/share/classes/java/util/zip/package.html	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/java/util/zip/package.html	Thu May 01 14:21:29 2014 -0700
@@ -39,45 +39,35 @@
 
 <h2>Package Specification</h2>
 
-</a>
 <ul>
   <li><a href="http://www.info-zip.org/doc/appnote-19970311-iz.zip">
       Info-ZIP Application Note 970311
       </a> - a detailed description of the Info-ZIP format upon which
       the <code>java.util.zip</code> classes are based.
-<p>
-  <a name="zip64">
-  <li>An implementation may optionally support the ZIP64(tm) format extensions
-      defined by the 
+  <li><a name="zip64">An implementation may optionally support the ZIP64(tm) format extensions
+      defined by the </a>
       <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">
       PKWARE ZIP File Format Specification</a>. The ZIP64(tm) format extensions
       are used to overcome the size limitations of the original ZIP format.
-<p>
-  <a name="lang_encoding">
-  <li>APPENDIX D of <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">
+  <li><a name="lang_encoding">APPENDIX D of </a><a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">
       PKWARE ZIP File Format Specification</a> - Language Encoding Flag (EFS) to
       encode ZIP entry filename and comment fields using UTF-8.
-<p>
   <li><a href="http://www.ietf.org/rfc/rfc1950.txt">
       ZLIB Compressed Data Format Specification version 3.3</a>
       &nbsp;
       <a href="http://www.ietf.org/rfc/rfc1950.txt.pdf">(pdf)</a>
       (RFC 1950)
-<p>
   <li><a href="http://www.ietf.org/rfc/rfc1951.txt">
       DEFLATE Compressed Data Format Specification version 1.3</a>
       &nbsp;
       <a href="http://www.ietf.org/rfc/rfc1951.txt.pdf">(pdf)</a>
       (RFC 1951)
-<p>
   <li><a href="http://www.ietf.org/rfc/rfc1952.txt">
       GZIP file format specification version 4.3</a>
       &nbsp;
       <a href="http://www.ietf.org/rfc/rfc1952.txt.pdf">(pdf)</a>
       (RFC 1952)
-<p>
   <li>CRC-32 checksum is described in RFC 1952 (above)
-<p>
   <li>Adler-32 checksum is described in RFC 1950 (above)
 </ul>
 
--- a/src/share/classes/javax/sql/PooledConnection.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/PooledConnection.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,7 +83,6 @@
  * <code>ConnectionPool</code> method <code>addStatementEventListener</code>.
  *  Thus, when an application closes its  <code>PreparedStatement</code>,
  * the underlying prepared statement is recycled rather than being closed.
- * <P>
  *
  * @since 1.4
  */
@@ -154,10 +153,10 @@
          * wish to be notified when  <code>PreparedStatement</code>s created by the
          * connection are closed or are detected to be invalid may use this method
          * to register a <code>StatementEventListener</code> with this <code>PooledConnection</code> object.
-         * <p>
+         *
          * @param listener      an component which implements the <code>StatementEventListener</code>
          *                                      interface that is to be registered with this <code>PooledConnection</code> object
-         * <p>
+         *
          * @since 1.6
          */
         public void addStatementEventListener(StatementEventListener listener);
@@ -166,11 +165,11 @@
          * Removes the specified <code>StatementEventListener</code> from the list of
          * components that will be notified when the driver detects that a
          * <code>PreparedStatement</code> has been closed or is invalid.
-         * <p>
+         *
          * @param listener      the component which implements the
          *                                      <code>StatementEventListener</code> interface that was previously
          *                                      registered with this <code>PooledConnection</code> object
-         * <p>
+         *
          * @since 1.6
          */
         public void removeStatementEventListener(StatementEventListener listener);
--- a/src/share/classes/javax/sql/StatementEvent.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/StatementEvent.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
  * registered with a <code>PooledConnection</code>. This occurs when the driver determines that a
  * <code>PreparedStatement</code> that is associated with the <code>PooledConnection</code> has been closed or the driver determines
  * is invalid.
- * <p>
+ *
  * @since 1.6
  */
 public class StatementEvent extends EventObject {
@@ -50,11 +50,11 @@
          * Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code> and
          * <code>PreparedStatement</code>.  The <code>SQLException</code> contained in the event defaults to
          * null.
-         * <p>
+         *
          * @param con                   The <code>PooledConnection</code> that the closed or invalid
          * <code>PreparedStatement</code>is associated with.
          * @param statement             The <code>PreparedStatement</code> that is being closed or is invalid
-         * <p>
+         *
          * @throws IllegalArgumentException if <code>con</code> is null.
          *
          * @since 1.6
@@ -71,7 +71,7 @@
         /**
          * Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code>,
          * <code>PreparedStatement</code> and <code>SQLException</code>
-         * <p>
+         *
          * @param con                   The <code>PooledConnection</code> that the closed or invalid <code>PreparedStatement</code>
          * is associated with.
          * @param statement             The <code>PreparedStatement</code> that is being closed or is invalid
@@ -79,7 +79,7 @@
          *                                              the application
          *
          * @throws IllegalArgumentException if <code>con</code> is null.
-         * <p>
+         *
          * @since 1.6
          */
         public StatementEvent(PooledConnection con,
@@ -94,9 +94,9 @@
 
         /**
          * Returns the <code>PreparedStatement</code> that is being closed or is invalid
-         * <p>
+         *
          * @return      The <code>PreparedStatement</code> that is being closed or is invalid
-         * <p>
+         *
          * @since 1.6
          */
         public PreparedStatement getStatement() {
@@ -106,9 +106,9 @@
 
         /**
          * Returns the <code>SQLException</code> the driver is about to throw
-         * <p>
+         *
          * @return      The <code>SQLException</code> the driver is about to throw
-         * <p>
+         *
          * @since 1.6
          */
         public SQLException getSQLException() {
--- a/src/share/classes/javax/sql/StatementEventListener.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/StatementEventListener.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@
  * <p>
  * Methods which allow a component to register a StatementEventListener with a
  * <code>PooledConnection</code> have been added to the <code>PooledConnection</code> interface.
- * <p>
+ *
  * @since 1.6
  */
 public interface StatementEventListener  extends java.util.EventListener{
@@ -72,13 +72,13 @@
          * <code>PreparedStatement</code> is invalid. The driver calls this method
          * just before it throws the <code>SQLException</code>,
          * contained in the given event, to the application.
-         * <p>
-         * @param event         an event object describing the source of the event,
-         *                                      the statement that is invalid and the exception the
-         *                                      driver is about to throw.  The source of the event is
-         *                                      the <code>PooledConnection</code> which the invalid <code>PreparedStatement</code>
-         * is associated with.
-         * <p>
+         *
+         * @param event    an event object describing the source of the event,
+         *                 the statement that is invalid and the exception the
+         *                 driver is about to throw.  The source of the event is
+         *                 the <code>PooledConnection</code> which the invalid <code>PreparedStatement</code>
+         *                 is associated with.
+         *
          * @since 1.6
          */
         void statementErrorOccurred(StatementEvent event);
--- a/src/share/classes/javax/sql/package.html	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/package.html	Thu May 01 14:21:29 2014 -0700
@@ -2,7 +2,7 @@
 <html>
 <head>
 <!--
-Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
 This code is free software; you can redistribute it and/or modify it
@@ -36,10 +36,9 @@
 the Java<sup><font size=-2>TM</font></sup> programming language.
 This package supplements the <code>java.sql</code>
 package and, as of the version 1.4 release, is included in the 
-Java Platform, Standard Edition
-(Java SE<sup><font size=-2>TM</sup></font>).
+Java Platform, Standard Edition (Java SE&trade;).
 It remains an essential part of the Java Platform, Enterprise Edition
-(Java EE<sup><font size=-2>TM</sup></font>).
+(Java EE&trade;).
 <P>
 The <code>javax.sql</code> package provides for the following:
 <OL>
@@ -145,7 +144,6 @@
 <code>PreparedStatement</code> is closed or there is an error, the connection 
 pool manager (being a listener)
 gets a notification that includes a <code>StatementEvent</code> object.
-<p>
 
 <H2>Distributed Transactions</H2>
 
@@ -203,14 +201,12 @@
 it rows, or moves its cursor, it also notifies each listener that is registered 
 with it.  The listener reacts by carrying out its implementation of the 
 notification method called on it.
-<P>
   <LI><code>RowSetEvent</code><br>
 As part of its internal notification process, a <code>RowSet</code> object
 creates an instance of <code>RowSetEvent</code> and passes it to the listener.
 The listener can use this <code>RowSetEvent</code> object to find out which rowset
 had the event.
 </UL>
-<P>
 <LI>Metadata 
 <UL>
   <LI><code>RowSetMetaData</code><br>
@@ -226,7 +222,6 @@
 method <code>execute</code>, the <code>RowSet</code> object will contain
 a new set of rows, and its <code>RowSetMetaData</code> object will have been
 internally updated to contain information about the new columns.
-<P>
 </UL>
 <LI>The Reader/Writer Facility<br>
 A <code>RowSet</code> object that implements the <code>RowSetInternal</code>
@@ -248,7 +243,7 @@
 (2) the connection that was passed to it, if any.  A rowset uses the 
 <code>RowSetInternal</code> methods behind the scenes to get access to
 this information.  An application does not normally invoke these methods directly.
-<P>
+
   <LI><code>RowSetReader</code><br>
 A disconnected <code>RowSet</code> object that has implemented the 
 <code>RowSetInternal</code> interface can call on its reader (the 
@@ -269,7 +264,6 @@
 back to the underlying data source.  Implementations may vary widely, but
 generally, a writer will do the following:
 
-<P>
 <UL>
   <LI>Make a connection to the data source 
   <LI>Check to see whether there is a conflict, that is, whether
@@ -291,7 +285,6 @@
 JDBC technology driver that implements the JDBC 4.0 API.
 You must check your driver documentation to be sure that it implements
 the particular features you want to use.
-<P>
 
 <h2>Package Specification</h2>
 
@@ -307,7 +300,7 @@
 
 <ul>
   <li><a href="http://www.oracle.com/technetwork/java/index-142838.html">
-          <i>JDBC&#0153;API Tutorial and Reference, Third Edition</i></a>
+          <i>JDBC&#8482;API Tutorial and Reference, Third Edition</i></a>
 </ul>
 </body>
 </html>
--- a/src/share/classes/javax/sql/rowset/BaseRowSet.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/rowset/BaseRowSet.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,6 @@
  *  <li>Fields for storing stream instances
  *  <li>Constants for indicating the type of a stream
  *  </ul>
- *  <p>
  * </UL>
  *
  * <h3>2.0 Setting Properties</h3>
@@ -981,7 +980,7 @@
      * the specified concurrency. The default concurrency for any <code>RowSet</code>
      * object (connected or disconnected) is <code>ResultSet.CONCUR_UPDATABLE</code>,
      * but this method may be called at any time to change the concurrency.
-     * <P>
+     *
      * @param concurrency one of the following constants:
      *                    <code>ResultSet.CONCUR_READ_ONLY</code> or
      *                    <code>ResultSet.CONCUR_UPDATABLE</code>
@@ -1419,7 +1418,6 @@
      * form a subset of the actual rows returned by the original query. This is
      * an implementation variance determined by the specific <code>SyncProvider</code>
      * object employed by the disconnected <code>RowSet</code> object.
-     * <P>
      *
      * @param rows the number of rows to fetch; <code>0</code> to let the
      *        driver decide what the best fetch size is; must not be less
@@ -1466,7 +1464,7 @@
      * <P>
      * An application can call the method <code>setConcurrency</code> at any time
      * to change a <code>RowSet</code> object's concurrency.
-     * <p>
+     *
      * @return the concurrency type for this <code>RowSet</code>
      *     object, which must be one of the following:
      *     <code>ResultSet.CONCUR_READ_ONLY</code> or
@@ -1737,7 +1735,7 @@
      * <p>
      * NOTE: <code>JdbcRowSet</code> does not require the <code>populate</code> method
      * as it is undefined in this class.
-     * <p>
+     *
      * @param parameterIndex the ordinal number of the placeholder parameter
      *        in this <code>RowSet</code> object's command that is to be set.
      *        The first parameter is 1, the second is 2, and so on; must be
@@ -1867,7 +1865,7 @@
      * <P>
      * NOTE: <code>JdbcRowSet</code> does not require the <code>populate</code> method
      * as it is undefined in this class.
-     * S
+     *
      * @param parameterIndex the ordinal number of the placeholder parameter
      *        in this <code>RowSet</code> object's command that is to be set.
      *        The first parameter is 1, the second is 2, and so on; must be
@@ -1933,7 +1931,7 @@
      * <p>
      * NOTE: <code>JdbcRowSet</code> does not require the <code>populate</code> method
      * as it is undefined in this class.
-     * <p>
+     *
      * @param parameterIndex the ordinal number of the placeholder parameter
      *        in this <code>RowSet</code> object's command that is to be set.
      *        The first parameter is 1, the second is 2, and so on; must be
@@ -3579,7 +3577,7 @@
    * @exception SQLException if a database access error occurs or
    * this method is called on a closed <code>CallableStatement</code>
    * @throws SQLFeatureNotSupportedException  if the JDBC driver does not support this method
-     * @since 1.6
+   * @since 1.6
   */
   public void setAsciiStream(String parameterName, java.io.InputStream x)
           throws SQLException{
@@ -3651,7 +3649,7 @@
   * <code>Reader</code> reads the data till end-of-file is reached. The
   * driver does the necessary conversion from Java character format to
   * the national character set in the database.
-
+  *
   * <P><B>Note:</B> This stream object can either be a standard
   * Java stream object or your own subclass that implements the
   * standard interface.
--- a/src/share/classes/javax/sql/rowset/CachedRowSet.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/rowset/CachedRowSet.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -998,7 +998,6 @@
     * available within the internal <code>RowSet</code> tabular structure by
     * virtue of a key already set either on the <code>RowSet</code> object
     * itself or on the underlying SQL data.
-    * <P>
     *
     * @return a <code>Collection</code> object that contains the values in
     * each row in this <code>CachedRowSet</code> object
--- a/src/share/classes/javax/sql/rowset/JdbcRowSet.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/rowset/JdbcRowSet.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -116,7 +116,6 @@
  * <code>CachedRowSet</code>&trade;
  * reference implementation to account for the different
  * requirements of connected and disconnected <code>RowSet</code> objects.
- * <p>
  *
  * @author Jonathan Bruce
  */
--- a/src/share/classes/javax/sql/rowset/package.html	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/rowset/package.html	Thu May 01 14:21:29 2014 -0700
@@ -5,7 +5,7 @@
   <meta http-equiv="Content-Type"
  content="text/html; charset=iso-8859-1">
 <!--
-Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
 This code is free software; you can redistribute it and/or modify it
@@ -76,7 +76,7 @@
 technology-enabled driver ("JDBC driver"). In addition, a <code>JdbcRowSet</code>
 object provides a fully updatable and scrollable tabular 
 data structure as defined in the JDBC 3.0 specification.
-<p>
+
 <li><a href="CachedRowSet.html">
 <b><code>CachedRowSet</code>&trade;</b></a>
  - A <tt>CachedRowSet</tt> object is a JavaBeans&trade;
@@ -92,7 +92,7 @@
 Further details on this mechanism are discussed in the <a
 href="spi/package-summary.html"><code>javax.sql.rowset.spi</code></a> package
 specification.
-<p>
+
 <li><a href="WebRowSet.html"><b><code>WebRowSet</code></b></a> - A 
 <code>WebRowSet</code> object is an extension of <tt>CachedRowSet</tt>
 that can read and write a <code>RowSet</code> object in a well formed XML format.
@@ -108,7 +108,7 @@
 Schema is defined and published at
 <a href="http://java.sun.com/xml/ns/jdbc/webrowset.xsd">
 <code>http://java.sun.com/xml/ns/jdbc/webrowset.xsd</code></a>.
-<p>   
+
 <li><a href="FilteredRowSet.html"><b><code>FilteredRowSet</code></b></a> - A
 <tt>FilteredRowSet</tt> object provides filtering functionality in a programmatic
 and extensible way. There are many instances when a <tt>RowSet</tt> <code>object</code>
@@ -124,7 +124,7 @@
 considered as bi-directional. No standard filters are defined;
 however, sufficient mechanics are specified to permit any required filter to be
 implemented.
-<p>
+
 <li><a href="JoinRowSet.html"><b><code>JoinRowSet</code></b></a> - The <tt>JoinRowSet</tt>
 interface  describes a mechanism by which relationships can be established between 
 two or more standard <code>RowSet</code> implementations. Any number of <tt>RowSet</tt>
@@ -146,7 +146,7 @@
 should also consult the <i>Implementer's Guide</i> in the <a
 href="spi/package-summary.html">javax.sql.rowset.spi</a> package for guidelines
 on <a href="spi/SyncProvider.html"><code>SyncProvider</code></a> implementations.
-<p>
+
 <ul>
 <li><b>3.1 Constructor</b>
 <p>
@@ -215,11 +215,10 @@
   in addition to providing a set of constants for stream type designation.<br>
               </td>
             </tr>
-                               
-      </tbody>                    
+      </tbody>
     </table>
     </blockquote>
-<p>
+
 <li><b>3.3 Connected RowSet Requirements</b>
 <p>
 The <code>JdbcRowSet</code> describes a <code>RowSet</code> object that <b>must</b> always
@@ -231,7 +230,6 @@
 or a <code>RowSetWriter</code> object. They can safely rely on the JDBC driver to
 supply their needs by virtue of the presence of an underlying updatable and scrollable
 <code>ResultSet</code> implementation.
-<p>
 
 <li>
 <b>3.4 Disconnected RowSet Requirements</b>
@@ -248,7 +246,7 @@
 synchronization is required. A disconnected <code>RowSet</code> object should 
 therefore ensure that no 
 extraneous references remain on the <code>Connection</code> object.
-<p>
+
 <li><b>3.5 Role of RowSetMetaDataImpl</b>
 <p>
 The <code>RowsetMetaDataImpl</code> class is a utility class that provides an implementation of the
@@ -256,7 +254,7 @@
 method implementations for metadata for both connected and disconnected 
 <code>RowSet</code> objects. All implementations are free to use this standard
 implementation but are not required to do so.
-<p>
+
 <li><b>3.6 RowSetWarning Class</b>
 <p>
 The <code>RowSetWarning</code> class provides warnings that can be set
@@ -273,8 +271,6 @@
 be chained on it.  If a warning is returned, <code>getNextWarning</code> can be called
 on it, and so on until there are no more warnings.
 
-
-<P>
 <li><b>3.7 The Joinable Interface</b>
 <P>
 The <code>Joinable</code> interface provides both connected and disconnected 
--- a/src/share/classes/javax/sql/rowset/serial/SQLInputImpl.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/rowset/serial/SQLInputImpl.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -164,7 +164,7 @@
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code>
      * implementation.
-     * <p>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *     if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -182,7 +182,7 @@
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code>
      * implementation.
-     * <p>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *     if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -201,7 +201,7 @@
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code>
      * implementation.
-     * <p>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *     if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -219,7 +219,7 @@
      * This method does not perform type-safe checking to determine if the
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
-     * <P>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *       if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -237,7 +237,7 @@
      * This method does not perform type-safe checking to determine if the
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
-     * <P>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *       if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -255,7 +255,7 @@
      * This method does not perform type-safe checking to determine if the
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
-     * <P>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *       if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -273,7 +273,7 @@
      * This method does not perform type-safe checking to determine if the
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
-     * <P>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *       if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -291,7 +291,7 @@
      * This method does not perform type-safe checking to determine if the
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
-     * <P>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *       if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -309,7 +309,7 @@
      * This method does not perform type-safe checking to determine if the
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
-     * <P>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *       if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -326,7 +326,7 @@
      * This method does not perform type-safe checking to determine if the
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
-     * <P>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *       if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
@@ -343,7 +343,7 @@
      * This method does not perform type-safe checking to determine if the
      * returned type is the expected type; this responsibility is delegated
      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
-     * <P>
+     *
      * @return the next attribute in this <code>SQLInputImpl</code> object;
      *       if the value is <code>SQL NULL</code>, return <code>null</code>
      * @throws SQLException if the read position is located at an invalid
--- a/src/share/classes/javax/sql/rowset/serial/SerialDatalink.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/rowset/serial/SerialDatalink.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -76,7 +76,7 @@
     /**
       * Constructs a new <code>SerialDatalink</code> object from the given
       * <code>java.net.URL</code> object.
-      * <P>
+      *
       * @param url the {@code URL} to create the {@code SerialDataLink} from
       * @throws SerialException if url parameter is a null
       */
--- a/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,6 @@
 
     /**
      * Constructor for <code>SerialJavaObject</code> helper class.
-     * <p>
      *
      * @param obj the Java <code>Object</code> to be serialized
      * @throws SerialException if the object is found not to be serializable
--- a/src/share/classes/javax/sql/rowset/spi/package.html	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/sql/rowset/spi/package.html	Thu May 01 14:21:29 2014 -0700
@@ -1,14 +1,14 @@
 <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
 <html>
 <head>
-                    
+
   <meta http-equiv="Content-Type"
  content="text/html; charset=iso-8859-1">
-                    
+
   <meta name="GENERATOR"
  content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]">
 <!--
-Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
 This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 questions.
 -->
   <title>javax.sql.rowset.spi</title>
-   
+
 </head>
   <body bgcolor="#ffffff">
 
@@ -46,7 +46,7 @@
 it with the <code>SyncFactory</code> singleton. (See the class comment for
 <code>SyncProvider</code> for a full explanation of the registration process and 
 the naming convention to be used.)
-<P>
+
 <h2>Table of Contents</h2>
 <ul>
 <li><a href="#pkgspec">1.0 Package Specification</a>
@@ -57,7 +57,7 @@
 <li><a href="#reldocs">6.0 Related Documentation</a>
 </ul>
 
-<h3><a name="pkgspec">1.0 Package Specification</h3>
+<h3><a name="pkgspec">1.0 Package Specification</a></h3>
 <P>
 The following classes and interfaces make up the <code>javax.sql.rowset.spi</code>
 package:
@@ -155,7 +155,7 @@
            using locks; rather, it checks to see if there is a conflict
            before trying to synchronize the <code>RowSet</code> object and the
            data source. If there is a conflict, it does nothing, meaning that
-		   changes to the <code>RowSet</code> object are not persisted to the data
+           changes to the <code>RowSet</code> object are not persisted to the data
            source.
        <LI><B><tt>RIXMLProvider</tt></B> <BR>
             A synchronization provider that can be used with a
@@ -201,10 +201,8 @@
 synchronization mechanisms.  A vendor can make its implementation available by 
 registering the fully qualified class name with Oracle Corporation at
 <code>jdbc@sun.com</code>. This process is discussed in further detail below. 
-<P>
 
-<a name="arch"><h3>2.0 Service Provider Interface Architecture</h3>
-<ul>
+<h3><a name="arch">2.0 Service Provider Interface Architecture</a></h3>
 <b>2.1 Overview</b>
 <p>
 The Service Provider Interface provides a pluggable mechanism by which
@@ -229,13 +227,13 @@
 properties are set at run time and apply system-wide per invocation of the Java
 application. See the section <a href="#reldocs">"Related Documentation"</a>
 further related information.
-<p>
+
 <li><b>Property Files</b> - Properties specified in a standard property file.
 This can be specified using a System Property or by modifying a standard
 property file located in the platform run-time. The
 reference implementation of this technology includes a standard property
 file than can be edited to add additional <code>SyncProvider</code> objects.
-<p> 
+
 <li><b>JNDI Context</b> - Available providers can be registered on a JNDI
 context. The <tt>SyncFactory</tt> will attempt to load <tt>SyncProvider</tt>
 objects bound to the context and register them with the factory. This
@@ -258,20 +256,19 @@
 <li> If a <code>SyncProvider</code> object is specified and the <code>SyncFactory</code>
 contains <i>no</i> reference to the provider, a <code>SyncFactoryException</code> is 
 thrown.
-<p>
+
 <li> If a <code>SyncProvider</code> object is specified and the <code>SyncFactory</code>
 contains a reference to the provider, the requested provider is supplied.
-<p>
+
 <li> If no <code>SyncProvider</code> object is specified, the reference
 implementation provider <code>RIOptimisticProvider</code> is supplied.
 </ul>
 <p>
 These policies are explored in more detail in the <a href="SyncFactory.html">
 <code>SyncFactory</code></a> class.
-</ul>
 
-<li><a name="impl"><h3>3.0 SyncProvider Implementer's Guide</h3>
-<ul>
+<h3><a name="impl">3.0 SyncProvider Implementer's Guide</a></h3>
+
 <b>3.1 Requirements</b>
 <p>
 A compliant <code>SyncProvider</code> implementation that is fully pluggable
@@ -300,7 +297,7 @@
 underlying data source, overwriting whatever is there. No attempt is made to compare 
 original values with current values to see if there is a conflict. The 
 <code>RIXMLProvider</code> is implemented with this grade.
-<p>
+
 <li><b>GRADE_CHECK_MODIFIED_AT_COMMIT</b> - A low grade of optimistic synchronization.
 A <code>SyncProvider</code> implementation returning this grade
 will check for conflicts in rows that have changed between the last synchronization 
@@ -309,20 +306,20 @@
 object. If there are no conflicts, changes in the <code>RowSet</code> object will be
 written to the data source. If there are conflicts, no changes are written.
 The <code>RIOptimisticProvider</code> implementation uses this grade.
-<p>
+
 <li><b>GRADE_CHECK_ALL_AT_COMMIT</b> - A high grade of optimistic synchronization.
 A <code>SyncProvider</code> implementation   returning this grade
 will check all rows, including rows that have not changed in the disconnected
 <code>RowSet</code> object. In this way, any changes to rows in the underlying
 data source will be reflected in the disconnected <code>RowSet</code> object
 when the synchronization finishes successfully.
-<p>
+
 <li><b>GRADE_LOCK_WHEN_MODIFIED</b> - A pessimistic grade of synchronization.
 <code>SyncProvider</code> implementations returning this grade will lock
 the row in the originating  data source that corresponds to the row being changed
 in the <code>RowSet</code> object to reduce the possibility of other
 processes modifying the same data in the data source.
-<p>
+
 <li><b>GRADE_LOCK_WHEN_LOADED</b> - A higher pessimistic synchronization grade.
 A <code>SyncProvider</code> implementation returning this grade will lock
 the entire view and/or  table affected by the original query used to
@@ -347,13 +344,13 @@
 <li><b>DATASOURCE_NO_LOCK</b> - No locks remain on the originating data source. 
 This is the default lock setting for all <code>SyncProvider</code> implementations 
 unless otherwise directed by a <code>RowSet</code> object.
-<p>
+
 <li><b>DATASOURCE_ROW_LOCK</b> - A lock is placed on the rows that are touched by
 the original SQL query used to populate the <code>RowSet</code> object.
-<p> 
+
 <li><b>DATASOURCE_TABLE_LOCK</b> - A lock is placed on all tables that are touched
 by the query that was used to populate the <code>RowSet</code> object.
-<p>
+
 <li><b>DATASOURCE_DB_LOCK</b>
 A lock is placed on the entire data source that is used by the <code>RowSet</code>
 object.
@@ -369,7 +366,7 @@
 Indicates that a <code>SyncProvider</code> implementation  supports synchronization
 to the table or tables from which the SQL <code>VIEW</code> used to populate  a
 a <code>RowSet</code> object is derived.
-<p>
+
 <li><b>NONUPDATABLE_VIEW_SYNC</b>
 Indicates that a <code>SyncProvider</code> implementation  does <b>not</b> support
 synchronization to the table or tables from which the SQL <code>VIEW</code> 
@@ -381,7 +378,7 @@
 In the example below, the reference <tt>CachedRowSetImpl</tt> implementation
 reconfigures its current <tt>SyncProvider</tt> object by calling the 
 <tt>setSyncProvider</tt> method.<br>
-       
+
 <PRE>
     CachedRowSetImpl crs = new CachedRowSetImpl();
     crs.setSyncProvider("com.foo.bar.HASyncProvider");
@@ -412,7 +409,7 @@
       // No synchronization with the originating data source provided
     break;
     }
-	  
+
     switch (sync.getDataSourcLock() {
       case: SyncProvider.DATASOURCE_DB_LOCK
        // A lock is placed on the entire datasource that is used by the
@@ -439,14 +436,13 @@
     It is also possible using the static utility method in the
 <code>SyncFactory</code> class to determine the list of <code>SyncProvider</code>
 implementations currently registered with the <code>SyncFactory</code>.
-       
+
 <pre>
-	Enumeration e = SyncFactory.getRegisteredProviders();
-</pre>    
+       Enumeration e = SyncFactory.getRegisteredProviders();
+</pre>
 
-</ul>
 
-<h3><a name="resolving">4.0 Resolving Synchronization Conflicts</h3>
+<h3><a name="resolving">4.0 Resolving Synchronization Conflicts</a></h3>
 
 The interface <code>SyncResolver</code> provides a way for an application to
 decide manually what to do when a conflict occurs. When the <code>CachedRowSet</code>
@@ -491,18 +487,18 @@
 <P>
 The comment for the <code>SyncResolver</code> interface has more detail.
 
-<a name="relspec"><h3>5.0 Related Specifications</h3>
+<h3><a name="relspec">5.0 Related Specifications</a></h3>
 <ul>
-<li><a href="http://java.sun.com/products/jndi">JNDI 1.3</a>
+<li><a href="http://docs.oracle.com/javase/jndi/tutorial/index.html">JNDI</a>
 <li><a href="{@docRoot}/../technotes/guides/logging/index.html">Java Logging
 APIs</a>
 </ul>
-<a name="reldocs"><h3>6.0 Related Documentation</h3>
+<h3><a name="reldocs">6.0 Related Documentation</a></h3>
 <ul>
 <li><a href="{@docRoot}/../technotes/tools/index.html#basic">System
 properties</a>
 <li>Resource Files
-<li><a href="http://java.sun.com/tutorial/jdbc">DataSource for JDBC
+<li><a href="http://docs.oracle.com/javase/tutorial/jdbc/">DataSource for JDBC
 Connections</a>
 </ul>
 
--- a/src/share/classes/javax/swing/BufferStrategyPaintManager.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/BufferStrategyPaintManager.java	Thu May 01 14:21:29 2014 -0700
@@ -27,13 +27,10 @@
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.image.*;
-import java.lang.reflect.*;
 import java.lang.ref.WeakReference;
 import java.util.*;
 
 import com.sun.java.swing.SwingUtilities3;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 import sun.awt.AWTAccessor;
 
 import sun.awt.SubRegionShowable;
--- a/src/share/classes/javax/swing/JOptionPane.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/JOptionPane.java	Thu May 01 14:21:29 2014 -0700
@@ -56,6 +56,7 @@
 import javax.swing.event.InternalFrameAdapter;
 import javax.accessibility.*;
 import static javax.swing.ClientPropertyKey.PopupFactory_FORCE_HEAVYWEIGHT_POPUP;
+import sun.awt.AWTAccessor;
 
 /**
  * <code>JOptionPane</code> makes it easy to pop up a standard dialog box that
@@ -1306,17 +1307,7 @@
             }
         }
 
-        // Use reflection to get Container.startLWModal.
-        try {
-            Method method = AccessController.doPrivileged(new ModalPrivilegedAction(
-                    Container.class, "startLWModal"));
-            if (method != null) {
-                method.invoke(dialog, (Object[])null);
-            }
-        } catch (IllegalAccessException ex) {
-        } catch (IllegalArgumentException ex) {
-        } catch (InvocationTargetException ex) {
-        }
+        AWTAccessor.getContainerAccessor().startLWModal(dialog);
 
         if (parentComponent instanceof JInternalFrame) {
             try {
@@ -1451,17 +1442,7 @@
             }
         }
 
-        // Use reflection to get Container.startLWModal.
-        try {
-            Method method = AccessController.doPrivileged(new ModalPrivilegedAction(
-                    Container.class, "startLWModal"));
-            if (method != null) {
-                method.invoke(dialog, (Object[])null);
-            }
-        } catch (IllegalAccessException ex) {
-        } catch (IllegalArgumentException ex) {
-        } catch (InvocationTargetException ex) {
-        }
+        AWTAccessor.getContainerAccessor().startLWModal(dialog);
 
         if (parentComponent instanceof JInternalFrame) {
             try {
@@ -1535,18 +1516,7 @@
                 if (iFrame.isVisible() &&
                         event.getSource() == JOptionPane.this &&
                         event.getPropertyName().equals(VALUE_PROPERTY)) {
-                // Use reflection to get Container.stopLWModal().
-                try {
-                    Method method = AccessController.doPrivileged(
-                        new ModalPrivilegedAction(
-                            Container.class, "stopLWModal"));
-                    if (method != null) {
-                        method.invoke(iFrame, (Object[])null);
-                    }
-                } catch (IllegalAccessException ex) {
-                } catch (IllegalArgumentException ex) {
-                } catch (InvocationTargetException ex) {
-                }
+                    AWTAccessor.getContainerAccessor().stopLWModal(iFrame);
 
                 try {
                     iFrame.setClosed(true);
@@ -2512,33 +2482,6 @@
         ",wantsInput=" + wantsInputString;
     }
 
-    /**
-     * Retrieves a method from the provided class and makes it accessible.
-     */
-    private static class ModalPrivilegedAction implements PrivilegedAction<Method> {
-        private Class<?> clazz;
-        private String methodName;
-
-        public ModalPrivilegedAction(Class<?> clazz, String methodName) {
-            this.clazz = clazz;
-            this.methodName = methodName;
-        }
-
-        public Method run() {
-            Method method = null;
-            try {
-                method = clazz.getDeclaredMethod(methodName, (Class[])null);
-            } catch (NoSuchMethodException ex) {
-            }
-            if (method != null) {
-                method.setAccessible(true);
-            }
-            return method;
-        }
-    }
-
-
-
 ///////////////////
 // Accessibility support
 ///////////////////
--- a/src/share/classes/javax/swing/JTable.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/JTable.java	Thu May 01 14:21:29 2014 -0700
@@ -34,7 +34,6 @@
 
 import java.beans.*;
 
-import java.io.Serializable;
 import java.io.ObjectOutputStream;
 import java.io.ObjectInputStream;
 import java.io.IOException;
@@ -4043,7 +4042,7 @@
                 }
                 // Restore the lead
                 int viewLeadIndex = modelSelection.getLeadSelectionIndex();
-                if (viewLeadIndex != -1) {
+                if (viewLeadIndex != -1 && !modelSelection.isSelectionEmpty()) {
                     viewLeadIndex = convertRowIndexToView(viewLeadIndex);
                 }
                 SwingUtilities2.setLeadAnchorWithoutSelection(
@@ -5307,14 +5306,6 @@
         return retValue;
     }
 
-    private void setLazyValue(Hashtable h, Class c, LazyClass lazyClass) {
-        h.put(c, new TableLazyValue(lazyClass));
-    }
-
-    private void setLazyRenderer(Class c, LazyClass lazyClass) {
-        setLazyValue(defaultRenderersByColumnClass, c, lazyClass);
-    }
-
     /**
      * Creates default cell renderers for objects, numbers, doubles, dates,
      * booleans, and icons.
@@ -5325,24 +5316,32 @@
         defaultRenderersByColumnClass = new UIDefaults(8, 0.75f);
 
         // Objects
-        setLazyRenderer(Object.class, LazyClass.UIResource);
+        defaultRenderersByColumnClass.put(Object.class, (UIDefaults.LazyValue)
+                t -> new DefaultTableCellRenderer.UIResource());
 
         // Numbers
-        setLazyRenderer(Number.class, LazyClass.NumberRenderer);
+        defaultRenderersByColumnClass.put(Number.class, (UIDefaults.LazyValue)
+                t -> new NumberRenderer());
 
         // Doubles and Floats
-        setLazyRenderer(Float.class, LazyClass.DoubleRenderer);
-        setLazyRenderer(Double.class, LazyClass.DoubleRenderer);
+        defaultRenderersByColumnClass.put(Float.class, (UIDefaults.LazyValue)
+                t -> new DoubleRenderer());
+        defaultRenderersByColumnClass.put(Double.class, (UIDefaults.LazyValue)
+                t -> new DoubleRenderer());
 
         // Dates
-        setLazyRenderer(Date.class, LazyClass.DateRenderer);
+        defaultRenderersByColumnClass.put(Date.class, (UIDefaults.LazyValue)
+                t -> new DateRenderer());
 
         // Icons and ImageIcons
-        setLazyRenderer(Icon.class, LazyClass.IconRenderer);
-        setLazyRenderer(ImageIcon.class, LazyClass.IconRenderer);
+        defaultRenderersByColumnClass.put(Icon.class, (UIDefaults.LazyValue)
+                t -> new IconRenderer());
+        defaultRenderersByColumnClass.put(ImageIcon.class, (UIDefaults.LazyValue)
+                t -> new IconRenderer());
 
         // Booleans
-        setLazyRenderer(Boolean.class, LazyClass.BooleanRenderer);
+        defaultRenderersByColumnClass.put(Boolean.class, (UIDefaults.LazyValue)
+                t -> new BooleanRenderer());
     }
 
     /**
@@ -5420,10 +5419,6 @@
         }
     }
 
-    private void setLazyEditor(Class c, LazyClass lazyClass) {
-        setLazyValue(defaultEditorsByColumnClass, c, lazyClass);
-    }
-
     /**
      * Creates default cell editors for objects, numbers, and boolean values.
      * @see DefaultCellEditor
@@ -5432,13 +5427,16 @@
         defaultEditorsByColumnClass = new UIDefaults(3, 0.75f);
 
         // Objects
-        setLazyEditor(Object.class, LazyClass.GenericEditor);
+        defaultEditorsByColumnClass.put(Object.class, (UIDefaults.LazyValue)
+                t -> new GenericEditor());
 
         // Numbers
-        setLazyEditor(Number.class, LazyClass.NumberEditor);
+        defaultEditorsByColumnClass.put(Number.class, (UIDefaults.LazyValue)
+                t -> new NumberEditor());
 
         // Booleans
-        setLazyEditor(Boolean.class, LazyClass.BooleanEditor);
+        defaultEditorsByColumnClass.put(Boolean.class, (UIDefaults.LazyValue)
+                t -> new BooleanEditor());
     }
 
     /**
@@ -6544,54 +6542,6 @@
         }
     }
 
-    private enum LazyClass {
-
-        UIResource,
-        NumberRenderer,
-        DoubleRenderer,
-        DateRenderer,
-        IconRenderer,
-        BooleanRenderer,
-        GenericEditor,
-        NumberEditor,
-        BooleanEditor,
-    }
-
-    private static class TableLazyValue implements UIDefaults.LazyValue {
-
-        private LazyClass type;
-
-        public TableLazyValue(LazyClass type) {
-            this.type = type;
-        }
-
-        @Override
-        public Object createValue(UIDefaults table) {
-            switch (type) {
-                case UIResource:
-                    return new DefaultTableCellRenderer.UIResource();
-                case NumberRenderer:
-                    return new NumberRenderer();
-                case DoubleRenderer:
-                    return new DoubleRenderer();
-                case DateRenderer:
-                    return new DateRenderer();
-                case IconRenderer:
-                    return new IconRenderer();
-                case BooleanRenderer:
-                    return new BooleanRenderer();
-                case GenericEditor:
-                    return new GenericEditor();
-                case NumberEditor:
-                    return new NumberEditor();
-                case BooleanEditor:
-                    return new BooleanEditor();
-                default:
-                    return null;
-            }
-        }
-    }
-
 /////////////////
 // Accessibility support
 ////////////////
@@ -6636,8 +6586,8 @@
     TableColumnModelListener, CellEditorListener, PropertyChangeListener,
     AccessibleExtendedTable {
 
-        int lastSelectedRow;
-        int lastSelectedCol;
+        int previousFocusedRow;
+        int previousFocusedCol;
 
         /**
          * AccessibleJTable constructor
@@ -6652,8 +6602,10 @@
             tcm.addColumnModelListener(this);
             tcm.getSelectionModel().addListSelectionListener(this);
             JTable.this.getModel().addTableModelListener(this);
-            lastSelectedRow = JTable.this.getSelectedRow();
-            lastSelectedCol = JTable.this.getSelectedColumn();
+            previousFocusedRow = JTable.this.getSelectionModel().
+                                        getLeadSelectionIndex();
+            previousFocusedCol = JTable.this.getColumnModel().
+                                        getSelectionModel().getLeadSelectionIndex();
         }
 
     // Listeners to track model, etc. changes to as to re-place the other
@@ -6979,20 +6931,23 @@
          */
         public void valueChanged(ListSelectionEvent e) {
             firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
-                               Boolean.valueOf(false), Boolean.valueOf(true));
-
-            int selectedRow = JTable.this.getSelectedRow();
-            int selectedCol = JTable.this.getSelectedColumn();
-            if (selectedRow != lastSelectedRow ||
-                selectedCol != lastSelectedCol) {
-                Accessible oldA = getAccessibleAt(lastSelectedRow,
-                                                  lastSelectedCol);
-                Accessible newA = getAccessibleAt(selectedRow, selectedCol);
+                            Boolean.valueOf(false), Boolean.valueOf(true));
+
+            // Using lead selection index to cover both cases: node selected and node
+            // is focused but not selected (Ctrl+up/down)
+            int focusedRow = JTable.this.getSelectionModel().getLeadSelectionIndex();
+            int focusedCol = JTable.this.getColumnModel().getSelectionModel().
+                                                    getLeadSelectionIndex();
+
+            if (focusedRow != previousFocusedRow ||
+                focusedCol != previousFocusedCol) {
+                Accessible oldA = getAccessibleAt(previousFocusedRow, previousFocusedCol);
+                Accessible newA = getAccessibleAt(focusedRow, focusedCol);
                 firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
-                                   oldA, newA);
-                 lastSelectedRow = selectedRow;
-                 lastSelectedCol = selectedCol;
-             }
+                                    oldA, newA);
+                previousFocusedRow = focusedRow;
+                previousFocusedCol = focusedCol;
+            }
         }
 
 
--- a/src/share/classes/javax/swing/JTree.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/JTree.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1664,6 +1664,14 @@
 
         leadPath = newPath;
         firePropertyChange(LEAD_SELECTION_PATH_PROPERTY, oldValue, newPath);
+
+        // Fire the active descendant property change here since the
+        // leadPath got set, this is triggered both in case node
+        // selection changed and node focus changed
+        if (accessibleContext != null){
+            ((AccessibleJTree)accessibleContext).
+                fireActiveDescendantPropertyChange(oldValue, newPath);
+        }
     }
 
     /**
@@ -4129,26 +4137,9 @@
          *
          */
         public void valueChanged(TreeSelectionEvent e) {
-            // Fixes 4546503 - JTree is sending incorrect active
-            // descendant events
-            TreePath oldLeadSelectionPath = e.getOldLeadSelectionPath();
-            leadSelectionPath = e.getNewLeadSelectionPath();
-
-            if (oldLeadSelectionPath != leadSelectionPath) {
-                // Set parent to null so AccessibleJTreeNode computes
-                // its parent.
-                Accessible oldLSA = leadSelectionAccessible;
-                leadSelectionAccessible = (leadSelectionPath != null)
-                        ? new AccessibleJTreeNode(JTree.this,
-                                                  leadSelectionPath,
-                                                  null) // parent
-                        : null;
-                firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
-                                   oldLSA, leadSelectionAccessible);
-            }
-            firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
-                               Boolean.valueOf(false), Boolean.valueOf(true));
-        }
+             firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
+                                Boolean.valueOf(false), Boolean.valueOf(true));
+         }
 
         /**
          * Fire a visible data property change notification.
@@ -4249,6 +4240,34 @@
             }
         }
 
+        /**
+        *  Fire an active descendant property change notification.
+        *  The active descendant is used for objects such as list,
+        *  tree, and table, which may have transient children.
+        *  It notifies screen readers the active child of the component
+        *  has been changed so user can be notified from there.
+        *
+        * @param oldPath - lead path of previous active child
+        * @param newPath - lead path of current active child
+        *
+        */
+        void fireActiveDescendantPropertyChange(TreePath oldPath, TreePath newPath){
+            if(oldPath != newPath){
+                Accessible oldLSA = (oldPath != null)
+                                    ? new AccessibleJTreeNode(JTree.this,
+                                                              oldPath,
+                                                              null)
+                                    : null;
+
+                Accessible newLSA = (newPath != null)
+                                    ? new AccessibleJTreeNode(JTree.this,
+                                                              newPath,
+                                                              null)
+                                    : null;
+                firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
+                                                                oldLSA, newLSA);
+            }
+        }
 
         private AccessibleContext getCurrentAccessibleContext() {
             Component c = getCurrentComponent();
--- a/src/share/classes/javax/swing/plaf/ComponentUI.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/plaf/ComponentUI.java	Thu May 01 14:21:29 2014 -0700
@@ -297,7 +297,7 @@
     }
 
     /**
-     * Returns an enum indicating how the baseline of he component
+     * Returns an enum indicating how the baseline of the component
      * changes as the size changes.  This method is primarily meant for
      * layout managers and GUI builders.
      * <p>
--- a/src/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,10 @@
 import javax.swing.event.*;
 import javax.swing.plaf.*;
 
+import static sun.swing.SwingUtilities2.drawHLine;
+import static sun.swing.SwingUtilities2.drawRect;
+import static sun.swing.SwingUtilities2.drawVLine;
+
 
 /**
  * Implementation of ScrollBarUI for the Basic Look and Feel
@@ -572,17 +576,17 @@
         g.translate(thumbBounds.x, thumbBounds.y);
 
         g.setColor(thumbDarkShadowColor);
-        g.drawRect(0, 0, w-1, h-1);
+        drawRect(g, 0, 0, w - 1, h - 1);
         g.setColor(thumbColor);
-        g.fillRect(0, 0, w-1, h-1);
+        g.fillRect(0, 0, w - 1, h - 1);
 
         g.setColor(thumbHighlightColor);
-        g.drawLine(1, 1, 1, h-2);
-        g.drawLine(2, 1, w-3, 1);
+        drawVLine(g, 1, 1, h - 2);
+        drawHLine(g, 2, w - 3, 1);
 
         g.setColor(thumbLightShadowColor);
-        g.drawLine(2, h-2, w-2, h-2);
-        g.drawLine(w-2, 1, w-2, h-3);
+        drawHLine(g, 2, w - 2, h - 2);
+        drawVLine(g, w - 2, 1, h - 3);
 
         g.translate(-thumbBounds.x, -thumbBounds.y);
     }
--- a/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Thu May 01 14:21:29 2014 -0700
@@ -34,13 +34,10 @@
 import javax.swing.text.DefaultEditorKit;
 
 import java.awt.Color;
-import java.awt.event.KeyEvent;
-import java.lang.reflect.*;
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.WeakReference;
 
 import java.security.AccessController;
-import java.security.PrivilegedAction;
 
 import sun.awt.*;
 import sun.security.action.GetPropertyAction;
@@ -460,11 +457,9 @@
         LazyValue textFieldBorder =
             t -> MetalBorders.getTextFieldBorder();
 
-        Object dialogBorder = new MetalLazyValue(
-                          "javax.swing.plaf.metal.MetalBorders$DialogBorder");
+        LazyValue dialogBorder = t -> new MetalBorders.DialogBorder();
 
-        Object questionDialogBorder = new MetalLazyValue(
-                  "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
+        LazyValue questionDialogBorder = t -> new MetalBorders.QuestionDialogBorder();
 
         Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
                            "ctrl C", DefaultEditorKit.copyAction,
@@ -1470,12 +1465,8 @@
             "ToolBar.floatingBackground", menuBackground,
             "ToolBar.dockingForeground", primaryControlDarkShadow,
             "ToolBar.floatingForeground", primaryControl,
-            "ToolBar.rolloverBorder", new MetalLazyValue(
-                         "javax.swing.plaf.metal.MetalBorders",
-                         "getToolBarRolloverBorder"),
-            "ToolBar.nonrolloverBorder", new MetalLazyValue(
-                         "javax.swing.plaf.metal.MetalBorders",
-                         "getToolBarNonrolloverBorder"),
+            "ToolBar.rolloverBorder", (LazyValue) t -> MetalBorders.getToolBarRolloverBorder(),
+            "ToolBar.nonrolloverBorder", (LazyValue) t -> MetalBorders.getToolBarNonrolloverBorder(),
             "ToolBar.ancestorInputMap",
                new UIDefaults.LazyInputMap(new Object[] {
                         "UP", "navigateUp",
@@ -1489,17 +1480,14 @@
                  }),
 
             // RootPane
-            "RootPane.frameBorder", new MetalLazyValue(
-                      "javax.swing.plaf.metal.MetalBorders$FrameBorder"),
+            "RootPane.frameBorder", (LazyValue) t -> new MetalBorders.FrameBorder(),
             "RootPane.plainDialogBorder", dialogBorder,
             "RootPane.informationDialogBorder", dialogBorder,
-            "RootPane.errorDialogBorder", new MetalLazyValue(
-                      "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder"),
+            "RootPane.errorDialogBorder", (LazyValue) t -> new MetalBorders.ErrorDialogBorder(),
             "RootPane.colorChooserDialogBorder", questionDialogBorder,
             "RootPane.fileChooserDialogBorder", questionDialogBorder,
             "RootPane.questionDialogBorder", questionDialogBorder,
-            "RootPane.warningDialogBorder", new MetalLazyValue(
-                    "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder"),
+            "RootPane.warningDialogBorder", (LazyValue) t -> new MetalBorders.WarningDialogBorder(),
             // These bindings are only enabled when there is a default
             // button set on the rootpane.
             "RootPane.defaultButtonWindowKeyBindings", new Object[] {
@@ -2151,61 +2139,6 @@
 
 
     /**
-     * MetalLazyValue is a slimmed down version of <code>ProxyLaxyValue</code>.
-     * The code is duplicate so that it can get at the package private
-     * classes in metal.
-     */
-    private static class MetalLazyValue implements UIDefaults.LazyValue {
-        /**
-         * Name of the class to create.
-         */
-        private String className;
-        private String methodName;
-
-        MetalLazyValue(String name) {
-            this.className = name;
-        }
-
-        MetalLazyValue(String name, String methodName) {
-            this(name);
-            this.methodName = methodName;
-        }
-
-        public Object createValue(UIDefaults table) {
-            try {
-                final Class c = Class.forName(className);
-
-                if (methodName == null) {
-                    return c.newInstance();
-                }
-                Method method = AccessController.doPrivileged(
-                    new PrivilegedAction<Method>() {
-                    public Method run() {
-                        Method[] methods = c.getDeclaredMethods();
-                        for (int counter = methods.length - 1; counter >= 0;
-                             counter--) {
-                            if (methods[counter].getName().equals(methodName)){
-                                methods[counter].setAccessible(true);
-                                return methods[counter];
-                            }
-                        }
-                        return null;
-                    }
-                });
-                if (method != null) {
-                    return method.invoke(null, (Object[])null);
-                }
-            } catch (ClassNotFoundException cnfe) {
-            } catch (InstantiationException ie) {
-            } catch (IllegalAccessException iae) {
-            } catch (InvocationTargetException ite) {
-            }
-            return null;
-        }
-    }
-
-
-    /**
      * FontActiveValue redirects to the appropriate metal theme method.
      */
     private static class FontActiveValue implements UIDefaults.ActiveValue {
--- a/src/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,33 +25,23 @@
 
 package javax.swing.plaf.metal;
 
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.LayoutManager;
-import java.awt.Adjustable;
-import java.awt.event.AdjustmentListener;
-import java.awt.event.AdjustmentEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.Graphics;
+import java.awt.Color;
 import java.awt.Dimension;
+import java.awt.Graphics;
 import java.awt.Rectangle;
-import java.awt.Point;
-import java.awt.Insets;
-import java.awt.Color;
-import java.awt.IllegalComponentStateException;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 
-import java.beans.*;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JScrollBar;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicScrollBarUI;
 
-import javax.swing.*;
-import javax.swing.event.*;
-
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.BasicScrollBarUI;
+import static sun.swing.SwingUtilities2.drawHLine;
+import static sun.swing.SwingUtilities2.drawRect;
+import static sun.swing.SwingUtilities2.drawVLine;
 
 
 /**
@@ -158,21 +148,21 @@
 
             if ( c.isEnabled() ) {
                 g.setColor( darkShadowColor );
-                g.drawLine( 0, 0, 0, trackBounds.height - 1 );
-                g.drawLine( trackBounds.width - 2, 0, trackBounds.width - 2, trackBounds.height - 1 );
-                g.drawLine( 2, trackBounds.height - 1, trackBounds.width - 1, trackBounds.height - 1);
-                g.drawLine( 2, 0, trackBounds.width - 2, 0 );
+                drawVLine(g, 0, 0, trackBounds.height - 1);
+                drawVLine(g, trackBounds.width - 2, 0, trackBounds.height - 1);
+                drawHLine(g, 2, trackBounds.width - 1, trackBounds.height - 1);
+                drawHLine(g, 2, trackBounds.width - 2, 0);
 
                 g.setColor( shadowColor );
                 //      g.setColor( Color.red);
-                g.drawLine( 1, 1, 1, trackBounds.height - 2 );
-                g.drawLine( 1, 1, trackBounds.width - 3, 1 );
+                drawVLine(g, 1, 1, trackBounds.height - 2);
+                drawHLine(g, 1, trackBounds.width - 3, 1);
                 if (scrollbar.getValue() != scrollbar.getMaximum()) {  // thumb shadow
                     int y = thumbRect.y + thumbRect.height - trackBounds.y;
-                    g.drawLine( 1, y, trackBounds.width-1, y);
+                    drawHLine(g, 1, trackBounds.width - 1, y);
                 }
                 g.setColor(highlightColor);
-                g.drawLine( trackBounds.width - 1, 0, trackBounds.width - 1, trackBounds.height - 1 );
+                drawVLine(g, trackBounds.width - 1, 0, trackBounds.height - 1);
             } else {
                 MetalUtils.drawDisabledBorder(g, 0, 0, trackBounds.width, trackBounds.height );
             }
@@ -192,19 +182,19 @@
 
             if ( c.isEnabled() ) {
                 g.setColor( darkShadowColor );
-                g.drawLine( 0, 0, trackBounds.width - 1, 0 );  // top
-                g.drawLine( 0, 2, 0, trackBounds.height - 2 ); // left
-                g.drawLine( 0, trackBounds.height - 2, trackBounds.width - 1, trackBounds.height - 2 ); // bottom
-                g.drawLine( trackBounds.width - 1, 2, trackBounds.width - 1, trackBounds.height - 1 ); // right
+                drawHLine(g, 0, trackBounds.width - 1, 0);  // top
+                drawVLine(g, 0, 2, trackBounds.height - 2); // left
+                drawHLine(g, 0, trackBounds.width - 1, trackBounds.height - 2 ); // bottom
+                drawVLine(g, trackBounds.width - 1, 2,  trackBounds.height - 1 ); // right
 
                 g.setColor( shadowColor );
                 //      g.setColor( Color.red);
-                g.drawLine( 1, 1, trackBounds.width - 2, 1 );  // top
-                g.drawLine( 1, 1, 1, trackBounds.height - 3 ); // left
-                g.drawLine( 0, trackBounds.height - 1, trackBounds.width - 1, trackBounds.height - 1 ); // bottom
+                drawHLine(g, 1, trackBounds.width - 2, 1 );  // top
+                drawVLine(g, 1, 1, trackBounds.height - 3 ); // left
+                drawHLine(g, 0, trackBounds.width - 1, trackBounds.height - 1 ); // bottom
                 if (scrollbar.getValue() != scrollbar.getMaximum()) {  // thumb shadow
                     int x = thumbRect.x + thumbRect.width - trackBounds.x;
-                    g.drawLine( x, 1, x, trackBounds.height-1);
+                    drawVLine(g, x, 1, trackBounds.height-1);
                 }
             } else {
                 MetalUtils.drawDisabledBorder(g, 0, 0, trackBounds.width, trackBounds.height );
@@ -246,11 +236,11 @@
             g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 );
 
             g.setColor( thumbShadow );
-            g.drawRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 );
+            drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1);
 
             g.setColor( thumbHighlightColor );
-            g.drawLine( 1, 1, thumbBounds.width - 3, 1 );
-            g.drawLine( 1, 1, 1, thumbBounds.height - 2 );
+            drawHLine(g, 1, thumbBounds.width - 3, 1);
+            drawVLine(g, 1, 1, thumbBounds.height - 2);
 
             bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 );
             bumps.paintIcon( c, g, 3, 4 );
@@ -272,11 +262,11 @@
             g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 );
 
             g.setColor( thumbShadow );
-            g.drawRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 );
+            drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2);
 
             g.setColor( thumbHighlightColor );
-            g.drawLine( 1, 1, thumbBounds.width - 3, 1 );
-            g.drawLine( 1, 1, 1, thumbBounds.height - 3 );
+            drawHLine(g, 1, thumbBounds.width - 3, 1);
+            drawVLine(g, 1, 1, thumbBounds.height - 3);
 
             bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 );
             bumps.paintIcon( c, g, 4, 3 );
@@ -309,11 +299,11 @@
             }
 
             g.setColor(thumbShadow);
-            g.drawRect(0, 0, thumbBounds.width - 2, thumbBounds.height - 1);
+            drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1);
 
             g.setColor(thumbHighlightColor);
-            g.drawLine(1, 1, thumbBounds.width - 3, 1);
-            g.drawLine(1, 1, 1, thumbBounds.height - 2);
+            drawHLine(g, 1, thumbBounds.width - 3, 1);
+            drawVLine(g, 1, 1, thumbBounds.height - 2);
 
             MetalUtils.drawGradient(c, g, "ScrollBar.gradient", 2, 2,
                                     thumbBounds.width - 4,
@@ -351,11 +341,11 @@
             }
 
             g.setColor(thumbShadow);
-            g.drawRect(0, 0, thumbBounds.width - 1, thumbBounds.height - 2);
+            drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2);
 
             g.setColor(thumbHighlightColor);
-            g.drawLine(1, 1, thumbBounds.width - 2, 1);
-            g.drawLine(1, 1, 1, thumbBounds.height - 3);
+            drawHLine(g, 1, thumbBounds.width - 2, 1);
+            drawVLine(g, 1, 1, thumbBounds.height - 3);
 
             MetalUtils.drawGradient(c, g, "ScrollBar.gradient", 2, 2,
                                     thumbBounds.width - 3,
--- a/src/share/classes/javax/swing/text/EditorKit.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/text/EditorKit.java	Thu May 01 14:21:29 2014 -0700
@@ -39,9 +39,9 @@
  * A kit can safely store editing state as an instance
  * of the kit will be dedicated to a text component.
  * New kits will normally be created by cloning a
- * prototype kit.  The kit will have it's
+ * prototype kit.  The kit will have its
  * <code>setComponent</code> method called to establish
- * it's relationship with a JTextComponent.
+ * its relationship with a JTextComponent.
  *
  * @author  Timothy Prinzing
  */
--- a/src/share/classes/javax/swing/text/JTextComponent.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/text/JTextComponent.java	Thu May 01 14:21:29 2014 -0700
@@ -24,18 +24,16 @@
  */
 package javax.swing.text;
 
-import java.lang.reflect.Method;
+import com.sun.beans.util.Cache;
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 import java.beans.Transient;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Enumeration;
 import java.util.Vector;
-import java.util.Map;
 
 import java.util.concurrent.*;
 
@@ -1194,47 +1192,6 @@
     }
 
     /**
-     * Returns true if <code>klass</code> is NOT a JTextComponent and it or
-     * one of its superclasses (stoping at JTextComponent) overrides
-     * <code>processInputMethodEvent</code>. It is assumed this will be
-     * invoked from within a <code>doPrivileged</code>, and it is also
-     * assumed <code>klass</code> extends <code>JTextComponent</code>.
-     */
-    private static Boolean isProcessInputMethodEventOverridden(Class<?> klass) {
-        if (klass == JTextComponent.class) {
-            return Boolean.FALSE;
-        }
-        Boolean retValue = overrideMap.get(klass.getName());
-
-        if (retValue != null) {
-            return retValue;
-        }
-        Boolean sOverriden = isProcessInputMethodEventOverridden(
-                                       klass.getSuperclass());
-
-        if (sOverriden.booleanValue()) {
-            // If our superclass has overriden it, then by definition klass
-            // overrides it.
-            overrideMap.put(klass.getName(), sOverriden);
-            return sOverriden;
-        }
-        // klass's superclass didn't override it, check for an override in
-        // klass.
-        try {
-            Class[] classes = new Class[1];
-            classes[0] = InputMethodEvent.class;
-
-            Method m = klass.getDeclaredMethod("processInputMethodEvent",
-                                               classes);
-            retValue = Boolean.TRUE;
-        } catch (NoSuchMethodException nsme) {
-            retValue = Boolean.FALSE;
-        }
-        overrideMap.put(klass.getName(), retValue);
-        return retValue;
-    }
-
-    /**
      * Fetches the current color used to render the
      * caret.
      *
@@ -3916,7 +3873,33 @@
      * Maps from class name to Boolean indicating if
      * <code>processInputMethodEvent</code> has been overriden.
      */
-    private static Map<String, Boolean> overrideMap;
+    private static Cache<Class<?>,Boolean> METHOD_OVERRIDDEN
+            = new Cache<Class<?>,Boolean>(Cache.Kind.WEAK, Cache.Kind.STRONG) {
+        /**
+         * Returns {@code true} if the specified {@code type} extends {@link JTextComponent}
+         * and the {@link JTextComponent#processInputMethodEvent} method is overridden.
+         */
+        @Override
+        public Boolean create(final Class<?> type) {
+            if (JTextComponent.class == type) {
+                return Boolean.FALSE;
+            }
+            if (get(type.getSuperclass())) {
+                return Boolean.TRUE;
+            }
+            return AccessController.doPrivileged(
+                    new PrivilegedAction<Boolean>() {
+                        public Boolean run() {
+                            try {
+                                type.getDeclaredMethod("processInputMethodEvent", InputMethodEvent.class);
+                                return Boolean.TRUE;
+                            } catch (NoSuchMethodException exception) {
+                                return Boolean.FALSE;
+                            }
+                        }
+                    });
+        }
+    };
 
     /**
      * Returns a string representation of this <code>JTextComponent</code>.
@@ -4941,39 +4924,16 @@
      */
     private boolean shouldSynthensizeKeyEvents() {
         if (!checkedInputOverride) {
+            // Checks whether the client code overrides processInputMethodEvent.
+            // If it is overridden, need not to generate KeyTyped events for committed text.
+            // If it's not, behave as an passive input method client.
+            needToSendKeyTypedEvent = !METHOD_OVERRIDDEN.get(getClass());
             checkedInputOverride = true;
-            needToSendKeyTypedEvent =
-                             !isProcessInputMethodEventOverridden();
         }
         return needToSendKeyTypedEvent;
     }
 
     //
-    // Checks whether the client code overrides processInputMethodEvent.  If it is overridden,
-    // need not to generate KeyTyped events for committed text. If it's not, behave as an
-    // passive input method client.
-    //
-    private boolean isProcessInputMethodEventOverridden() {
-        if (overrideMap == null) {
-            overrideMap = Collections.synchronizedMap(new HashMap<String, Boolean>());
-        }
-        Boolean retValue = overrideMap.get(getClass().getName());
-
-        if (retValue != null) {
-            return retValue.booleanValue();
-        }
-        Boolean ret = AccessController.doPrivileged(new
-                       PrivilegedAction<Boolean>() {
-            public Boolean run() {
-                return isProcessInputMethodEventOverridden(
-                                JTextComponent.this.getClass());
-            }
-        });
-
-        return ret.booleanValue();
-    }
-
-    //
     // Checks whether a composed text in this text component
     //
     boolean composedTextExists() {
--- a/src/share/classes/javax/swing/text/html/HTMLEditorKit.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/HTMLEditorKit.java	Thu May 01 14:21:29 2014 -0700
@@ -26,7 +26,6 @@
 
 import sun.awt.AppContext;
 
-import java.lang.reflect.Method;
 import java.awt.*;
 import java.awt.event.*;
 import java.io.*;
@@ -34,12 +33,13 @@
 import java.net.URL;
 import javax.swing.text.*;
 import javax.swing.*;
-import javax.swing.border.*;
 import javax.swing.event.*;
 import javax.swing.plaf.TextUI;
 import java.util.*;
 import javax.accessibility.*;
 import java.lang.ref.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /**
  * The Swing JEditorPane text component supports different kinds
@@ -415,14 +415,13 @@
      *  HTMLEditorKit class
      * @return a stream representing the resource
      */
-    static InputStream getResourceAsStream(String name) {
-        try {
-            return ResourceLoader.getResourceAsStream(name);
-        } catch (Throwable e) {
-            // If the class doesn't exist or we have some other
-            // problem we just try to call getResourceAsStream directly.
-            return HTMLEditorKit.class.getResourceAsStream(name);
-        }
+    static InputStream getResourceAsStream(final String name) {
+        return AccessController.doPrivileged(
+                new PrivilegedAction<InputStream>() {
+                    public InputStream run() {
+                        return HTMLEditorKit.class.getResourceAsStream(name);
+                    }
+                });
     }
 
     /**
--- a/src/share/classes/javax/swing/text/html/ResourceLoader.java	Thu May 01 12:51:13 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package javax.swing.text.html;
-
-import java.io.InputStream;
-
-/**
- * Simple class to load resources using the 1.2
- * security model.  Since the html support is loaded
- * lazily, it's resources are potentially fetched with
- * applet code in the call stack.  By providing this
- * functionality in a class that is only built on 1.2,
- * reflection can be used from the code that is also
- * built on 1.1 to call this functionality (and avoid
- * the evils of preprocessing).  This functionality
- * is called from HTMLEditorKit.getResourceAsStream.
- *
- * @author  Timothy Prinzing
- */
-class ResourceLoader implements java.security.PrivilegedAction {
-
-    ResourceLoader(String name) {
-        this.name = name;
-    }
-
-    public Object run() {
-        Object o = HTMLEditorKit.class.getResourceAsStream(name);
-        return o;
-    }
-
-    public static InputStream getResourceAsStream(String name) {
-        java.security.PrivilegedAction a = new ResourceLoader(name);
-        return (InputStream) java.security.AccessController.doPrivileged(a);
-    }
-
-    private String name;
-}
--- a/src/share/classes/javax/swing/text/html/parser/ParserDelegator.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/parser/ParserDelegator.java	Thu May 01 14:21:29 2014 -0700
@@ -22,7 +22,6 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package javax.swing.text.html.parser;
 
 import sun.awt.AppContext;
@@ -35,6 +34,8 @@
 import java.io.ObjectInputStream;
 import java.io.Reader;
 import java.io.Serializable;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /**
  * Responsible for starting up a new DocumentParser
@@ -110,14 +111,13 @@
      *  ParserDelegator class.
      * @returns a stream representing the resource
      */
-    static InputStream getResourceAsStream(String name) {
-        try {
-            return ResourceLoader.getResourceAsStream(name);
-        } catch (Throwable e) {
-            // If the class doesn't exist or we have some other
-            // problem we just try to call getResourceAsStream directly.
-            return ParserDelegator.class.getResourceAsStream(name);
-        }
+    static InputStream getResourceAsStream(final String name) {
+        return AccessController.doPrivileged(
+                new PrivilegedAction<InputStream>() {
+                    public InputStream run() {
+                        return ParserDelegator.class.getResourceAsStream(name);
+                    }
+                });
     }
 
     private void readObject(ObjectInputStream s)
--- a/src/share/classes/javax/swing/text/html/parser/ResourceLoader.java	Thu May 01 12:51:13 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package javax.swing.text.html.parser;
-
-import java.io.InputStream;
-
-/**
- * Simple class to load resources using the 1.2
- * security model.  Since the html support is loaded
- * lazily, it's resources are potentially fetched with
- * applet code in the call stack.  By providing this
- * functionality in a class that is only built on 1.2,
- * reflection can be used from the code that is also
- * built on 1.1 to call this functionality (and avoid
- * the evils of preprocessing).  This functionality
- * is called from ParserDelegator.getResourceAsStream.
- *
- * @author  Timothy Prinzing
- */
-class ResourceLoader implements java.security.PrivilegedAction {
-
-    ResourceLoader(String name) {
-        this.name = name;
-    }
-
-    public Object run() {
-        Object o = ParserDelegator.class.getResourceAsStream(name);
-        return o;
-    }
-
-    public static InputStream getResourceAsStream(String name) {
-        java.security.PrivilegedAction a = new ResourceLoader(name);
-        return (InputStream) java.security.AccessController.doPrivileged(a);
-    }
-
-    private String name;
-}
--- a/src/share/classes/javax/swing/text/rtf/RTFReader.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/text/rtf/RTFReader.java	Thu May 01 14:21:29 2014 -0700
@@ -27,9 +27,9 @@
 import java.lang.*;
 import java.util.*;
 import java.io.*;
-import java.awt.Font;
 import java.awt.Color;
-
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import javax.swing.text.*;
 
 /**
@@ -558,16 +558,14 @@
 {
     char[] set = characterSets.get(name);
     if (set == null) {
-      InputStream charsetStream;
-      charsetStream = java.security.AccessController.
-              doPrivileged(new java.security.PrivilegedAction<InputStream>() {
-          public InputStream run() {
-              return RTFReader.class.getResourceAsStream
-                                     ("charsets/" + name + ".txt");
-          }
-      });
-      set = readCharset(charsetStream);
-      defineCharacterSet(name, set);
+        InputStream charsetStream = AccessController.doPrivileged(
+                new PrivilegedAction<InputStream>() {
+                    public InputStream run() {
+                        return RTFReader.class.getResourceAsStream("charsets/" + name + ".txt");
+                    }
+                });
+        set = readCharset(charsetStream);
+        defineCharacterSet(name, set);
     }
     return set;
 }
--- a/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java	Thu May 01 14:21:29 2014 -0700
@@ -191,7 +191,7 @@
         if (!inited || (getClosedIcon() instanceof UIResource)) {
             setClosedIcon(DefaultLookup.getIcon(this, ui, "Tree.closedIcon"));
         }
-        if (!inited || (getOpenIcon() instanceof UIManager)) {
+        if (!inited || (getOpenIcon() instanceof UIResource)) {
             setOpenIcon(DefaultLookup.getIcon(this, ui, "Tree.openIcon"));
         }
         if (!inited || (getTextSelectionColor() instanceof UIResource)) {
--- a/src/share/classes/sun/awt/AWTAccessor.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/awt/AWTAccessor.java	Thu May 01 14:21:29 2014 -0700
@@ -272,6 +272,16 @@
          * bypasses disabled Components during the search.
          */
         Component findComponentAt(Container cont, int x, int y, boolean ignoreEnabled);
+
+        /**
+         * Starts LW Modal.
+         */
+        void startLWModal(Container cont);
+
+        /**
+         * Starts LW Modal.
+         */
+        void stopLWModal(Container cont);
     }
 
     /*
--- a/src/share/classes/sun/awt/EventListenerAggregate.java	Thu May 01 12:51:13 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt;
-
-import java.lang.reflect.Array;
-import java.util.EventListener;
-
-
-/**
- * A class that assists in managing {@link java.util.EventListener}s of
- * the specified type. Its instance holds an array of listeners of the same
- * type and allows to perform the typical operations on the listeners.
- * This class is thread-safe.
- *
- * @author Alexander Gerasimov
- *
- * @since 1.5
- */
-public class EventListenerAggregate {
-
-    private EventListener[] listenerList;
-
-    /**
-     * Constructs an <code>EventListenerAggregate</code> object.
-     *
-     * @param listenerClass the type of the listeners to be managed by this object
-     *
-     * @throws NullPointerException if <code>listenerClass</code> is
-     *         <code>null</code>
-     * @throws ClassCastException if <code>listenerClass</code> is not
-     *         assignable to <code>java.util.EventListener</code>
-     */
-    public EventListenerAggregate(Class<? extends EventListener> listenerClass) {
-        if (listenerClass == null) {
-            throw new NullPointerException("listener class is null");
-        }
-
-        listenerList = (EventListener[])Array.newInstance(listenerClass, 0);
-    }
-
-    private Class<?> getListenerClass() {
-        return listenerList.getClass().getComponentType();
-    }
-
-    /**
-     * Adds the listener to this aggregate.
-     *
-     * @param listener the listener to be added
-     *
-     * @throws ClassCastException if <code>listener</code> is not
-     *         an instatce of <code>listenerClass</code> specified
-     *         in the constructor
-     */
-    public synchronized void add(EventListener listener) {
-        Class<?> listenerClass = getListenerClass();
-
-        if (!listenerClass.isInstance(listener)) { // null is not an instance of any class
-            throw new ClassCastException("listener " + listener + " is not " +
-                    "an instance of listener class " + listenerClass);
-        }
-
-        EventListener[] tmp = (EventListener[])Array.newInstance(listenerClass, listenerList.length + 1);
-        System.arraycopy(listenerList, 0, tmp, 0, listenerList.length);
-        tmp[listenerList.length] = listener;
-        listenerList = tmp;
-    }
-
-    /**
-     * Removes a listener that is equal to the given one from this aggregate.
-     * <code>equals()</code> method is used to compare listeners.
-     *
-     * @param listener the listener to be removed
-     *
-     * @return <code>true</code> if this aggregate contained the specified
-     *         <code>listener</code>; <code>false</code> otherwise
-     *
-     * @throws ClassCastException if <code>listener</code> is not
-     *         an instatce of <code>listenerClass</code> specified
-     *         in the constructor
-     */
-    public synchronized boolean remove(EventListener listener) {
-        Class<?> listenerClass = getListenerClass();
-
-        if (!listenerClass.isInstance(listener)) { // null is not an instance of any class
-            throw new ClassCastException("listener " + listener + " is not " +
-                    "an instance of listener class " + listenerClass);
-        }
-
-        for (int i = 0; i < listenerList.length; i++) {
-            if (listenerList[i].equals(listener)) {
-                EventListener[] tmp = (EventListener[])Array.newInstance(listenerClass,
-                                                                         listenerList.length - 1);
-                System.arraycopy(listenerList, 0, tmp, 0, i);
-                System.arraycopy(listenerList, i + 1, tmp, i, listenerList.length - i - 1);
-                listenerList = tmp;
-
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns an array of all the listeners contained in this aggregate.
-     * The array is the data structure in which listeners are stored internally.
-     * The runtime type of the returned array is "array of <code>listenerClass</code>"
-     * (<code>listenerClass</code> has been specified as a parameter to
-     * the constructor of this class).
-     *
-     * @return all the listeners contained in this aggregate (an empty
-     *         array if there are no listeners)
-     */
-    public synchronized EventListener[] getListenersInternal() {
-        return listenerList;
-    }
-
-    /**
-     * Returns an array of all the listeners contained in this aggregate.
-     * The array is a copy of the data structure in which listeners are stored
-     * internally.
-     * The runtime type of the returned array is "array of <code>listenerClass</code>"
-     * (<code>listenerClass</code> has been specified as a parameter to
-     * the constructor of this class).
-     *
-     * @return a copy of all the listeners contained in this aggregate (an empty
-     *         array if there are no listeners)
-     */
-    public synchronized EventListener[] getListenersCopy() {
-        return (listenerList.length == 0) ? listenerList : listenerList.clone();
-    }
-
-    /**
-     * Returns the number of lisetners in this aggregate.
-     *
-     * @return the number of lisetners in this aggregate
-     */
-    public synchronized int size() {
-        return listenerList.length;
-    }
-
-    /**
-     * Returns <code>true</code> if this aggregate contains no listeners,
-     * <code>false</code> otherwise.
-     *
-     * @return <code>true</code> if this aggregate contains no listeners,
-     *         <code>false</code> otherwise
-     */
-    public synchronized boolean isEmpty() {
-        return listenerList.length == 0;
-    }
-}
--- a/src/share/classes/sun/awt/datatransfer/SunClipboard.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/awt/datatransfer/SunClipboard.java	Thu May 01 14:21:29 2014 -0700
@@ -40,7 +40,7 @@
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
-import java.util.Iterator;
+import java.util.Objects;
 import java.util.Set;
 import java.util.HashSet;
 
@@ -49,7 +49,6 @@
 import sun.awt.AppContext;
 import sun.awt.PeerEvent;
 import sun.awt.SunToolkit;
-import sun.awt.EventListenerAggregate;
 
 
 /**
@@ -107,11 +106,7 @@
             setContentsNative(contents);
         } finally {
             if (oldOwner != null && oldOwner != owner) {
-                EventQueue.invokeLater(new Runnable() {
-                    public void run() {
-                        oldOwner.lostOwnership(SunClipboard.this, oldContents);
-                    }
-                });
+                EventQueue.invokeLater(() -> oldOwner.lostOwnership(SunClipboard.this, oldContents));
             }
         }
     }
@@ -355,13 +350,12 @@
             return;
         }
         AppContext appContext = AppContext.getAppContext();
-        EventListenerAggregate contextFlavorListeners = (EventListenerAggregate)
-                appContext.get(CLIPBOARD_FLAVOR_LISTENER_KEY);
-        if (contextFlavorListeners == null) {
-            contextFlavorListeners = new EventListenerAggregate(FlavorListener.class);
-            appContext.put(CLIPBOARD_FLAVOR_LISTENER_KEY, contextFlavorListeners);
+        Set<FlavorListener> flavorListeners = getFlavorListeners(appContext);
+        if (flavorListeners == null) {
+            flavorListeners = new HashSet<>();
+            appContext.put(CLIPBOARD_FLAVOR_LISTENER_KEY, flavorListeners);
         }
-        contextFlavorListeners.add(listener);
+        flavorListeners.add(listener);
 
         if (numberOfFlavorListeners++ == 0) {
             long[] currentFormats = null;
@@ -382,25 +376,26 @@
         if (listener == null) {
             return;
         }
-        AppContext appContext = AppContext.getAppContext();
-        EventListenerAggregate contextFlavorListeners = (EventListenerAggregate)
-                appContext.get(CLIPBOARD_FLAVOR_LISTENER_KEY);
-        if (contextFlavorListeners == null){
+        Set<FlavorListener> flavorListeners = getFlavorListeners(AppContext.getAppContext());
+        if (flavorListeners == null){
             //else we throw NullPointerException, but it is forbidden
             return;
         }
-        if (contextFlavorListeners.remove(listener) &&
-                --numberOfFlavorListeners == 0) {
+        if (flavorListeners.remove(listener) && --numberOfFlavorListeners == 0) {
             unregisterClipboardViewerChecked();
             currentDataFlavors = null;
         }
     }
 
+    @SuppressWarnings("unchecked")
+    private Set<FlavorListener> getFlavorListeners(AppContext appContext) {
+        return (Set<FlavorListener>)appContext.get(CLIPBOARD_FLAVOR_LISTENER_KEY);
+    }
+
     public synchronized FlavorListener[] getFlavorListeners() {
-        EventListenerAggregate contextFlavorListeners = (EventListenerAggregate)
-                AppContext.getAppContext().get(CLIPBOARD_FLAVOR_LISTENER_KEY);
-        return contextFlavorListeners == null ? new FlavorListener[0] :
-                (FlavorListener[])contextFlavorListeners.getListenersCopy();
+        Set<FlavorListener> flavorListeners = getFlavorListeners(AppContext.getAppContext());
+        return flavorListeners == null ? new FlavorListener[0]
+                : flavorListeners.toArray(new FlavorListener[flavorListeners.size()]);
     }
 
     public boolean areFlavorListenersRegistered() {
@@ -425,42 +420,26 @@
         Set prevDataFlavors = currentDataFlavors;
         currentDataFlavors = formatArrayAsDataFlavorSet(formats);
 
-        if ((prevDataFlavors != null) && (currentDataFlavors != null) &&
-                prevDataFlavors.equals(currentDataFlavors)) {
+        if (Objects.equals(prevDataFlavors, currentDataFlavors)) {
             // we've been able to successfully get available on the clipboard
             // DataFlavors this and previous time and they are coincident;
             // don't notify
             return;
         }
 
-        class SunFlavorChangeNotifier implements Runnable {
-            private final FlavorListener flavorListener;
-
-            SunFlavorChangeNotifier(FlavorListener flavorListener) {
-                this.flavorListener = flavorListener;
-            }
-
-            public void run() {
-                if (flavorListener != null) {
-                    flavorListener.flavorsChanged(new FlavorEvent(SunClipboard.this));
-                }
-            }
-        };
-
-        for (Iterator it = AppContext.getAppContexts().iterator(); it.hasNext();) {
-            AppContext appContext = (AppContext)it.next();
+        for (AppContext appContext : AppContext.getAppContexts()) {
             if (appContext == null || appContext.isDisposed()) {
                 continue;
             }
-            EventListenerAggregate flavorListeners = (EventListenerAggregate)
-                    appContext.get(CLIPBOARD_FLAVOR_LISTENER_KEY);
+            Set<FlavorListener> flavorListeners = getFlavorListeners(appContext);
             if (flavorListeners != null) {
-                FlavorListener[] flavorListenerArray =
-                        (FlavorListener[])flavorListeners.getListenersInternal();
-                for (int i = 0; i < flavorListenerArray.length; i++) {
-                    SunToolkit.postEvent(appContext, new PeerEvent(this,
-                            new SunFlavorChangeNotifier(flavorListenerArray[i]),
-                            PeerEvent.PRIORITY_EVENT));
+                for (FlavorListener listener : flavorListeners) {
+                    if (listener != null) {
+                        PeerEvent peerEvent = new PeerEvent(this,
+                                () -> listener.flavorsChanged(new FlavorEvent(SunClipboard.this)),
+                                PeerEvent.PRIORITY_EVENT);
+                        SunToolkit.postEvent(appContext, peerEvent);
+                    }
                 }
             }
         }
--- a/src/share/classes/sun/awt/image/GifImageDecoder.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/awt/image/GifImageDecoder.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -114,6 +114,7 @@
     /**
      * produce an image from the stream.
      */
+    @SuppressWarnings("fallthrough")
     public void produceImage() throws IOException, ImageFormatException {
         try {
             readHeader();
@@ -238,7 +239,7 @@
                     if (frameno == 0) {
                         return;
                     }
-                    // NOBREAK
+                    // Fall through
 
                   case TERMINATOR:
                     if (nloops == 0 || nloops-- >= 0) {
--- a/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java	Thu May 01 14:21:29 2014 -0700
@@ -24,6 +24,7 @@
  */
 package sun.awt.image;
 
+import java.awt.Dimension;
 import java.awt.Image;
 import java.awt.Graphics;
 import java.awt.geom.Dimension2D;
@@ -43,6 +44,13 @@
     private int availableInfo;
 
     public MultiResolutionBufferedImage(Image baseImage,
+            BiFunction<Integer, Integer, Image> mapper) {
+        this(baseImage, new Dimension[]{new Dimension(
+            baseImage.getWidth(null), baseImage.getHeight(null))
+        }, mapper);
+    }
+
+    public MultiResolutionBufferedImage(Image baseImage,
             Dimension2D[] sizes, BiFunction<Integer, Integer, Image> mapper) {
         super(baseImage.getWidth(null), baseImage.getHeight(null),
                 BufferedImage.TYPE_INT_ARGB_PRE);
@@ -115,7 +123,7 @@
     }
 
     private static void preload(Image image, int availableInfo) {
-        if (image instanceof ToolkitImage) {
+        if (availableInfo != 0 && image instanceof ToolkitImage) {
             ((ToolkitImage) image).preload(new ImageObserver() {
                 int flags = availableInfo;
 
--- a/src/share/classes/sun/awt/image/PixelConverter.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/awt/image/PixelConverter.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,6 +53,7 @@
 
     protected PixelConverter() {}
 
+    @SuppressWarnings("fallthrough")
     public int rgbToPixel(int rgb, ColorModel cm) {
         Object obj = cm.getDataElements(rgb, null);
         switch (cm.getTransferType()) {
--- a/src/share/classes/sun/java2d/pipe/DrawImage.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/java2d/pipe/DrawImage.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -310,11 +310,19 @@
         return false;
     }
 
-    /*
-     * Return a BufferedImage of the requested type with the indicated
-     * subimage of the original image located at 0,0 in the new image.
-     * If a bgColor is supplied, composite the original image over that
-     * color with a SrcOver operation, otherwise make a SrcNoEa copy.
+    /**
+     * Return a non-accelerated BufferedImage of the requested type with the
+     * indicated subimage of the original image located at 0,0 in the new image.
+     * If a bgColor is supplied, composite the original image over that color
+     * with a SrcOver operation, otherwise make a SrcNoEa copy.
+     * <p>
+     * Returned BufferedImage is not accelerated for two reasons:
+     * <ul>
+     * <li> Types of the image and surface are predefined, because these types
+     *      correspond to the TransformHelpers, which we know we have. And
+     *      acceleration can change the type of the surface
+     * <li> Image will be used only once and acceleration caching wouldn't help
+     * </ul>
      */
     BufferedImage makeBufferedImage(Image img, Color bgColor, int type,
                                     int sx1, int sy1, int sx2, int sy2)
@@ -324,6 +332,7 @@
         final BufferedImage bimg = new BufferedImage(width, height, type);
         final SunGraphics2D g2d = (SunGraphics2D) bimg.createGraphics();
         g2d.setComposite(AlphaComposite.Src);
+        bimg.setAccelerationPriority(0);
         if (bgColor != null) {
             g2d.setColor(bgColor);
             g2d.fillRect(0, 0, width, height);
--- a/src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import java.util.Base64;
 import java.util.HashMap;
 import sun.net.www.HeaderParser;
+import sun.util.logging.PlatformLogger;
 import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE;
 import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
 
@@ -44,6 +45,7 @@
 class NegotiateAuthentication extends AuthenticationInfo {
 
     private static final long serialVersionUID = 100L;
+    private static final PlatformLogger logger = HttpURLConnection.getHttpLogger();
 
     final private HttpCallerInfo hci;
 
@@ -79,6 +81,31 @@
     }
 
     /**
+     * Find out if the HttpCallerInfo supports Negotiate protocol.
+     * @return true if supported
+     */
+    public static boolean isSupported(HttpCallerInfo hci) {
+        ClassLoader loader = null;
+        try {
+            loader = Thread.currentThread().getContextClassLoader();
+        } catch (SecurityException se) {
+            if (logger.isLoggable(PlatformLogger.Level.FINER)) {
+                logger.finer("NegotiateAuthentication: " +
+                    "Attempt to get the context class loader failed - " + se);
+            }
+        }
+
+        if (loader != null) {
+            // Lock on the class loader instance to avoid the deadlock engaging
+            // the lock in "ClassLoader.loadClass(String, boolean)" method.
+            synchronized (loader) {
+                return isSupportedImpl(hci);
+            }
+        }
+        return isSupportedImpl(hci);
+    }
+
+    /**
      * Find out if the HttpCallerInfo supports Negotiate protocol. In order to
      * find out yes or no, an initialization of a Negotiator object against it
      * is tried. The generated object will be cached under the name of ths
@@ -89,7 +116,7 @@
      *
      * @return true if supported
      */
-    synchronized public static boolean isSupported(HttpCallerInfo hci) {
+    private static synchronized boolean isSupportedImpl(HttpCallerInfo hci) {
         if (supported == null) {
             supported = new HashMap <String, Boolean>();
             cache = new HashMap <String, Negotiator>();
--- a/src/share/classes/sun/nio/ch/PendingFuture.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/nio/ch/PendingFuture.java	Thu May 01 14:21:29 2014 -0700
@@ -35,8 +35,6 @@
  */
 
 final class PendingFuture<V,A> implements Future<V> {
-    private static final CancellationException CANCELLED =
-        new CancellationException();
 
     private final AsynchronousChannel channel;
     private final CompletionHandler<V,? super A> handler;
@@ -180,7 +178,7 @@
                 latch.await();
         }
         if (exc != null) {
-            if (exc == CANCELLED)
+            if (exc instanceof CancellationException)
                 throw new CancellationException();
             throw new ExecutionException(exc);
         }
@@ -197,7 +195,7 @@
                 if (!latch.await(timeout, unit)) throw new TimeoutException();
         }
         if (exc != null) {
-            if (exc == CANCELLED)
+            if (exc instanceof CancellationException)
                 throw new CancellationException();
             throw new ExecutionException(exc);
         }
@@ -205,7 +203,7 @@
     }
 
     Throwable exception() {
-        return (exc != CANCELLED) ? exc : null;
+        return (exc instanceof CancellationException) ? null : exc;
     }
 
     V value() {
@@ -214,7 +212,7 @@
 
     @Override
     public boolean isCancelled() {
-        return (exc == CANCELLED);
+        return (exc instanceof CancellationException);
     }
 
     @Override
@@ -233,7 +231,7 @@
                 ((Cancellable)channel()).onCancel(this);
 
             // set result and cancel timer
-            exc = CANCELLED;
+            exc = new CancellationException();
             haveResult = true;
             if (timeoutTask != null)
                 timeoutTask.cancel(false);
--- a/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -113,7 +113,6 @@
 
         try {
             Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1);
-            // Cannot generate key here, please don't use Cipher.UNWRAP_MODE!
             cipher.init(Cipher.UNWRAP_MODE, privateKey,
                     new TlsRsaPremasterSecretParameterSpec(
                             maxVersion.v, currentVersion.v),
--- a/src/share/classes/sun/swing/SwingUtilities2.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/classes/sun/swing/SwingUtilities2.java	Thu May 01 14:21:29 2014 -0700
@@ -25,13 +25,11 @@
 
 package sun.swing;
 
-import java.security.*;
 import java.lang.reflect.*;
 import java.awt.*;
 import static java.awt.RenderingHints.*;
 import java.awt.event.*;
 import java.awt.font.*;
-import java.awt.geom.*;
 import java.awt.print.PrinterGraphics;
 import java.text.CharacterIterator;
 import java.text.AttributedCharacterIterator;
@@ -48,11 +46,8 @@
 import javax.swing.tree.TreeModel;
 import javax.swing.tree.TreePath;
 
-import sun.swing.PrintColorUIResource;
-import sun.swing.ImageIconUIResource;
 import sun.print.ProxyPrintGraphics;
 import sun.awt.*;
-import sun.security.action.GetPropertyAction;
 import java.io.*;
 import java.util.*;
 import sun.font.FontDesignMetrics;
@@ -924,6 +919,77 @@
         return retVal;
     }
 
+    /**
+     * This method should be used for drawing a borders over a filled rectangle.
+     * Draws vertical line, using the current color, between the points {@code
+     * (x, y1)} and {@code (x, y2)} in graphics context's coordinate system.
+     * Note: it use {@code Graphics.fillRect()} internally.
+     *
+     * @param g  Graphics to draw the line to.
+     * @param x  the <i>x</i> coordinate.
+     * @param y1 the first point's <i>y</i> coordinate.
+     * @param y2 the second point's <i>y</i> coordinate.
+     */
+    public static void drawVLine(Graphics g, int x, int y1, int y2) {
+        if (y2 < y1) {
+            final int temp = y2;
+            y2 = y1;
+            y1 = temp;
+        }
+        g.fillRect(x, y1, 1, y2 - y1 + 1);
+    }
+
+    /**
+     * This method should be used for drawing a borders over a filled rectangle.
+     * Draws horizontal line, using the current color, between the points {@code
+     * (x1, y)} and {@code (x2, y)} in graphics context's coordinate system.
+     * Note: it use {@code Graphics.fillRect()} internally.
+     *
+     * @param g  Graphics to draw the line to.
+     * @param x1 the first point's <i>x</i> coordinate.
+     * @param x2 the second point's <i>x</i> coordinate.
+     * @param y  the <i>y</i> coordinate.
+     */
+    public static void drawHLine(Graphics g, int x1, int x2, int y) {
+        if (x2 < x1) {
+            final int temp = x2;
+            x2 = x1;
+            x1 = temp;
+        }
+        g.fillRect(x1, y, x2 - x1 + 1, 1);
+    }
+
+    /**
+     * This method should be used for drawing a borders over a filled rectangle.
+     * Draws the outline of the specified rectangle. The left and right edges of
+     * the rectangle are at {@code x} and {@code x + w}. The top and bottom
+     * edges are at {@code y} and {@code y + h}. The rectangle is drawn using
+     * the graphics context's current color. Note: it use {@code
+     * Graphics.fillRect()} internally.
+     *
+     * @param g Graphics to draw the rectangle to.
+     * @param x the <i>x</i> coordinate of the rectangle to be drawn.
+     * @param y the <i>y</i> coordinate of the rectangle to be drawn.
+     * @param w the w of the rectangle to be drawn.
+     * @param h the h of the rectangle to be drawn.
+     * @see SwingUtilities2#drawVLine(java.awt.Graphics, int, int, int)
+     * @see SwingUtilities2#drawHLine(java.awt.Graphics, int, int, int)
+     */
+    public static void drawRect(Graphics g, int x, int y, int w, int h) {
+        if (w < 0 || h < 0) {
+            return;
+        }
+
+        if (h == 0 || w == 0) {
+            g.fillRect(x, y, w + 1, h + 1);
+        } else {
+            g.fillRect(x, y, w, 1);
+            g.fillRect(x + w, y, 1, h);
+            g.fillRect(x + 1, y + h, w, 1);
+            g.fillRect(x, y + 1, 1, h);
+        }
+    }
+
     private static TextLayout createTextLayout(JComponent c, String s,
                                             Font f, FontRenderContext frc) {
         Object shaper = (c == null ?
--- a/src/share/native/sun/java2d/loops/TransformHelper.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/native/sun/java2d/loops/TransformHelper.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -384,6 +384,7 @@
         return;
     }
     Region_IntersectBounds(&clipInfo, &dstInfo.bounds);
+    Transform_GetInfo(env, itxform, &itxInfo);
 
     numedges = (((jlong) dstInfo.bounds.y2) - ((jlong) dstInfo.bounds.y1));
     if (numedges <= 0) {
@@ -423,7 +424,6 @@
         return;
     }
 
-    Transform_GetInfo(env, itxform, &itxInfo);
 
     if (!Region_IsEmpty(&clipInfo)) {
         srcOps->GetRasInfo(env, srcOps, &srcInfo);
--- a/src/share/native/sun/java2d/opengl/OGLSurfaceData.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/share/native/sun/java2d/opengl/OGLSurfaceData.c	Thu May 01 14:21:29 2014 -0700
@@ -543,7 +543,9 @@
     }
 
     JNU_SetFieldByName(env, NULL, sdObject, "nativeWidth", "I", width);
-    JNU_SetFieldByName(env, NULL, sdObject, "nativeHeight", "I", height);
+    if (!((*env)->ExceptionOccurred(env))) {
+        JNU_SetFieldByName(env, NULL, sdObject, "nativeHeight", "I", height);
+    }
 
     (*env)->DeleteLocalRef(env, sdObject);
 }
--- a/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Thu May 01 14:21:29 2014 -0700
@@ -548,6 +548,7 @@
         }
     }
 
+    @SuppressWarnings("fallthrough")
     public void handleEvent(java.awt.AWTEvent e) {
         if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() && target.isEnabled())  {
             if (e instanceof MouseEvent) {
--- a/src/solaris/classes/sun/awt/X11/XWM.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/classes/sun/awt/X11/XWM.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1112,6 +1112,7 @@
      * Therefore, a compound state is just ICONIFIED | anything else.
      *
      */
+    @SuppressWarnings("fallthrough")
     boolean supportsExtendedState(int state) {
         switch (state) {
           case Frame.MAXIMIZED_VERT:
@@ -1131,6 +1132,7 @@
                       return true;
                   }
               }
+              /* FALLTROUGH */
           default:
               return false;
         }
--- a/src/solaris/native/sun/awt/CUPSfuncs.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/CUPSfuncs.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -213,6 +213,8 @@
 
     name = (*env)->GetStringUTFChars(env, printer, NULL);
     if (name == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not create printer name");
         return NULL;
     }
 
@@ -220,12 +222,10 @@
     // unlink() must be caled to remove the file when finished using it.
     filename = j2d_cupsGetPPD(name);
     (*env)->ReleaseStringUTFChars(env, printer, name);
+    CHECK_NULL_RETURN(filename, NULL);
 
     cls = (*env)->FindClass(env, "java/lang/String");
-
-    if (filename == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(cls, NULL);
 
     if ((ppd = j2d_ppdOpenFile(filename)) == NULL) {
         unlink(filename);
@@ -249,6 +249,7 @@
             unlink(filename);
             j2d_ppdClose(ppd);
             DPRINTF("CUPSfuncs::bad alloc new array\n", "")
+            (*env)->ExceptionClear(env);
             JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
             return NULL;
         }
@@ -323,6 +324,11 @@
     ppd_size_t *size;
 
     const char *name = (*env)->GetStringUTFChars(env, printer, NULL);
+    if (name == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not create printer name");
+        return NULL;
+    }
     const char *filename;
     int i;
     jobjectArray sizeArray = NULL;
@@ -332,9 +338,7 @@
     // unlink() must be called to remove the file after using it.
     filename = j2d_cupsGetPPD(name);
     (*env)->ReleaseStringUTFChars(env, printer, name);
-    if (filename == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(filename, NULL);
     if ((ppd = j2d_ppdOpenFile(filename)) == NULL) {
         unlink(filename);
         DPRINTF("unable to open PPD  %s\n", filename)
@@ -350,11 +354,19 @@
             unlink(filename);
             j2d_ppdClose(ppd);
             DPRINTF("CUPSfuncs::bad alloc new float array\n", "")
+            (*env)->ExceptionClear(env);
             JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
             return NULL;
         }
 
         dims = (*env)->GetFloatArrayElements(env, sizeArray, NULL);
+        if (dims == NULL) {
+            unlink(filename);
+            j2d_ppdClose(ppd);
+            (*env)->ExceptionClear(env);
+            JNU_ThrowOutOfMemoryError(env, "Could not create printer name");
+            return NULL;
+        }
         for (i = 0; i<option->num_choices; i++) {
             choice = (option->choices)+i;
             size = j2d_ppdPageSize(ppd, choice->choice);
--- a/src/solaris/native/sun/awt/X11Color.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/X11Color.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -892,11 +892,10 @@
     jmethodID mid;
 
     clazz = (*env)->FindClass(env,"java/awt/color/ColorSpace");
+    CHECK_NULL_RETURN(clazz, NULL);
     mid = (*env)->GetStaticMethodID(env, clazz, "getInstance",
                                     "(I)Ljava/awt/color/ColorSpace;");
-    if (mid == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(mid, NULL);
 
     /* SECURITY: This is safe, because static methods cannot
      *           be overridden, and this method does not invoke
@@ -919,6 +918,11 @@
         (aData->awt_depth >= 15))
     {
         clazz = (*env)->FindClass(env,"java/awt/image/DirectColorModel");
+        if (clazz == NULL) {
+            (*env)->PopLocalFrame(env, 0);
+            return NULL;
+        }
+
         if (!aData->isTranslucencySupported) {
 
             mid = (*env)->GetMethodID(env,clazz,"<init>","(IIIII)V");
@@ -1005,6 +1009,10 @@
         }
 
         clazz = (*env)->FindClass(env,"java/awt/image/ComponentColorModel");
+        if (clazz == NULL) {
+            (*env)->PopLocalFrame(env, 0);
+            return NULL;
+        }
 
         mid = (*env)->GetMethodID(env,clazz,"<init>",
             "(Ljava/awt/color/ColorSpace;[IZZII)V");
@@ -1253,6 +1261,7 @@
     if (!JNU_IsNull(env,this))
     {
         SYSCLR_class = (*env)->FindClass(env, "java/awt/SystemColor");
+        CHECK_NULL_RETURN(SYSCLR_class, 0);
 
         if ((*env)->IsInstanceOf(env, this, SYSCLR_class)) {
                 /* SECURITY: This is safe, because there is no way
@@ -1264,6 +1273,7 @@
                                           ,this
                                           ,"getRGB"
                                           ,"()I").i;
+                JNU_CHECK_EXCEPTION_RETURN(env, 0);
         } else {
                 col = (int)(*env)->GetIntField(env,this,colorValueID);
         }
@@ -1370,6 +1380,8 @@
             AWT_UNLOCK ();
         }
         sysColors = (*env)->FindClass (env, "java/awt/SystemColor");
+        CHECK_NULL(sysColors);
+
         if (lock) {
             AWT_LOCK ();
         }
@@ -1377,6 +1389,13 @@
                                                    "systemColors",
                                                    "[I");
 
+        if (colorID == NULL) {
+            if (lock) {
+                AWT_UNLOCK();
+            }
+            return;
+        }
+
         colors = (jintArray) (*env)->GetStaticObjectField
                                                 (env, sysColors, colorID);
 
--- a/src/solaris/native/sun/awt/awt.h	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt.h	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,8 +77,22 @@
 
 #define AWT_LOCK_IMPL() \
     (*env)->CallStaticVoidMethod(env, tkClass, awtLockMID)
+
 #define AWT_NOFLUSH_UNLOCK_IMPL() \
-    (*env)->CallStaticVoidMethod(env, tkClass, awtUnlockMID)
+    do { \
+      jthrowable pendingException; \
+      if ((pendingException = (*env)->ExceptionOccurred(env)) != NULL) { \
+         (*env)->ExceptionClear(env); \
+      } \
+      (*env)->CallStaticVoidMethod(env, tkClass, awtUnlockMID); \
+      if (pendingException) { \
+         if ((*env)->ExceptionCheck(env)) { \
+            (*env)->ExceptionDescribe(env); \
+            (*env)->ExceptionClear(env); \
+         } \
+         (*env)->Throw(env, pendingException); \
+      } \
+    } while (0)
 #define AWT_WAIT_IMPL(tm) \
     (*env)->CallStaticVoidMethod(env, tkClass, awtWaitMID, (jlong)(tm))
 #define AWT_NOTIFY_IMPL() \
--- a/src/solaris/native/sun/awt/awt_AWTEvent.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_AWTEvent.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,22 +49,22 @@
 JNIEXPORT void JNICALL
 Java_java_awt_AWTEvent_initIDs(JNIEnv *env, jclass cls)
 {
-    awtEventIDs.bdata = (*env)->GetFieldID(env, cls, "bdata", "[B");
-    awtEventIDs.consumed = (*env)->GetFieldID(env, cls, "consumed", "Z");
-    awtEventIDs.id = (*env)->GetFieldID(env, cls, "id", "I");
+    CHECK_NULL(awtEventIDs.bdata = (*env)->GetFieldID(env, cls, "bdata", "[B"));
+    CHECK_NULL(awtEventIDs.consumed = (*env)->GetFieldID(env, cls, "consumed", "Z"));
+    CHECK_NULL(awtEventIDs.id = (*env)->GetFieldID(env, cls, "id", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_event_InputEvent_initIDs(JNIEnv *env, jclass cls)
 {
-    inputEventIDs.modifiers = (*env)->GetFieldID(env, cls, "modifiers", "I");
+    CHECK_NULL(inputEventIDs.modifiers = (*env)->GetFieldID(env, cls, "modifiers", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_event_KeyEvent_initIDs(JNIEnv *env, jclass cls)
 {
-    keyEventIDs.keyCode = (*env)->GetFieldID(env, cls, "keyCode", "I");
-    keyEventIDs.keyChar = (*env)->GetFieldID(env, cls, "keyChar", "C");
+    CHECK_NULL(keyEventIDs.keyCode = (*env)->GetFieldID(env, cls, "keyCode", "I"));
+    CHECK_NULL(keyEventIDs.keyChar = (*env)->GetFieldID(env, cls, "keyChar", "C"));
 }
 
 JNIEXPORT void JNICALL
--- a/src/solaris/native/sun/awt/awt_DrawingSurface.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_DrawingSurface.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -78,6 +78,8 @@
 
     /* Make sure the target is a java.awt.Component */
     componentClass = (*env)->FindClass(env, "java/awt/Component");
+    CHECK_NULL_RETURN(componentClass, (jint)JAWT_LOCK_ERROR);
+
     if (!(*env)->IsInstanceOf(env, target, componentClass)) {
 #ifdef DEBUG
             fprintf(stderr, "Target is not a component\n");
@@ -126,6 +128,8 @@
 
     /* Make sure the target is a java.awt.Component */
     componentClass = (*env)->FindClass(env, "java/awt/Component");
+    CHECK_NULL_RETURN(componentClass, (int32_t) 0);
+
     if (!(*env)->IsInstanceOf(env, target, componentClass)) {
 #ifdef DEBUG
         fprintf(stderr, "DrawingSurface target must be a component\n");
@@ -195,6 +199,8 @@
 
     /* Make sure the target is a java.awt.Component */
     componentClass = (*env)->FindClass(env, "java/awt/Component");
+    CHECK_NULL_RETURN(componentClass, NULL);
+
     if (!(*env)->IsInstanceOf(env, target, componentClass)) {
 #ifdef DEBUG
         fprintf(stderr, "DrawingSurface target must be a component\n");
@@ -292,6 +298,8 @@
 
     /* Make sure the target component is a java.awt.Component */
     componentClass = (*env)->FindClass(env, "java/awt/Component");
+    CHECK_NULL_RETURN(componentClass, NULL);
+
     if (!(*env)->IsInstanceOf(env, target, componentClass)) {
 #ifdef DEBUG
         fprintf(stderr,
@@ -354,6 +362,10 @@
     if (window != None) {
         peer = JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit",
             "windowToXWindow", "(J)Lsun/awt/X11/XBaseWindow;", (jlong)window).l;
+        if ((*env)->ExceptionCheck(env)) {
+            AWT_UNLOCK();
+            return (jobject)NULL;
+        }
     }
     if ((peer != NULL) &&
         (JNU_IsInstanceOfByName(env, peer, "sun/awt/X11/XWindow") == 1)) {
@@ -361,6 +373,7 @@
     }
 
     if (target == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "NullPointerException");
         AWT_UNLOCK();
         return (jobject)NULL;
--- a/src/solaris/native/sun/awt/awt_Font.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_Font.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -86,14 +86,13 @@
 #ifndef HEADLESS
     /** We call "NoClientCode" methods because they won't invoke client
         code on the privileged toolkit thread **/
-    fontIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J");
-    fontIDs.style = (*env)->GetFieldID(env, cls, "style", "I");
-    fontIDs.size = (*env)->GetFieldID(env, cls, "size", "I");
-    fontIDs.getPeer = (*env)->GetMethodID(env, cls, "getPeer_NoClientCode",
-                                           "()Ljava/awt/peer/FontPeer;");
-    fontIDs.getFamily =
-      (*env)->GetMethodID(env, cls, "getFamily_NoClientCode",
-                                            "()Ljava/lang/String;");
+    CHECK_NULL(fontIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J"));
+    CHECK_NULL(fontIDs.style = (*env)->GetFieldID(env, cls, "style", "I"));
+    CHECK_NULL(fontIDs.size = (*env)->GetFieldID(env, cls, "size", "I"));
+    CHECK_NULL(fontIDs.getPeer = (*env)->GetMethodID(env, cls, "getPeer_NoClientCode",
+                                                     "()Ljava/awt/peer/FontPeer;"));
+    CHECK_NULL(fontIDs.getFamily = (*env)->GetMethodID(env, cls, "getFamily_NoClientCode",
+                                                       "()Ljava/lang/String;"));
 #endif /* !HEADLESS */
 }
 
@@ -120,12 +119,10 @@
   (JNIEnv *env, jclass cls)
 {
 #ifndef HEADLESS
-    fontDescriptorIDs.nativeName =
-      (*env)->GetFieldID(env, cls, "nativeName",
-                         "Ljava/lang/String;");
-    fontDescriptorIDs.charsetName =
-      (*env)->GetFieldID(env, cls, "charsetName",
-                         "Ljava/lang/String;");
+    CHECK_NULL(fontDescriptorIDs.nativeName =
+               (*env)->GetFieldID(env, cls, "nativeName", "Ljava/lang/String;"));
+    CHECK_NULL(fontDescriptorIDs.charsetName =
+               (*env)->GetFieldID(env, cls, "charsetName", "Ljava/lang/String;"));
 #endif /* !HEADLESS */
 }
 
@@ -144,20 +141,18 @@
   (JNIEnv *env, jclass cls)
 {
 #ifndef HEADLESS
-    platformFontIDs.componentFonts =
-      (*env)->GetFieldID(env, cls, "componentFonts",
-                         "[Lsun/awt/FontDescriptor;");
-    platformFontIDs.fontConfig =
-      (*env)->GetFieldID(env,cls, "fontConfig",
-                         "Lsun/awt/FontConfiguration;");
-
-    platformFontIDs.makeConvertedMultiFontString =
-      (*env)->GetMethodID(env, cls, "makeConvertedMultiFontString",
-                          "(Ljava/lang/String;)[Ljava/lang/Object;");
-
-    platformFontIDs.makeConvertedMultiFontChars =
-      (*env)->GetMethodID(env, cls, "makeConvertedMultiFontChars",
-                          "([CII)[Ljava/lang/Object;");
+    CHECK_NULL(platformFontIDs.componentFonts =
+               (*env)->GetFieldID(env, cls, "componentFonts",
+                                  "[Lsun/awt/FontDescriptor;"));
+    CHECK_NULL(platformFontIDs.fontConfig =
+               (*env)->GetFieldID(env,cls, "fontConfig",
+                                  "Lsun/awt/FontConfiguration;"));
+    CHECK_NULL(platformFontIDs.makeConvertedMultiFontString =
+               (*env)->GetMethodID(env, cls, "makeConvertedMultiFontString",
+                                   "(Ljava/lang/String;)[Ljava/lang/Object;"));
+    CHECK_NULL(platformFontIDs.makeConvertedMultiFontChars =
+               (*env)->GetMethodID(env, cls, "makeConvertedMultiFontChars",
+                                   "([CII)[Ljava/lang/Object;"));
 #endif /* !HEADLESS */
 }
 
@@ -385,6 +380,11 @@
         return 0;
     }
     cname = (char *) JNU_GetStringPlatformChars(env, name, NULL);
+    if (cname == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not create font name");
+        return 0;
+    }
 
     /* additional default font names */
     if (strcmp(cname, "serif") == 0) {
@@ -448,6 +448,8 @@
     }
 
     if (!JNU_IsNull(env, font) && awtJNI_IsMultiFont(env, font)) {
+        JNU_CHECK_EXCEPTION_RETURN(env, NULL);
+
         struct FontData *fdata = NULL;
         int32_t i, size;
         char *fontsetname = NULL;
@@ -492,7 +494,12 @@
 
             if (!JNU_IsNull(env, fontDescriptorName)) {
                 nativename = (char *) JNU_GetStringPlatformChars(env, fontDescriptorName, NULL);
-                doFree = TRUE;
+                if (nativename == NULL) {
+                    nativename = "";
+                    doFree = FALSE;
+                } else {
+                    doFree = TRUE;
+                }
             } else {
                 nativename = "";
                 doFree = FALSE;
@@ -516,6 +523,11 @@
 
             fdata->flist[i].charset_name = (char *)
                 JNU_GetStringPlatformChars(env, charsetName, NULL);
+            if (fdata->flist[i].charset_name == NULL) {
+                (*env)->ExceptionClear(env);
+                JNU_ThrowOutOfMemoryError(env, "Could not create charset name");
+                return NULL;
+            }
 
             /* We are done with the objects. */
             (*env)->DeleteLocalRef(env, fontDescriptor);
@@ -543,6 +555,19 @@
                     fdata->xfont = fdata->flist[i].xfont;
                     fdata->flist[i].index_length = 1;
                 } else {
+                    /* Free any already allocated storage and fonts */
+                    int j = i;
+                    for (j = 0; j <= i; j++) {
+                        free((void *)fdata->flist[j].xlfd);
+                        JNU_ReleaseStringPlatformChars(env, NULL,
+                            fdata->flist[j].charset_name);
+                        if (fdata->flist[j].load) {
+                            XFreeFont(awt_display, fdata->flist[j].xfont);
+                        }
+                    }
+                    free((void *)fdata->flist);
+                    free((void *)fdata);
+
                     if (errmsg != NULL) {
                         *errmsg = "java/lang" "NullPointerException";
                     }
--- a/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -152,8 +152,11 @@
     x11GraphicsConfigIDs.screen = NULL;
 
     x11GraphicsConfigIDs.aData = (*env)->GetFieldID (env, cls, "aData", "J");
+    CHECK_NULL(x11GraphicsConfigIDs.aData);
     x11GraphicsConfigIDs.bitsPerPixel = (*env)->GetFieldID (env, cls, "bitsPerPixel", "I");
+    CHECK_NULL(x11GraphicsConfigIDs.bitsPerPixel);
     x11GraphicsConfigIDs.screen = (*env)->GetFieldID (env, cls, "screen", "Lsun/awt/X11GraphicsDevice;");
+    CHECK_NULL(x11GraphicsConfigIDs.screen);
 
     if (x11GraphicsConfigIDs.aData == NULL ||
             x11GraphicsConfigIDs.bitsPerPixel == NULL ||
@@ -1346,7 +1349,6 @@
 
     /* Make Color Model object for this GraphicsConfiguration */
     colorModel = awtJNI_GetColorModel (env, adata);
-
     AWT_UNLOCK ();
 
     return colorModel;
@@ -1374,6 +1376,7 @@
         JNU_GetLongFieldAsPtr(env, this, x11GraphicsConfigIDs.aData);
 
     clazz = (*env)->FindClass(env, "java/awt/Rectangle");
+    CHECK_NULL_RETURN(clazz, NULL);
     mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
     if (mid != NULL) {
         if (usingXinerama) {
@@ -1543,7 +1546,7 @@
     clazz = (*env)->GetObjectClass(env, this);
     midAddVisual = (*env)->GetMethodID(env, clazz, "addDoubleBufferVisual",
         "(I)V");
-
+    CHECK_NULL(midAddVisual);
     AWT_LOCK();
     rootWindow = RootWindow(awt_display, xinawareScreen);
     visScreenInfo = XdbeGetVisualInfo(awt_display, &rootWindow, &n);
@@ -1739,6 +1742,7 @@
     jint validRefreshRate = refreshRate;
 
     displayModeClass = (*env)->FindClass(env, "java/awt/DisplayMode");
+    CHECK_NULL_RETURN(displayModeClass, NULL);
     if (JNU_IsNull(env, displayModeClass)) {
         JNU_ThrowInternalError(env,
                                "Could not get display mode class");
@@ -1746,6 +1750,7 @@
     }
 
     cid = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V");
+    CHECK_NULL_RETURN(cid, NULL);
     if (cid == NULL) {
         JNU_ThrowInternalError(env,
                                "Could not get display mode constructor");
@@ -1779,6 +1784,7 @@
         }
         mid = (*env)->GetMethodID(env, arrayListClass, "add",
                                   "(Ljava/lang/Object;)Z");
+        CHECK_NULL(mid);
         if (mid == NULL) {
             JNU_ThrowInternalError(env,
                 "Could not get method java.util.ArrayList.add()");
@@ -1955,6 +1961,9 @@
                                          size.height,
                                          BIT_DEPTH_MULTI,
                                          rates[j]);
+                    if ((*env)->ExceptionCheck(env)) {
+                        break;
+                    }
                 }
             }
         }
--- a/src/solaris/native/sun/awt/awt_InputMethod.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_InputMethod.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -319,6 +319,7 @@
         JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
                              "flushText",
                              "()V");
+        JNU_CHECK_EXCEPTION_RETURN(env, NULL);
         /* IMPORTANT:
            The order of the following calls is critical since "imInstance" may
            point to the global reference itself, if "freeX11InputMethodData" is called
@@ -1120,6 +1121,9 @@
         if (text->string.multi_byte != NULL) {
             if (pre_draw->text->encoding_is_wchar == False) {
                 javastr = JNU_NewStringPlatform(env, (const char *)text->string.multi_byte);
+                if (javastr == NULL) {
+                    goto finally;
+                }
             } else {
                 char *mbstr = wcstombsdmp(text->string.wide_char, text->length);
                 if (mbstr == NULL) {
@@ -1127,6 +1131,9 @@
                 }
                 javastr = JNU_NewStringPlatform(env, (const char *)mbstr);
                 free(mbstr);
+                if (javastr == NULL) {
+                    goto finally;
+                }
             }
         }
         if (text->feedback != NULL) {
@@ -1135,6 +1142,7 @@
 
             style = (*env)->NewIntArray(env, text->length);
             if (JNU_IsNull(env, style)) {
+                (*env)->ExceptionClear(env);
                 THROW_OUT_OF_MEMORY_ERROR();
                 goto finally;
             }
@@ -1395,14 +1403,17 @@
     pX11IMData->lookup_buf = 0;
     pX11IMData->lookup_buf_len = 0;
 
-    if (createXIC(env, pX11IMData, (Window)window)
-        == False) {
+    if (createXIC(env, pX11IMData, (Window)window) == False) {
         destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
         pX11IMData = (X11InputMethodData *) NULL;
+        if ((*env)->ExceptionCheck(env)) {
+            goto finally;
+        }
     }
 
     setX11InputMethodData(env, this, pX11IMData);
 
+finally:
     AWT_UNLOCK();
     return (pX11IMData != NULL);
 }
--- a/src/solaris/native/sun/awt/awt_Insets.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_Insets.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,8 @@
 JNIEXPORT void JNICALL
 Java_java_awt_Insets_initIDs(JNIEnv *env, jclass cls)
 {
-    insetsIDs.top = (*env)->GetFieldID(env, cls, "top", "I");
-    insetsIDs.bottom = (*env)->GetFieldID(env, cls, "bottom", "I");
-    insetsIDs.left = (*env)->GetFieldID(env, cls, "left", "I");
-    insetsIDs.right = (*env)->GetFieldID(env, cls, "right", "I");
+    CHECK_NULL(insetsIDs.top = (*env)->GetFieldID(env, cls, "top", "I"));
+    CHECK_NULL(insetsIDs.bottom = (*env)->GetFieldID(env, cls, "bottom", "I"));
+    CHECK_NULL(insetsIDs.left = (*env)->GetFieldID(env, cls, "left", "I"));
+    CHECK_NULL(insetsIDs.right = (*env)->GetFieldID(env, cls, "right", "I"));
 }
--- a/src/solaris/native/sun/awt/awt_LoadLibrary.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_LoadLibrary.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,11 +77,16 @@
     return isHeadless;
 }
 
+#define CHECK_EXCEPTION_FATAL(env, message) \
+    if ((*env)->ExceptionCheck(env)) { \
+        (*env)->ExceptionClear(env); \
+        (*env)->FatalError(env, message); \
+    }
+
 /*
  * Pathnames to the various awt toolkits
  */
 
-
 #ifdef MACOSX
   #define LWAWT_PATH "/libawt_lwawt.dylib"
   #define DEFAULT_PATH LWAWT_PATH
@@ -125,6 +130,8 @@
      */
 
     fmProp = (*env)->NewStringUTF(env, "sun.font.fontmanager");
+    CHECK_EXCEPTION_FATAL(env, "Could not allocate font manager property");
+
 #ifdef MACOSX
         fmanager = (*env)->NewStringUTF(env, "sun.font.CFontManager");
         tk = LWAWT_PATH;
@@ -132,10 +139,13 @@
         fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager");
         tk = XAWT_PATH;
 #endif
+    CHECK_EXCEPTION_FATAL(env, "Could not allocate font manager name");
+
     if (fmanager && fmProp) {
         JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "setProperty",
                                    "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
                                    fmProp, fmanager);
+        CHECK_EXCEPTION_FATAL(env, "Could not allocate set properties");
     }
 
 #ifndef MACOSX
@@ -154,9 +164,11 @@
         (*env)->DeleteLocalRef(env, fmanager);
     }
 
+    jstring jbuf = JNU_NewStringPlatform(env, buf);
+    CHECK_EXCEPTION_FATAL(env, "Could not allocate library name");
     JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "load",
                                "(Ljava/lang/String;)V",
-                               JNU_NewStringPlatform(env, buf));
+                               jbuf);
 
     awtHandle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
 
--- a/src/solaris/native/sun/awt/awt_Robot.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_Robot.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,10 +175,13 @@
 
     num_buttons = numberOfButtons;
     tmp = (*env)->GetIntArrayElements(env, buttonDownMasks, JNI_FALSE);
+    CHECK_NULL(tmp);
+
     masks = (jint *)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(jint), num_buttons);
     if (masks == (jint *) NULL) {
+        (*env)->ExceptionClear(env);
+        (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
         JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
-        (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
         return;
     }
     for (i = 0; i < num_buttons; i++) {
--- a/src/solaris/native/sun/awt/awt_UNIXToolkit.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_UNIXToolkit.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -98,6 +98,7 @@
                                           (*env)->GetObjectClass(env, this));
         icon_upcall_method = (*env)->GetMethodID(env, this_class,
                                  "loadIconCallback", "([BIIIIIZ)V");
+        CHECK_NULL_RETURN(icon_upcall_method, JNI_FALSE);
     }
 
     if (pixbuf != NULL)
@@ -112,6 +113,8 @@
 
         /* Copy the data array into a Java structure so we can pass it back. */
         jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
+        JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
+
         (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
                                    (jbyte *)pixbuf_data);
 
--- a/src/solaris/native/sun/awt/awt_util.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_util.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,7 @@
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
-void
+jboolean
 awtJNI_ThreadYield(JNIEnv *env) {
 
     static jclass threadClass = NULL;
@@ -76,6 +76,7 @@
         Boolean err = FALSE;
         if (threadClass == NULL) {
             jclass tc = (*env)->FindClass(env, "java/lang/Thread");
+            CHECK_NULL_RETURN(tc, JNI_FALSE);
             threadClass = (*env)->NewGlobalRef(env, tc);
             (*env)->DeleteLocalRef(env, tc);
             if (threadClass != NULL) {
@@ -91,10 +92,11 @@
             err = TRUE;
         }
         if (err) {
-            return;
+            return JNI_FALSE;
         }
     } /* threadClass == NULL*/
 
     (*env)->CallStaticVoidMethod(env, threadClass, yieldMethodID);
     DASSERT(!((*env)->ExceptionOccurred(env)));
+    return JNI_TRUE;
 } /* awtJNI_ThreadYield() */
--- a/src/solaris/native/sun/awt/awt_util.h	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/awt_util.h	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -78,7 +78,7 @@
     int32_t echoC;
 };
 
-extern void awtJNI_ThreadYield(JNIEnv *env);
+extern jboolean awtJNI_ThreadYield(JNIEnv *env);
 
 /*
  * Functions for accessing fields by name and signature
--- a/src/solaris/native/sun/awt/fontpath.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/fontpath.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -161,17 +161,22 @@
 
     if (! isLocalSet) {
       jclass geCls = (*env)->FindClass(env, "java/awt/GraphicsEnvironment");
+      CHECK_NULL_RETURN(geCls, JNI_FALSE);
       jmethodID getLocalGE = (*env)->GetStaticMethodID(env, geCls,
                                                  "getLocalGraphicsEnvironment",
                                            "()Ljava/awt/GraphicsEnvironment;");
+      CHECK_NULL_RETURN(getLocalGE, JNI_FALSE);
       jobject ge = (*env)->CallStaticObjectMethod(env, geCls, getLocalGE);
+      JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
 
       jclass sgeCls = (*env)->FindClass(env,
                                         "sun/java2d/SunGraphicsEnvironment");
+      CHECK_NULL_RETURN(sgeCls, JNI_FALSE);
       if ((*env)->IsInstanceOf(env, ge, sgeCls)) {
         jmethodID isDisplayLocal = (*env)->GetMethodID(env, sgeCls,
                                                        "isDisplayLocal",
                                                        "()Z");
+        JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
         isLocal = (*env)->CallBooleanMethod(env, ge, isDisplayLocal);
       } else {
         isLocal = True;
@@ -1005,50 +1010,38 @@
     jmethodID fcFontCons;
     char* debugMinGlyphsStr = getenv("J2D_DEBUG_MIN_GLYPHS");
 
+    CHECK_NULL(fcInfoObj);
+    CHECK_NULL(fcCompFontArray);
+
     jclass fcInfoClass =
         (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigInfo");
+    CHECK_NULL(fcInfoClass);
     jclass fcCompFontClass =
         (*env)->FindClass(env, "sun/font/FontConfigManager$FcCompFont");
+    CHECK_NULL(fcCompFontClass);
     jclass fcFontClass =
          (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigFont");
-
-    if (fcInfoObj == NULL || fcCompFontArray == NULL || fcInfoClass == NULL ||
-        fcCompFontClass == NULL || fcFontClass == NULL) {
-        return;
-    }
-
-    fcVersionID = (*env)->GetFieldID(env, fcInfoClass, "fcVersion", "I");
+    CHECK_NULL(fcFontClass);
 
-    fcCacheDirsID = (*env)->GetFieldID(env, fcInfoClass, "cacheDirs",
-                                       "[Ljava/lang/String;");
-
-    fcNameID = (*env)->GetFieldID(env, fcCompFontClass,
-                                  "fcName", "Ljava/lang/String;");
-    fcFirstFontID =
-        (*env)->GetFieldID(env, fcCompFontClass, "firstFont",
-                           "Lsun/font/FontConfigManager$FontConfigFont;");
 
-    fcAllFontsID =
-        (*env)->GetFieldID(env, fcCompFontClass, "allFonts",
-                           "[Lsun/font/FontConfigManager$FontConfigFont;");
-
-    fcFontCons = (*env)->GetMethodID(env, fcFontClass, "<init>", "()V");
-
-    familyNameID = (*env)->GetFieldID(env, fcFontClass,
-                                      "familyName", "Ljava/lang/String;");
-    styleNameID = (*env)->GetFieldID(env, fcFontClass,
-                                    "styleStr", "Ljava/lang/String;");
-    fullNameID = (*env)->GetFieldID(env, fcFontClass,
-                                    "fullName", "Ljava/lang/String;");
-    fontFileID = (*env)->GetFieldID(env, fcFontClass,
-                                    "fontFile", "Ljava/lang/String;");
-
-    if (fcVersionID == NULL || fcCacheDirsID == NULL || fcNameID == NULL ||
-        fcFirstFontID == NULL || fcAllFontsID == NULL || fcFontCons == NULL ||
-        familyNameID == NULL || styleNameID == NULL || fullNameID == NULL ||
-        fontFileID == NULL) {
-        return;
-    }
+    CHECK_NULL(fcVersionID = (*env)->GetFieldID(env, fcInfoClass, "fcVersion", "I"));
+    CHECK_NULL(fcCacheDirsID = (*env)->GetFieldID(env, fcInfoClass, "cacheDirs",
+                                                  "[Ljava/lang/String;"));
+    CHECK_NULL(fcNameID = (*env)->GetFieldID(env, fcCompFontClass,
+                                             "fcName", "Ljava/lang/String;"));
+    CHECK_NULL(fcFirstFontID = (*env)->GetFieldID(env, fcCompFontClass, "firstFont",
+                                        "Lsun/font/FontConfigManager$FontConfigFont;"));
+    CHECK_NULL(fcAllFontsID = (*env)->GetFieldID(env, fcCompFontClass, "allFonts",
+                                        "[Lsun/font/FontConfigManager$FontConfigFont;"));
+    CHECK_NULL(fcFontCons = (*env)->GetMethodID(env, fcFontClass, "<init>", "()V"));
+    CHECK_NULL(familyNameID = (*env)->GetFieldID(env, fcFontClass,
+                                      "familyName", "Ljava/lang/String;"));
+    CHECK_NULL(styleNameID = (*env)->GetFieldID(env, fcFontClass,
+                                    "styleStr", "Ljava/lang/String;"));
+    CHECK_NULL(fullNameID = (*env)->GetFieldID(env, fcFontClass,
+                                    "fullName", "Ljava/lang/String;"));
+    CHECK_NULL(fontFileID = (*env)->GetFieldID(env, fcFontClass,
+                                    "fontFile", "Ljava/lang/String;"));
 
     if ((libfontconfig = openFontConfig()) == NULL) {
         return;
@@ -1129,6 +1122,8 @@
         if (cacheDirs != NULL) {
             while ((cnt < max) && (cacheDir = (*FcStrListNext)(cacheDirs))) {
                 jstr = (*env)->NewStringUTF(env, (const char*)cacheDir);
+                JNU_CHECK_EXCEPTION(env);
+
                 (*env)->SetObjectArrayElement(env, cacheDirArray, cnt++, jstr);
             }
             (*FcStrListDone)(cacheDirs);
@@ -1136,6 +1131,11 @@
     }
 
     locale = (*env)->GetStringUTFChars(env, localeStr, 0);
+    if (locale == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not create locale");
+        return;
+    }
 
     arrlen = (*env)->GetArrayLength(env, fcCompFontArray);
     for (i=0; i<arrlen; i++) {
--- a/src/solaris/native/sun/awt/gtk2_interface.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/gtk2_interface.c	Thu May 01 14:21:29 2014 -0700
@@ -538,9 +538,7 @@
              fprintf(stderr, "dlsym(gtk_show_uri) returned NULL\n");
 #endif /* INTERNAL_BUILD */
         } else {
-#ifdef __solaris__
             update_supported_actions(env);
-#endif
             success = TRUE;
         }
      }
--- a/src/solaris/native/sun/awt/initIDs.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/initIDs.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,9 +47,6 @@
   (JNIEnv *env, jclass clazz)
 {
     colorValueID = (*env)->GetFieldID(env, clazz, "value", "I");
-
-    if(colorValueID == NULL)
-        JNU_ThrowNullPointerException (env, "Can't get java/awt/Color.value fieldID");
 }
 
 JNIEXPORT void JNICALL
--- a/src/solaris/native/sun/awt/multi_font.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/multi_font.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,7 @@
     jobject temp = NULL;
     jboolean validRet = JNI_FALSE;
 
-    if ((*env)->EnsureLocalCapacity(env, 2) < 0)
+    if ((*env)->EnsureLocalCapacity(env, 2) < 0 || (*env)->ExceptionCheck(env))
         goto done;
 
     peer = (*env)->CallObjectMethod(env,font,fontIDs.getPeer);
@@ -162,7 +162,7 @@
 
     font = JNU_CallMethodByName(env, NULL, this, "getFont_NoClientCode",
                                 "()Ljava/awt/Font;").l;
-    if (JNU_IsNull(env, font)) {
+    if (JNU_IsNull(env, font) || (*env)->ExceptionCheck(env)) {
         return JNI_FALSE;
     }
 
@@ -318,6 +318,10 @@
     }
 
     fdata = awtJNI_GetFontData(env, font, &err);
+    if ((*env)->ExceptionCheck(env)) {
+        (*env)->DeleteLocalRef(env, dataArray);
+        return 0;
+    }
 
     stringCount = (*env)->GetArrayLength(env, dataArray);
 
@@ -336,6 +340,11 @@
         }
 
         j = awtJNI_GetFontDescriptorNumber(env, font, fontDescriptor);
+        if ((*env)->ExceptionCheck(env)) {
+            (*env)->DeleteLocalRef(env, fontDescriptor);
+            (*env)->DeleteLocalRef(env, data);
+            break;
+        }
 
         if (fdata->flist[j].load == 0) {
             xf = loadFont(awt_display,
@@ -356,6 +365,14 @@
 
         stringData =
             (unsigned char *)(*env)->GetPrimitiveArrayCritical(env, data,NULL);
+        if (stringData == NULL) {
+            (*env)->DeleteLocalRef(env, fontDescriptor);
+            (*env)->DeleteLocalRef(env, data);
+            (*env)->ExceptionClear(env);
+            JNU_ThrowOutOfMemoryError(env, "Could not get string data");
+            break;
+        }
+
         length = (stringData[0] << 24) | (stringData[1] << 16) |
             (stringData[2] << 8) | stringData[3];
         offsetStringData = (char *)(stringData + (4 * sizeof(char)));
--- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,10 +45,12 @@
     filenameFilterCallbackMethodID = (*env)->GetMethodID(env, cx,
             "filenameFilterCallback", "(Ljava/lang/String;)Z");
     DASSERT(filenameFilterCallbackMethodID != NULL);
+    CHECK_NULL(filenameFilterCallbackMethodID);
 
     setFileInternalMethodID = (*env)->GetMethodID(env, cx,
             "setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V");
     DASSERT(setFileInternalMethodID != NULL);
+    CHECK_NULL(setFileInternalMethodID);
 
     widgetFieldID = (*env)->GetFieldID(env, cx, "widget", "J");
     DASSERT(widgetFieldID != NULL);
@@ -63,6 +65,7 @@
     env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
     filename = (*env)->NewStringUTF(env, filter_info->filename);
+    JNU_CHECK_EXCEPTION_RETURN(env, FALSE);
 
     return (*env)->CallBooleanMethod(env, obj, filenameFilterCallbackMethodID,
             filename);
@@ -173,13 +176,14 @@
 
     stringCls = (*env)->FindClass(env, "java/lang/String");
     if (stringCls == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowInternalError(env, "Could not get java.lang.String class");
         return NULL;
     }
 
-    array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
-            NULL);
+    array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls, NULL);
     if (array == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowInternalError(env, "Could not instantiate array files array");
         return NULL;
     }
@@ -189,7 +193,9 @@
         entry = (char*) iterator->data;
         entry = strrchr(entry, '/') + 1;
         str = (*env)->NewStringUTF(env, entry);
-        (*env)->SetObjectArrayElement(env, array, i, str);
+        if (str && !(*env)->ExceptionCheck(env)) {
+            (*env)->SetObjectArrayElement(env, array, i, str);
+        }
         i++;
     }
 
@@ -215,13 +221,14 @@
 
     stringCls = (*env)->FindClass(env, "java/lang/String");
     if (stringCls == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowInternalError(env, "Could not get java.lang.String class");
         return NULL;
     }
 
-    array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
-            NULL);
+    array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls, NULL);
     if (array == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowInternalError(env, "Could not instantiate array files array");
         return NULL;
     }
@@ -236,7 +243,9 @@
         }
 
         str = (*env)->NewStringUTF(env, entry);
-        (*env)->SetObjectArrayElement(env, array, i, str);
+        if (str && !(*env)->ExceptionCheck(env)) {
+            (*env)->SetObjectArrayElement(env, array, i, str);
+        }
         i++;
     }
 
@@ -268,16 +277,17 @@
     if (full_path_names) {
         //This is a hack for use with "Recent Folders" in gtk where each
         //file could have its own directory.
+        jfilenames = toPathAndFilenamesArray(env, filenames);
         jcurrent_folder = (*env)->NewStringUTF(env, "/");
-        jfilenames = toPathAndFilenamesArray(env, filenames);
     } else {
-        jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
         jfilenames = toFilenamesArray(env, filenames);
+        jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
     }
-    (*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder,
-            jfilenames);
+    if (!(*env)->ExceptionCheck(env)) {
+        (*env)->CallVoidMethod(env, obj, setFileInternalMethodID,
+                               jcurrent_folder, jfilenames);
+    }
     fp_g_free(current_folder);
-
     quit(env, (jobject)obj, TRUE);
 }
 
@@ -296,11 +306,17 @@
 
     if (jvm == NULL) {
         (*env)->GetJavaVM(env, &jvm);
+        JNU_CHECK_EXCEPTION(env);
     }
 
     fp_gdk_threads_enter();
 
     const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0);
+    if (title == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not get title");
+        return;
+    }
 
     if (mode == java_awt_FileDialog_SAVE) {
         /* Save action */
@@ -328,6 +344,11 @@
     /* Set the directory */
     if (jdir != NULL) {
         const char *dir = (*env)->GetStringUTFChars(env, jdir, 0);
+        if (dir == NULL) {
+            (*env)->ExceptionClear(env);
+            JNU_ThrowOutOfMemoryError(env, "Could not get dir");
+            return;
+        }
         fp_gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir);
         (*env)->ReleaseStringUTFChars(env, jdir, dir);
     }
@@ -335,6 +356,11 @@
     /* Set the filename */
     if (jfile != NULL) {
         const char *filename = (*env)->GetStringUTFChars(env, jfile, 0);
+        if (filename == NULL) {
+            (*env)->ExceptionClear(env);
+            JNU_ThrowOutOfMemoryError(env, "Could not get filename");
+            return;
+        }
         if (mode == java_awt_FileDialog_SAVE) {
             fp_gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
         } else {
--- a/src/solaris/native/sun/xawt/XToolkit.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/xawt/XToolkit.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,7 @@
 #include "awt_Component.h"
 #include "awt_MenuComponent.h"
 #include "awt_Font.h"
+#include "awt_util.h"
 
 #include "sun_awt_X11_XToolkit.h"
 #include "java_awt_SystemColor.h"
@@ -76,6 +77,8 @@
 #ifndef HEADLESS
 
 extern Display* awt_init_Display(JNIEnv *env, jobject this);
+extern void freeNativeStringArray(char **array, long length);
+extern char** stringArrayToNative(JNIEnv *env, jobjectArray array, jsize * ret_length);
 
 struct XFontPeerIDs xFontPeerIDs;
 
@@ -103,9 +106,11 @@
   (JNIEnv *env, jclass clazz)
 {
     jfieldID fid = (*env)->GetStaticFieldID(env, clazz, "numLockMask", "I");
+    CHECK_NULL(fid);
     awt_NumLockMask = (*env)->GetStaticIntField(env, clazz, fid);
     DTRACE_PRINTLN1("awt_NumLockMask = %u", awt_NumLockMask);
     fid = (*env)->GetStaticFieldID(env, clazz, "modLockIsShiftLock", "I");
+    CHECK_NULL(fid);
     awt_ModLockIsShiftLock = (*env)->GetStaticIntField(env, clazz, fid) != 0 ? True : False;
 }
 
@@ -173,21 +178,31 @@
 
 
     componentIDs.x = (*env)->GetFieldID(env, cls, "x", "I");
+    CHECK_NULL(componentIDs.x);
     componentIDs.y = (*env)->GetFieldID(env, cls, "y", "I");
+    CHECK_NULL(componentIDs.y);
     componentIDs.width = (*env)->GetFieldID(env, cls, "width", "I");
+    CHECK_NULL(componentIDs.width);
     componentIDs.height = (*env)->GetFieldID(env, cls, "height", "I");
+    CHECK_NULL(componentIDs.height);
     componentIDs.isPacked = (*env)->GetFieldID(env, cls, "isPacked", "Z");
+    CHECK_NULL(componentIDs.isPacked);
     componentIDs.peer =
       (*env)->GetFieldID(env, cls, "peer", "Ljava/awt/peer/ComponentPeer;");
+    CHECK_NULL(componentIDs.peer);
     componentIDs.background =
       (*env)->GetFieldID(env, cls, "background", "Ljava/awt/Color;");
+    CHECK_NULL(componentIDs.background);
     componentIDs.foreground =
       (*env)->GetFieldID(env, cls, "foreground", "Ljava/awt/Color;");
+    CHECK_NULL(componentIDs.foreground);
     componentIDs.graphicsConfig =
         (*env)->GetFieldID(env, cls, "graphicsConfig",
                            "Ljava/awt/GraphicsConfiguration;");
+    CHECK_NULL(componentIDs.graphicsConfig);
     componentIDs.name =
       (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;");
+    CHECK_NULL(componentIDs.name);
 
     /* Use _NoClientCode() methods for trusted methods, so that we
      *  know that we are not invoking client code on trusted threads
@@ -195,19 +210,20 @@
     componentIDs.getParent =
       (*env)->GetMethodID(env, cls, "getParent_NoClientCode",
                          "()Ljava/awt/Container;");
+    CHECK_NULL(componentIDs.getParent);
 
     componentIDs.getLocationOnScreen =
       (*env)->GetMethodID(env, cls, "getLocationOnScreen_NoTreeLock",
                          "()Ljava/awt/Point;");
+    CHECK_NULL(componentIDs.getLocationOnScreen);
 
     keyclass = (*env)->FindClass(env, "java/awt/event/KeyEvent");
-    if (JNU_IsNull(env, keyclass)) {
-        return;
-    }
+    CHECK_NULL(keyclass);
 
     componentIDs.isProxyActive =
         (*env)->GetFieldID(env, keyclass, "isProxyActive",
                            "Z");
+    CHECK_NULL(componentIDs.isProxyActive);
 
     componentIDs.appContext =
         (*env)->GetFieldID(env, cls, "appContext",
@@ -339,7 +355,7 @@
 static void     waitForEvents(JNIEnv *, jlong);
 static void     awt_pipe_init();
 static void     processOneEvent(XtInputMask iMask);
-static void     performPoll(JNIEnv *, jlong);
+static Boolean  performPoll(JNIEnv *, jlong);
 static void     wakeUp();
 static void     update_poll_timeout(int timeout_control);
 static uint32_t get_poll_timeout(jlong nextTaskTime);
@@ -608,11 +624,13 @@
  */
 void
 waitForEvents(JNIEnv *env, jlong nextTaskTime) {
-    performPoll(env, nextTaskTime);
-    if ((awt_next_flush_time > 0) && (awtJNI_TimeMillis() >= awt_next_flush_time)) {
-        XFlush(awt_display);
-        awt_last_flush_time = awt_next_flush_time;
-        awt_next_flush_time = 0LL;
+    if (performPoll(env, nextTaskTime)
+          && (awt_next_flush_time > 0)
+          && (awtJNI_TimeMillis() >= awt_next_flush_time)) {
+
+                XFlush(awt_display);
+                awt_last_flush_time = awt_next_flush_time;
+                awt_next_flush_time = 0LL;
     }
 } /* waitForEvents() */
 
@@ -646,7 +664,7 @@
  *
  * The fdAWTPipe will be empty when this returns.
  */
-static void
+static Boolean
 performPoll(JNIEnv *env, jlong nextTaskTime) {
     static Bool pollFdsInited = False;
     static char read_buf[AWT_POLL_BUFSIZE + 1];    /* dummy buf to empty pipe */
@@ -673,7 +691,9 @@
     /* ACTUALLY DO THE POLL() */
     if (timeout == 0) {
         // be sure other threads get a chance
-        awtJNI_ThreadYield(env);
+        if (!awtJNI_ThreadYield(env)) {
+            return FALSE;
+        }
     }
 
     if (tracing) poll_sleep_time = awtJNI_TimeMillis();
@@ -701,7 +721,7 @@
         update_poll_timeout(TIMEOUT_EVENTS);
         PRINT2("performPoll(): TIMEOUT_EVENTS curPollTimeout = %d \n", curPollTimeout);
     }
-    return;
+    return TRUE;
 
 } /* performPoll() */
 
@@ -856,23 +876,25 @@
     xawt_root_window = get_xawt_root_shell(env);
 
     if ( xawt_root_window == None ) {
+        AWT_UNLOCK();
         JNU_ThrowNullPointerException(env, "AWT root shell is unrealized");
-        AWT_UNLOCK();
         return;
     }
 
     command = (char *) JNU_GetStringPlatformChars(env, jcommand, NULL);
-    c[0] = (char *)command;
-    status = XmbTextListToTextProperty(awt_display, c, 1,
-                                       XStdICCTextStyle, &text_prop);
+    if (command != NULL) {
+        c[0] = (char *)command;
+        status = XmbTextListToTextProperty(awt_display, c, 1,
+                                           XStdICCTextStyle, &text_prop);
 
-    if (status == Success || status > 0) {
-        XSetTextProperty(awt_display, xawt_root_window,
-                         &text_prop, XA_WM_COMMAND);
-        if (text_prop.value != NULL)
-            XFree(text_prop.value);
+        if (status == Success || status > 0) {
+            XSetTextProperty(awt_display, xawt_root_window,
+                             &text_prop, XA_WM_COMMAND);
+            if (text_prop.value != NULL)
+                XFree(text_prop.value);
+        }
+        JNU_ReleaseStringPlatformChars(env, jcommand, command);
     }
-    JNU_ReleaseStringPlatformChars(env, jcommand, command);
     AWT_UNLOCK();
 }
 
@@ -886,96 +908,56 @@
  * name.  It's not!  It's just a plain function.
  */
 JNIEXPORT void JNICALL
-Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
+Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jarray)
 {
-    static const char empty[] = "";
-
-    int argc;
-    const char **cargv;
+    jsize length;
+    char ** array;
     XTextProperty text_prop;
     int status;
-    int i;
     Window xawt_root_window;
 
     AWT_LOCK();
     xawt_root_window = get_xawt_root_shell(env);
 
     if (xawt_root_window == None) {
+      AWT_UNLOCK();
       JNU_ThrowNullPointerException(env, "AWT root shell is unrealized");
-      AWT_UNLOCK();
       return;
     }
 
-    argc = (int)(*env)->GetArrayLength(env, jargv);
-    if (argc == 0) {
-        AWT_UNLOCK();
-        return;
-    }
-
-    /* array of C strings */
-    cargv = (const char **)calloc(argc, sizeof(char *));
-    if (cargv == NULL) {
-        JNU_ThrowOutOfMemoryError(env, "Unable to allocate cargv");
-        AWT_UNLOCK();
-        return;
-    }
-
-    /* fill C array with platform chars of java strings */
-      for (i = 0; i < argc; ++i) {
-        jstring js;
-        const char *cs;
-
-        cs = NULL;
-        js = (*env)->GetObjectArrayElement(env, jargv, i);
-        if (js != NULL) {
-            cs = JNU_GetStringPlatformChars(env, js, NULL);
-        }
-        if (cs == NULL) {
-            cs = empty;
-        }
-        cargv[i] = cs;
-        (*env)->DeleteLocalRef(env, js);
-    }
+    array = stringArrayToNative(env, jarray, &length);
 
-    /* grr, X prototype doesn't declare cargv as const, thought it really is */
-    status = XmbTextListToTextProperty(awt_display, (char **)cargv, argc,
-                                       XStdICCTextStyle, &text_prop);
-    if (status < 0) {
-        switch (status) {
-        case XNoMemory:
-            JNU_ThrowOutOfMemoryError(env,
-                "XmbTextListToTextProperty: XNoMemory");
-            break;
-        case XLocaleNotSupported:
-            JNU_ThrowInternalError(env,
-                "XmbTextListToTextProperty: XLocaleNotSupported");
-            break;
-        case XConverterNotFound:
-            JNU_ThrowNullPointerException(env,
-                "XmbTextListToTextProperty: XConverterNotFound");
-            break;
-        default:
-            JNU_ThrowInternalError(env,
-                "XmbTextListToTextProperty: unknown error");
+    if (array != NULL) {
+        status = XmbTextListToTextProperty(awt_display, array, length,
+                                           XStdICCTextStyle, &text_prop);
+        if (status < 0) {
+            switch (status) {
+            case XNoMemory:
+                JNU_ThrowOutOfMemoryError(env,
+                    "XmbTextListToTextProperty: XNoMemory");
+                break;
+            case XLocaleNotSupported:
+                JNU_ThrowInternalError(env,
+                    "XmbTextListToTextProperty: XLocaleNotSupported");
+                break;
+            case XConverterNotFound:
+                JNU_ThrowNullPointerException(env,
+                    "XmbTextListToTextProperty: XConverterNotFound");
+                break;
+            default:
+                JNU_ThrowInternalError(env,
+                    "XmbTextListToTextProperty: unknown error");
+            }
+        } else {
+            XSetTextProperty(awt_display, xawt_root_window,
+                                 &text_prop, XA_WM_COMMAND);
         }
-    } else {
-
-    XSetTextProperty(awt_display, xawt_root_window,
-                         &text_prop, XA_WM_COMMAND);
-    }
-
-    for (i = 0; i < argc; ++i) {
-        jstring js;
 
-        if (cargv[i] == empty)
-            continue;
+        if (text_prop.value != NULL)
+            XFree(text_prop.value);
 
-        js = (*env)->GetObjectArrayElement(env, jargv, i);
-        JNU_ReleaseStringPlatformChars(env, js, cargv[i]);
-        (*env)->DeleteLocalRef(env, js);
+        freeNativeStringArray(array, length);
     }
-    if (text_prop.value != NULL)
-        XFree(text_prop.value);
     AWT_UNLOCK();
 }
 
--- a/src/solaris/native/sun/xawt/XWindow.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/xawt/XWindow.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1242,9 +1242,13 @@
 {
    char *ptr = NULL;
    windowID = (*env)->GetFieldID(env, clazz, "window", "J");
+   CHECK_NULL(windowID);
    targetID = (*env)->GetFieldID(env, clazz, "target", "Ljava/awt/Component;");
+   CHECK_NULL(targetID);
    graphicsConfigID = (*env)->GetFieldID(env, clazz, "graphicsConfig", "Lsun/awt/X11GraphicsConfig;");
+   CHECK_NULL(graphicsConfigID);
    drawStateID = (*env)->GetFieldID(env, clazz, "drawState", "I");
+   CHECK_NULL(drawStateID);
    ptr = getenv("_AWT_USE_TYPE4_PATCH");
    if( ptr != NULL && ptr[0] != 0 ) {
        if( strncmp("true", ptr, 4) == 0 ) {
--- a/src/solaris/native/sun/xawt/XlibWrapper.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/xawt/XlibWrapper.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,7 @@
 #include "utility/rect.h"
 
 #include <X11/XKBlib.h>
+
 #if defined(DEBUG) || defined(INTERNAL_BUILD)
 static jmethodID lockIsHeldMID = NULL;
 
@@ -59,17 +60,94 @@
         lockIsHeldMID =
             (*env)->GetStaticMethodID(env, tkClass,
                                       "isAWTLockHeldByCurrentThread", "()Z");
+        if (lockIsHeldMID == NULL) return;
     }
     if (!(*env)->CallStaticBooleanMethod(env, tkClass, lockIsHeldMID)) {
         JNU_ThrowInternalError(env, "Current thread does not hold AWT_LOCK!");
     }
 }
 
-#define AWT_CHECK_HAVE_LOCK() CheckHaveAWTLock(env)
+#define AWT_CHECK_HAVE_LOCK()                       \
+    do {                                            \
+        CheckHaveAWTLock(env);                      \
+        if ((*env)->ExceptionCheck(env)) {          \
+            return;                                 \
+        }                                           \
+    } while (0);                                    \
+
+#define AWT_CHECK_HAVE_LOCK_RETURN(ret)             \
+    do {                                            \
+        CheckHaveAWTLock(env);                      \
+        if ((*env)->ExceptionCheck(env)) {          \
+            return (ret);                           \
+        }                                           \
+    } while (0);                                    \
+
 #else
 #define AWT_CHECK_HAVE_LOCK()
+#define AWT_CHECK_HAVE_LOCK_RETURN(ret)
 #endif
 
+void freeNativeStringArray(char **array, jsize length) {
+    int i;
+    if (array == NULL) {
+        return;
+    }
+    for (i = 0; i < length; i++) {
+        free(array[i]);
+    }
+    free(array);
+}
+
+char** stringArrayToNative(JNIEnv *env, jobjectArray array, jsize * ret_length) {
+    Bool err = FALSE;
+    char ** strings;
+    int index, str_index = 0;
+    jsize length = (*env)->GetArrayLength(env, array);
+
+    if (length == 0) {
+        return NULL;
+    }
+
+    strings = (char**) calloc(length, sizeof (char*));
+
+    if (strings == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "");
+        return NULL;
+    }
+
+    for (index = 0; index < length; index++) {
+        jstring str = (*env)->GetObjectArrayElement(env, array, index);
+        if (str != NULL) {
+            const char * str_char = JNU_GetStringPlatformChars(env, str, NULL);
+            if (str_char != NULL) {
+                char * dup_str = strdup(str_char);
+                if (dup_str != NULL) {
+                    strings[str_index++] = dup_str;
+                } else {
+                    JNU_ThrowOutOfMemoryError(env, "");
+                    err = TRUE;
+                }
+                JNU_ReleaseStringPlatformChars(env, str, str_char);
+            } else {
+                err = TRUE;
+            }
+            (*env)->DeleteLocalRef(env, str);
+            if (err) {
+                break;
+            }
+        }
+    }
+
+    if (err) {
+        freeNativeStringArray(strings, str_index);
+        strings = NULL;
+        str_index = -1;
+    }
+    *ret_length = str_index;
+
+    return strings;
+}
 
 /*
  * Class:     XlibWrapper
@@ -81,7 +159,7 @@
 (JNIEnv *env, jclass clazz, jlong display_name)
 {
     Display *dp;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     dp  =  XOpenDisplay((char *) jlong_to_ptr(display_name));
 
     return ptr_to_jlong(dp);
@@ -97,7 +175,7 @@
 JNIEXPORT jlong JNICALL
 Java_sun_awt_X11_XlibWrapper_XDisplayString(JNIEnv *env, jclass clazz,
                         jlong display) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ptr_to_jlong(XDisplayString((Display*) jlong_to_ptr(display)));
 }
 
@@ -115,7 +193,7 @@
  */
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DefaultScreen (JNIEnv *env, jclass clazz, jlong display) {
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong) DefaultScreen((Display *) jlong_to_ptr(display));
 }
 
@@ -125,7 +203,7 @@
  * Signature: (JJ)J
  */
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_ScreenOfDisplay(JNIEnv *env, jclass clazz, jlong display, jlong screen_number) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ptr_to_jlong(ScreenOfDisplay((Display *) jlong_to_ptr(display),
                                         screen_number));
 }
@@ -136,7 +214,7 @@
  * Signature: (J)I
  */
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_DoesBackingStore(JNIEnv *env, jclass clazz, jlong screen) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jint) DoesBackingStore((Screen*) jlong_to_ptr(screen));
 }
 
@@ -148,7 +226,7 @@
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DisplayWidth
 (JNIEnv *env, jclass clazz, jlong display, jlong screen) {
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong) DisplayWidth((Display *) jlong_to_ptr(display),screen);
 
 }
@@ -160,7 +238,7 @@
  */
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DisplayWidthMM
 (JNIEnv *env, jclass clazz, jlong display, jlong screen) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong) DisplayWidthMM((Display *) jlong_to_ptr(display),screen);
 }
 
@@ -172,7 +250,7 @@
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DisplayHeight
 (JNIEnv *env, jclass clazz, jlong display, jlong screen) {
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong) DisplayHeight((Display *) jlong_to_ptr(display),screen);
 }
 /*
@@ -182,7 +260,7 @@
  */
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_DisplayHeightMM
 (JNIEnv *env, jclass clazz, jlong display, jlong screen) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong) DisplayHeightMM((Display *) jlong_to_ptr(display),screen);
 }
 
@@ -193,7 +271,7 @@
  */
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_RootWindow
 (JNIEnv *env , jclass clazz, jlong display, jlong screen_number) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong) RootWindow((Display *) jlong_to_ptr(display), screen_number);
 }
 
@@ -203,7 +281,7 @@
  */
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_ScreenCount
 (JNIEnv *env , jclass clazz, jlong display) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ScreenCount((Display *) jlong_to_ptr(display));
 }
 
@@ -218,7 +296,7 @@
    jint x, jint y, jint w, jint h , jint border_width, jint depth,
    jlong wclass, jlong visual, jlong valuemask, jlong attributes)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return  XCreateWindow((Display *) jlong_to_ptr(display),(Window) window, x, y, w, h,
               border_width, depth, wclass, (Visual *) jlong_to_ptr(visual),
               valuemask, (XSetWindowAttributes *) jlong_to_ptr(attributes));
@@ -360,7 +438,7 @@
 
     Window focusOwner;
     int revert_to;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     XGetInputFocus( (Display *)jlong_to_ptr(display), &focusOwner, &revert_to);
     return focusOwner;
 }
@@ -383,7 +461,7 @@
  jint owner_events, jint event_mask, jint pointer_mode,
  jint keyboard_mode, jlong confine_to, jlong cursor, jlong time)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XGrabPointer( (Display *)jlong_to_ptr(display), (Window) window,
              (Bool) owner_events, (unsigned int) event_mask, (int) pointer_mode,
              (int) keyboard_mode, (Window) confine_to, (Cursor) cursor, (Time) time);
@@ -401,7 +479,7 @@
  jint owner_events, jint pointer_mode,
  jint keyboard_mode, jlong time)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XGrabKeyboard( (Display *)jlong_to_ptr(display), (Window) window,
               (Bool) owner_events, (int) pointer_mode,
               (int) keyboard_mode, (Time) time);
@@ -474,7 +552,7 @@
 (JNIEnv *env, jclass clazz, jlong display, jlong opcode_rtrn, jlong event_rtrn,
               jlong error_rtrn, jlong major_in_out, jlong minor_in_out)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     return XkbQueryExtension( (Display *) jlong_to_ptr(display),
                        (int *) jlong_to_ptr(opcode_rtrn),
                        (int *) jlong_to_ptr(event_rtrn),
@@ -485,7 +563,7 @@
 JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XkbLibraryVersion
 (JNIEnv *env, jclass clazz, jlong lib_major_in_out, jlong lib_minor_in_out)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     *((int *)jlong_to_ptr(lib_major_in_out)) =  XkbMajorVersion;
     *((int *)jlong_to_ptr(lib_minor_in_out)) =  XkbMinorVersion;
     return  XkbLibraryVersion((int *)jlong_to_ptr(lib_major_in_out), (int *)jlong_to_ptr(lib_minor_in_out));
@@ -494,7 +572,7 @@
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XkbGetMap
 (JNIEnv *env, jclass clazz, jlong display, jlong which, jlong device_spec)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong) XkbGetMap( (Display *) jlong_to_ptr(display),
                               (unsigned int) which,
                               (unsigned int) device_spec);
@@ -502,7 +580,7 @@
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XkbGetUpdatedMap
 (JNIEnv *env, jclass clazz, jlong display, jlong which, jlong xkb)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong) XkbGetUpdatedMap( (Display *) jlong_to_ptr(display),
                               (unsigned int) which,
                               (XkbDescPtr) jlong_to_ptr(xkb));
@@ -516,6 +594,7 @@
 JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XkbTranslateKeyCode
 (JNIEnv *env, jclass clazz, jlong xkb, jint keycode, jlong mods, jlong mods_rtrn, jlong keysym_rtrn)
 {
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     Bool b;
     b = XkbTranslateKeyCode((XkbDescPtr)xkb, (unsigned int)keycode, (unsigned int)mods,
                               (unsigned int *)jlong_to_ptr(mods_rtrn),
@@ -578,7 +657,7 @@
 JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XFilterEvent
 (JNIEnv *env, jclass clazz, jlong ptr, jlong window)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     return (jboolean) XFilterEvent((XEvent *) jlong_to_ptr(ptr), (Window) window);
 }
 
@@ -590,7 +669,7 @@
 JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_XSupportsLocale
 (JNIEnv *env, jclass clazz)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     return (jboolean)XSupportsLocale();
 }
 
@@ -607,9 +686,10 @@
 
     if (!JNU_IsNull(env, jstr)) {
         modifier_list = (char *)JNU_GetStringPlatformChars(env, jstr, NULL);
+        CHECK_NULL_RETURN(modifier_list, NULL);
     }
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(NULL);
     if (modifier_list) {
         ret = XSetLocaleModifiers(modifier_list);
         JNU_ReleaseStringPlatformChars(env, jstr, (const char *) modifier_list);
@@ -722,7 +802,7 @@
  jlong src_x, jlong src_y, jlong dest_x_return, jlong dest_y_return,
  jlong child_return)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XTranslateCoordinates( (Display *) jlong_to_ptr(display), src_w, dest_w,
                   src_x, src_y,
                   (int *) jlong_to_ptr(dest_x_return),
@@ -733,7 +813,7 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XEventsQueued
 (JNIEnv *env, jclass clazz, jlong display, jint mode) {
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XEventsQueued((Display *) jlong_to_ptr(display), mode);
 
 }
@@ -758,6 +838,7 @@
 #else
         cname = (char *) JNU_GetStringPlatformChars(env, jstr, NULL);
 #endif
+        CHECK_NULL(cname);
     } else {
         cname = "";
     }
@@ -814,8 +895,9 @@
     jlong type, jint format, jint mode, jstring value)
 {
     jboolean iscopy;
+    AWT_CHECK_HAVE_LOCK();
     const char * chars = JNU_GetStringPlatformChars(env, value, &iscopy);
-    AWT_CHECK_HAVE_LOCK();
+    CHECK_NULL(chars);
     XChangeProperty((Display*)jlong_to_ptr(display), window, (Atom)property,
                     (Atom)type, format, mode, (unsigned char*)chars, strlen(chars));
     if (iscopy) {
@@ -833,7 +915,7 @@
  jlong long_length, jlong delete, jlong req_type, jlong actual_type,
  jlong actual_format, jlong nitems_ptr, jlong bytes_after, jlong data_ptr)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XGetWindowProperty((Display*) jlong_to_ptr(display), window, property, long_offset, long_length,
                   delete, (Atom) req_type, (Atom*) jlong_to_ptr(actual_type),
                   (int *) jlong_to_ptr(actual_format), (unsigned long *) jlong_to_ptr(nitems_ptr),
@@ -857,23 +939,22 @@
     unsigned long nitems;
     unsigned long bytes_after;
     unsigned char * string;
-    jstring res;
-    AWT_CHECK_HAVE_LOCK();
+    jstring res = NULL;
+    AWT_CHECK_HAVE_LOCK_RETURN(NULL);
     status = XGetWindowProperty((Display*)jlong_to_ptr(display), window,
                                 atom, 0, 0xFFFF, False, XA_STRING,
                                 &actual_type, &actual_format, &nitems, &bytes_after,
                                 &string);
+
     if (status != Success || string == NULL) {
-    return NULL;
+        return NULL;
     }
 
-    if (actual_type != XA_STRING || actual_format != 8) {
-    XFree(string);
-    return NULL;
+    if (actual_type == XA_STRING && actual_format == 8) {
+        res = JNU_NewStringPlatform(env,(char*) string);
     }
-
-    // Memory leak???
-    return JNU_NewStringPlatform(env,(char*) string);
+    XFree(string);
+    return res;
 }
 
 /*
@@ -887,13 +968,15 @@
     char *cname;
     unsigned long atom;
 
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
+
     if (!JNU_IsNull(env, jstr)) {
         cname = (char *)JNU_GetStringPlatformChars(env, jstr, NULL);
+        CHECK_NULL_RETURN(cname, 0);
     } else {
         cname = "";
     }
 
-    AWT_CHECK_HAVE_LOCK();
     atom = XInternAtom((Display *) jlong_to_ptr(display), cname, ife);
 
     if (!JNU_IsNull(env, jstr)) {
@@ -906,7 +989,7 @@
 
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XCreateFontCursor
 (JNIEnv *env, jclass clazz, jlong display, jint shape) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XCreateFontCursor((Display *) jlong_to_ptr(display), (int) shape);
 }
 
@@ -919,7 +1002,7 @@
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XCreatePixmapCursor
 (JNIEnv *env , jclass clazz, jlong display, jlong source, jlong mask, jlong fore, jlong back, jint x , jint y) {
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong) XCreatePixmapCursor((Display *) jlong_to_ptr(display), (Pixmap) source, (Pixmap) mask,
                                        (XColor *) jlong_to_ptr(fore), (XColor *) jlong_to_ptr(back), x, y);
 }
@@ -935,7 +1018,7 @@
 
     Status status;
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     status  =  XQueryBestCursor((Display *) jlong_to_ptr(display), (Drawable) drawable, width,height,
                                 (unsigned int *) jlong_to_ptr(width_return), (unsigned int *) jlong_to_ptr(height_return));
 
@@ -966,15 +1049,14 @@
 
     Bool b;
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     b = XQueryPointer((Display *) jlong_to_ptr(display),
                       (Window) w, (Window *) jlong_to_ptr(root_return), (Window *) jlong_to_ptr(child_return),
                       (int *) jlong_to_ptr(root_x_return), (int *) jlong_to_ptr(root_y_return),
                       (int *) jlong_to_ptr(win_x_return), (int *) jlong_to_ptr(win_y_return),
                       (unsigned int *) jlong_to_ptr(mask_return));
-    if (b == True) return JNI_TRUE;
-    else return JNI_FALSE;
 
+    return b ? JNI_TRUE : JNI_FALSE;
 }
 
 /*
@@ -1042,7 +1124,7 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGetPointerMapping
 (JNIEnv *env, jclass clazz, jlong display, jlong map, jint buttonNumber)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XGetPointerMapping((Display*)jlong_to_ptr(display), (unsigned char*) jlong_to_ptr(map), buttonNumber);
 }
 
@@ -1061,31 +1143,26 @@
     if (!JNU_IsNull(env, program)) {
         c_program = (char *)JNU_GetStringPlatformChars(env, program, NULL);
     }
+    CHECK_NULL_RETURN(c_program, NULL);
+
     if (!JNU_IsNull(env, option)) {
         c_option = (char *)JNU_GetStringPlatformChars(env, option, NULL);
     }
 
-    if (c_program == NULL || c_option == NULL) {
-        if (!JNU_IsNull(env, program)) {
-            JNU_ReleaseStringPlatformChars(env, program, (const char *) c_program);
-        }
-        if (!JNU_IsNull(env, option)) {
-            JNU_ReleaseStringPlatformChars(env, option, (const char *) c_option);
-        }
+    if (c_option == NULL) {
+        JNU_ReleaseStringPlatformChars(env, program, (const char *) c_program);
         return NULL;
     }
-    AWT_CHECK_HAVE_LOCK();
-    c_res = XGetDefault((Display*)jlong_to_ptr(display), c_program, c_option);
 
-    if (!JNU_IsNull(env, program)) {
-        JNU_ReleaseStringPlatformChars(env, program, (const char *) c_program);
-    }
-    if (!JNU_IsNull(env, option)) {
-        JNU_ReleaseStringPlatformChars(env, option, (const char *) c_option);
-    }
+    AWT_CHECK_HAVE_LOCK_RETURN(NULL);
+    c_res = XGetDefault((Display*)jlong_to_ptr(display), c_program, c_option);
+    // The strings returned by XGetDefault() are owned by Xlib and
+    // should not be modified or freed by the client.
+
+    JNU_ReleaseStringPlatformChars(env, program, (const char *) c_program);
+    JNU_ReleaseStringPlatformChars(env, option, (const char *) c_option);
 
     if (c_res != NULL) {
-        // Memory leak???
         return JNU_NewStringPlatform(env, c_res);
     } else {
         return NULL;
@@ -1103,7 +1180,7 @@
 {
     XWindowAttributes attrs;
     memset(&attrs, 0, sizeof(attrs));
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     XGetWindowAttributes((Display *) jlong_to_ptr(display), window, &attrs);
     return ptr_to_jlong(attrs.screen);
 }
@@ -1116,7 +1193,7 @@
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XScreenNumberOfScreen
 (JNIEnv *env, jclass clazz, jlong screen)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(-1);
     if(jlong_to_ptr(screen) == NULL) {
         return -1;
     }
@@ -1131,7 +1208,7 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XIconifyWindow
 (JNIEnv *env, jclass clazz, jlong display, jlong window, jlong screenNumber)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XIconifyWindow((Display*) jlong_to_ptr(display), window, screenNumber);
 }
 
@@ -1158,10 +1235,9 @@
     unsigned char * str = (unsigned char*) jlong_to_ptr(str_ptr);
     long length = strlen((char*)str);
     jbyteArray res = (*env)->NewByteArray(env, length);
-    void * storage = malloc(length+1);
-    memcpy(storage, str, length+1);
+    CHECK_NULL_RETURN(res, NULL);
     (*env)->SetByteArrayRegion(env, res, 0, length,
-                   (const signed char*) storage);
+                   (const signed char*) str);
     return res;
 }
 
@@ -1174,7 +1250,7 @@
 JNIEXPORT jstring JNICALL Java_sun_awt_X11_XlibWrapper_ServerVendor
 (JNIEnv *env, jclass clazz, jlong display)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(NULL);
     return JNU_NewStringPlatform(env, ServerVendor((Display*)jlong_to_ptr(display)));
 }
 /*
@@ -1185,7 +1261,7 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_VendorRelease
 (JNIEnv *env, jclass clazz, jlong display)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return VendorRelease((Display*)jlong_to_ptr(display));
 }
 /*
@@ -1203,7 +1279,7 @@
     // second, in which place in the keysymarray is XK_KP_7
     // using XKeycodeToKeysym.
     int kc7;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     kc7 = XKeysymToKeycode((Display*)jlong_to_ptr(display), XK_KP_7);
     if( !kc7 ) {
         // keycode is not defined. Why, it's a reduced keyboard perhaps:
@@ -1226,7 +1302,7 @@
 (JNIEnv *env, jclass clazz, jlong display)
 {
     int xx;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     xx = XKeysymToKeycode((Display*)jlong_to_ptr(display), SunXK_F37);
     return (!xx) ? JNI_FALSE : JNI_TRUE;
 }
@@ -1242,7 +1318,7 @@
     int32_t i;
     int32_t kanaCount = 0;
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
 
     // There's no direct way to determine whether the keyboard has
     // a kana lock key. From available keyboard mapping tables, it looks
@@ -1289,8 +1365,10 @@
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler
 (JNIEnv *env, jclass clazz)
 {
-    (*env)->GetJavaVM(env, &jvm);
-    AWT_CHECK_HAVE_LOCK();
+    if ((*env)->GetJavaVM(env, &jvm) < 0) {
+        return 0;
+    }
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ptr_to_jlong(XSetErrorHandler(ToolkitErrorHandler));
 }
 
@@ -1350,28 +1428,14 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XInternAtoms
 (JNIEnv *env, jclass clazz, jlong display, jobjectArray names_arr, jboolean only_if_exists, jlong atoms)
 {
-    int length = (*env)->GetArrayLength(env, names_arr);
-    char ** names = (char**)malloc(length*sizeof(char*));
-    jboolean copy;
-    int index, name_index = 0;
-    int status;
-
-    AWT_CHECK_HAVE_LOCK();
-
-    for (index = 0; index < length; index++) {
-        jstring str = (*env)->GetObjectArrayElement(env, names_arr, index);
-        if (!JNU_IsNull(env, str)) {
-            const char * str_char = JNU_GetStringPlatformChars(env, str, NULL);
-            names[name_index++] = strdup(str_char);
-            JNU_ReleaseStringPlatformChars(env, str, str_char);
-            (*env)->DeleteLocalRef(env, str);
-        }
+    int status = 0;
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
+    jsize length;
+    char** names = stringArrayToNative(env, names_arr, &length);
+    if (names) {
+        status = XInternAtoms((Display*)jlong_to_ptr(display), names, length, only_if_exists, (Atom*) jlong_to_ptr(atoms));
+        freeNativeStringArray(names, length);
     }
-    status = XInternAtoms((Display*)jlong_to_ptr(display), names, name_index, only_if_exists, (Atom*) jlong_to_ptr(atoms));
-    for (index = 0; index < length; index++) {
-        free(names[index]);
-    }
-    free(names);
     return status;
 }
 
@@ -1386,7 +1450,7 @@
 (JNIEnv *env, jclass clazz, jlong display, jlong window, jlong attr_ptr)
 {
     jint status;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     memset((XWindowAttributes*) jlong_to_ptr(attr_ptr), 0, sizeof(XWindowAttributes));
     status =  XGetWindowAttributes((Display*)jlong_to_ptr(display), window, (XWindowAttributes*) jlong_to_ptr(attr_ptr));
     return status;
@@ -1404,7 +1468,7 @@
      jlong border_width_return, jlong depth_return)
 {
     jint status;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     status = XGetGeometry((Display *)jlong_to_ptr(display),
                           (Drawable)drawable, (Window *)jlong_to_ptr(root_return),
                           (int *)jlong_to_ptr(x_return), (int *)jlong_to_ptr(y_return),
@@ -1423,7 +1487,7 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGetWMNormalHints
 (JNIEnv *env, jclass clazz, jlong display, jlong window, jlong hints, jlong supplied_return)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XGetWMNormalHints((Display*) jlong_to_ptr(display),
                              window,
                              (XSizeHints*) jlong_to_ptr(hints),
@@ -1462,7 +1526,7 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XSendEvent
 (JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean propagate, jlong event_mask, jlong event)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XSendEvent((Display*) jlong_to_ptr(display),
                       window,
                       propagate==JNI_TRUE?True:False,
@@ -1479,7 +1543,7 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XQueryTree
 (JNIEnv *env, jclass clazz, jlong display, jlong window, jlong root_return, jlong parent_return, jlong children_return, jlong nchildren_return)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XQueryTree((Display*) jlong_to_ptr(display),
                       window,
                       (Window *) jlong_to_ptr(root_return),
@@ -1524,7 +1588,7 @@
 (JNIEnv *env, jclass clazz, jlong display, jlong vinfo_mask, jlong vinfo_template,
  jlong nitems_return)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ptr_to_jlong(XGetVisualInfo((Display*) jlong_to_ptr(display),
                                        (long) vinfo_mask,
                                        (XVisualInfo*) jlong_to_ptr(vinfo_template),
@@ -1534,7 +1598,7 @@
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XAllocSizeHints
   (JNIEnv *env, jclass clazz)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ptr_to_jlong(XAllocSizeHints());
 }
 
@@ -1560,7 +1624,7 @@
 (JNIEnv *env, jclass clazz, jlong display , jlong colormap, jlong xcolor) {
 
     Status status;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     status = XAllocColor((Display *) jlong_to_ptr(display), (Colormap) colormap, (XColor *) jlong_to_ptr(xcolor));
 
     if (status == 0) return JNI_FALSE;
@@ -1575,7 +1639,7 @@
  */
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XCreateBitmapFromData
 (JNIEnv *env, jclass clazz, jlong display, jlong drawable, jlong data, jint width, jint height) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
 
     return (jlong) XCreateBitmapFromData((Display *) jlong_to_ptr(display), (Drawable) drawable,
                                          (char *) jlong_to_ptr(data), width, height);
@@ -1640,7 +1704,7 @@
 JNIEXPORT jlong JNICALL
 Java_sun_awt_X11_XlibWrapper_XGetSelectionOwner(JNIEnv *env, jclass clazz,
                         jlong display, jlong selection) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return (jlong)XGetSelectionOwner((Display*)jlong_to_ptr(display), selection);
 }
 
@@ -1655,7 +1719,7 @@
 {
     jstring string = NULL;
     char* name;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(NULL);
     name = (char*) XGetAtomName((Display*)jlong_to_ptr(display), atom);
 
     if (name == NULL) {
@@ -1679,21 +1743,21 @@
 JNIEXPORT jlong JNICALL
 Java_sun_awt_X11_XlibWrapper_XMaxRequestSize(JNIEnv *env, jclass clazz,
                          jlong display) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XMaxRequestSize((Display*) jlong_to_ptr(display));
 }
 
 JNIEXPORT jlong JNICALL
 Java_sun_awt_X11_XlibWrapper_XAllocWMHints(JNIEnv *env, jclass clazz)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ptr_to_jlong(XAllocWMHints());
 }
 
 JNIEXPORT jlong JNICALL
 Java_sun_awt_X11_XlibWrapper_XCreatePixmap(JNIEnv *env, jclass clazz, jlong display, jlong drawable, jint width, jint height, jint depth)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XCreatePixmap((Display*)jlong_to_ptr(display), (Drawable)drawable, width, height, depth);
 }
 JNIEXPORT jlong JNICALL
@@ -1702,7 +1766,7 @@
    jint depth, jint format, jint offset, jlong data, jint width,
    jint height, jint bitmap_pad, jint bytes_per_line)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ptr_to_jlong(XCreateImage((Display*) jlong_to_ptr(display), (Visual*) jlong_to_ptr(visual_ptr),
                 depth, format, offset, (char*) jlong_to_ptr(data),
                 width, height, bitmap_pad, bytes_per_line));
@@ -1712,7 +1776,7 @@
   (JNIEnv *env, jclass clazz, jlong display, jlong drawable,
    jlong valuemask, jlong values)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ptr_to_jlong(XCreateGC((Display*) jlong_to_ptr(display), (Drawable)drawable, valuemask, (XGCValues*) jlong_to_ptr(values)));
 }
 
@@ -1762,7 +1826,7 @@
     XIconSize** psize = (XIconSize**) jlong_to_ptr(ret_sizes);
     int * pcount = (int *) jlong_to_ptr(ret_count);
     Status res;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     res = XGetIconSizes((Display*) jlong_to_ptr(display), (Window)window, psize, pcount);
     return res;
 }
@@ -1771,7 +1835,7 @@
   (JNIEnv *env, jclass clazz, jlong display, jlong major_version_return,
    jlong minor_version_return)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XdbeQueryExtension((Display*) jlong_to_ptr(display), (int *) jlong_to_ptr(major_version_return),
                   (int *) jlong_to_ptr(minor_version_return));
 }
@@ -1784,11 +1848,12 @@
     Boolean bu;
     if (!JNU_IsNull(env, jstr)) {
         cname = (char *)JNU_GetStringPlatformChars(env, jstr, NULL);
+        CHECK_NULL_RETURN(cname, JNI_FALSE);
     } else {
         cname = "";
     }
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     bu = XQueryExtension((Display*) jlong_to_ptr(display), cname, (int *) jlong_to_ptr(mop_return),
                 (int *) jlong_to_ptr(feve_return),  (int *) jlong_to_ptr(err_return));
     if (!JNU_IsNull(env, jstr)) {
@@ -1800,7 +1865,7 @@
 JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_IsKeypadKey
   (JNIEnv *env, jclass clazz, jlong keysym)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     if(IsKeypadKey(keysym)) {
         return JNI_TRUE;
     }
@@ -1810,7 +1875,7 @@
 JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_XdbeAllocateBackBufferName
   (JNIEnv *env, jclass clazz, jlong display, jlong window, jint swap_action)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XdbeAllocateBackBufferName((Display*) jlong_to_ptr(display), (Window) window,
                       (XdbeSwapAction) swap_action);
 }
@@ -1818,28 +1883,28 @@
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeDeallocateBackBufferName
   (JNIEnv *env, jclass clazz, jlong display, jlong buffer)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XdbeDeallocateBackBufferName((Display*) jlong_to_ptr(display), (XdbeBackBuffer) buffer);
 }
 
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeBeginIdiom
   (JNIEnv *env, jclass clazz, jlong display)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XdbeBeginIdiom((Display*) jlong_to_ptr(display));
 }
 
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeEndIdiom
   (JNIEnv *env, jclass clazz, jlong display)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XdbeEndIdiom((Display*) jlong_to_ptr(display));
 }
 
 JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XdbeSwapBuffers
   (JNIEnv *env, jclass clazz, jlong display, jlong swap_info, jint num_windows)
 {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XdbeSwapBuffers((Display*) jlong_to_ptr(display), (XdbeSwapInfo *) jlong_to_ptr(swap_info), num_windows);
 }
 JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XQueryKeymap
@@ -1854,7 +1919,7 @@
 Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym(JNIEnv *env, jclass clazz,
                                               jlong display, jint keycode,
                                               jint index) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XKeycodeToKeysym((Display*) jlong_to_ptr(display), (unsigned int)keycode, (int)index);
 }
 
@@ -1862,7 +1927,7 @@
 Java_sun_awt_X11_XlibWrapper_XkbGetEffectiveGroup(JNIEnv *env, jclass clazz,
                                               jlong display) {
     XkbStateRec sr;
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     memset(&sr, 0, sizeof(XkbStateRec));
     XkbGetState((Display*) jlong_to_ptr(display), XkbUseCoreKbd, &sr);
 //    printf("-------------------------------------VVVV\n");
@@ -1887,21 +1952,21 @@
 Java_sun_awt_X11_XlibWrapper_XkbKeycodeToKeysym(JNIEnv *env, jclass clazz,
                                               jlong display, jint keycode,
                                               jint group, jint level) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XkbKeycodeToKeysym((Display*) jlong_to_ptr(display), (unsigned int)keycode, (unsigned int)group, (unsigned int)level);
 }
 
 JNIEXPORT jint JNICALL
 Java_sun_awt_X11_XlibWrapper_XKeysymToKeycode(JNIEnv *env, jclass clazz,
                                               jlong display, jlong keysym) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return XKeysymToKeycode((Display*) jlong_to_ptr(display), (KeySym)keysym);
 }
 
 JNIEXPORT jlong JNICALL
 Java_sun_awt_X11_XlibWrapper_XGetModifierMapping(JNIEnv *env, jclass clazz,
                                               jlong display) {
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(0);
     return ptr_to_jlong(XGetModifierMapping((Display*) jlong_to_ptr(display)));
 }
 
@@ -1958,7 +2023,7 @@
                                                      jlong display, jlong ptr) {
     uint32_t timeout = 1;
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
     exitSecondaryLoop = False;
     while (!exitSecondaryLoop) {
         if (XCheckIfEvent((Display*) jlong_to_ptr(display), (XEvent*) jlong_to_ptr(ptr), secondary_loop_event, NULL)) {
@@ -1996,7 +2061,7 @@
     static jclass stringClass = NULL;
     jclass        stringClassLocal = NULL;
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(NULL);
 
     if (JNU_IsNull(env, stringClass)) {
         stringClassLocal = (*env)->FindClass(env, "java/lang/String");
@@ -2148,7 +2213,7 @@
 {
     jboolean status;
 
-    AWT_CHECK_HAVE_LOCK();
+    AWT_CHECK_HAVE_LOCK_RETURN(JNI_FALSE);
 
     status = XShapeQueryExtension((Display *)jlong_to_ptr(display),
             (int *)jlong_to_ptr(event_base_return), (int *)jlong_to_ptr(error_base_return));
--- a/src/solaris/native/sun/xawt/awt_Desktop.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/solaris/native/sun/xawt/awt_Desktop.c	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
  * questions.
  */
 
+#include "jni_util.h"
 #include "gtk2_interface.h"
 #include "gnome_interface.h"
 
@@ -65,6 +66,12 @@
     const gchar* url_c;
 
     url_c = (char*)(*env)->GetByteArrayElements(env, url_j, NULL);
+    if (url_c == NULL) {
+        if (!(*env)->ExceptionCheck(env)) {
+            JNU_ThrowOutOfMemoryError(env, 0);
+        }
+        return JNI_FALSE;
+    }
 
     if (gtk_has_been_loaded) {
         fp_gdk_threads_enter();
--- a/src/windows/classes/sun/nio/fs/WindowsConstants.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/classes/sun/nio/fs/WindowsConstants.java	Thu May 01 14:21:29 2014 -0700
@@ -98,6 +98,7 @@
     public static final int ERROR_DISK_FULL             = 112;
     public static final int ERROR_INSUFFICIENT_BUFFER   = 122;
     public static final int ERROR_INVALID_LEVEL         = 124;
+    public static final int ERROR_DIR_NOT_ROOT          = 144;
     public static final int ERROR_DIR_NOT_EMPTY         = 145;
     public static final int ERROR_ALREADY_EXISTS        = 183;
     public static final int ERROR_MORE_DATA             = 234;
--- a/src/windows/classes/sun/nio/fs/WindowsFileStore.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/classes/sun/nio/fs/WindowsFileStore.java	Thu May 01 14:21:29 2014 -0700
@@ -86,14 +86,28 @@
                 WindowsFileAttributes.get(file, true);
                 target = file.getPathForWin32Calls();
             }
-            String root = GetVolumePathName(target);
-            return new WindowsFileStore(root);
+            try {
+                return createFromPath(target);
+            } catch (WindowsException e) {
+                if (e.lastError() != ERROR_DIR_NOT_ROOT)
+                    throw e;
+                target = WindowsLinkSupport.getFinalPath(file);
+                if (target == null)
+                    throw new FileSystemException(file.getPathForExceptionMessage(),
+                            null, "Couldn't resolve path");
+                return createFromPath(target);
+            }
         } catch (WindowsException x) {
             x.rethrowAsIOException(file);
             return null; // keep compiler happy
         }
     }
 
+    private static WindowsFileStore createFromPath(String target) throws WindowsException {
+        String root = GetVolumePathName(target);
+        return new WindowsFileStore(root);
+    }
+
     VolumeInformation volumeInformation() {
         return volInfo;
     }
--- a/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java	Thu May 01 14:21:29 2014 -0700
@@ -66,7 +66,7 @@
      * Returns the final path (all symbolic links resolved) or null if this
      * operation is not supported.
      */
-    private static String getFinalPath(WindowsPath input) throws IOException {
+    static String getFinalPath(WindowsPath input) throws IOException {
         long h = 0;
         try {
             h = input.openForReadAttributeAccess(true);
--- a/src/windows/native/sun/java2d/d3d/D3DBadHardware.h	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/java2d/d3d/D3DBadHardware.h	Thu May 01 14:21:29 2014 -0700
@@ -53,27 +53,18 @@
 
     // Intel HD
     // Clarkdale (Desktop) GMA HD Lines
-    { 0x8086, 0x0042, D_VERSION(6,14,10,5394), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0042, D_VERSION(8,15,10,2993), OS_VISTA | OS_WINDOWS7 },
+    { 0x8086, 0x0042, NO_VERSION, OS_ALL },
     // Arrandale (Mobile) GMA HD Lines
-    { 0x8086, 0x0046, D_VERSION(6,14,10,5394), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0046, D_VERSION(8,15,10,2993), OS_VISTA | OS_WINDOWS7 },
+    { 0x8086, 0x0046, NO_VERSION, OS_ALL },
 
     // Sandy Bridge HD Graphics 3000/2000
-    { 0x8086, 0x0102, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0102, D_VERSION(9,17,10,3223), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0106, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0106, D_VERSION(9,17,10,3223), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0112, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0112, D_VERSION(9,17,10,3223), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0116, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0116, D_VERSION(9,17,10,3223), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0122, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0122, D_VERSION(9,17,10,3223), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x0126, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x0126, D_VERSION(9,17,10,3223), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x010A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x010A, D_VERSION(9,17,10,3223), OS_VISTA | OS_WINDOWS7 },
+    { 0x8086, 0x0102, NO_VERSION, OS_ALL },
+    { 0x8086, 0x0106, NO_VERSION, OS_ALL },
+    { 0x8086, 0x0112, NO_VERSION, OS_ALL },
+    { 0x8086, 0x0116, NO_VERSION, OS_ALL },
+    { 0x8086, 0x0122, NO_VERSION, OS_ALL },
+    { 0x8086, 0x0126, NO_VERSION, OS_ALL },
+    { 0x8086, 0x010A, NO_VERSION, OS_ALL },
 
     // Ivy Bridge
     { 0x8086, 0x0162, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
@@ -170,33 +161,21 @@
     { 0x8086, 0x2A13, NO_VERSION, OS_ALL },
 
     // Eaglelake (Desktop) GMA 4500 Lines
-    { 0x8086, 0x2E42, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E42, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x2E43, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E43, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x2E92, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E92, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x2E93, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E93, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x2E12, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E12, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x2E13, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E13, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
+    { 0x8086, 0x2E42, NO_VERSION, OS_ALL },
+    { 0x8086, 0x2E43, NO_VERSION, OS_ALL },
+    { 0x8086, 0x2E92, NO_VERSION, OS_ALL },
+    { 0x8086, 0x2E93, NO_VERSION, OS_ALL },
+    { 0x8086, 0x2E12, NO_VERSION, OS_ALL },
+    { 0x8086, 0x2E13, NO_VERSION, OS_ALL },
     // Eaglelake (Desktop) GMA X4500 Lines
-    { 0x8086, 0x2E32, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E32, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x2E33, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E33, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x2E22, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E22, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
+    { 0x8086, 0x2E32, NO_VERSION, OS_ALL },
+    { 0x8086, 0x2E33, NO_VERSION, OS_ALL },
+    { 0x8086, 0x2E22, NO_VERSION, OS_ALL },
     // Eaglelake (Desktop) GMA X4500HD Lines
-    { 0x8086, 0x2E23, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2E23, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
+    { 0x8086, 0x2E23, NO_VERSION, OS_ALL },
     // Cantiga (Mobile) GMA 4500MHD Lines
-    { 0x8086, 0x2A42, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2A42, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
-    { 0x8086, 0x2A43, D_VERSION(6,14,10,5420), OS_WINXP | OS_WINXP_64 },
-    { 0x8086, 0x2A43, D_VERSION(8,15,10,2869), OS_VISTA | OS_WINDOWS7 },
+    { 0x8086, 0x2A42, NO_VERSION, OS_ALL },
+    { 0x8086, 0x2A43, NO_VERSION, OS_ALL },
 
     // ATI Mobility Radeon X1600, X1400, X1450, X1300, X1350
     // Reason: workaround for 6613066, 6687166
--- a/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp	Thu May 01 14:21:29 2014 -0700
@@ -33,9 +33,16 @@
 #include "awt_BitmapUtil.h"
 #include "D3DRenderQueue.h"
 
+
 // REMIND: move to awt_Component.h
 extern "C" HWND AwtComponent_GetHWnd(JNIEnv *env, jlong pData);
 
+/* This looks weird. but since some AWT headers need to be included,
+ * we end up with AWT's alloc.h macro definition of ExceptionOccurred.
+ * The reasons for that re-defintion do not apply to this code, so undef it.
+ */
+#undef ExceptionOccurred
+
 /**
  * Initializes nativeWidth/Height fields of the SurfaceData object with
  * dimensions on the native surface.
@@ -55,7 +62,9 @@
     }
 
     JNU_SetFieldByName(env, NULL, sdObject, "nativeWidth", "I", width);
-    JNU_SetFieldByName(env, NULL, sdObject, "nativeHeight", "I", height);
+    if (!(env->ExceptionOccurred())) {
+        JNU_SetFieldByName(env, NULL, sdObject, "nativeHeight", "I", height);
+    }
 
     env->DeleteLocalRef(sdObject);
 }
--- a/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp	Thu May 01 14:21:29 2014 -0700
@@ -354,17 +354,26 @@
     initThreadInfoIndex();
 
     xorCompClass = (jclass)env->NewGlobalRef(XORComp);
+    if (env->ExceptionCheck()) {
+        return;
+    }
 
     tc = env->FindClass("java/lang/Thread");
     DASSERT(tc != NULL);
+    CHECK_NULL(tc);
+
     threadClass = (jclass)env->NewGlobalRef(tc);
     DASSERT(threadClass != NULL);
+    CHECK_NULL(threadClass);
+
     currentThreadMethodID =
         env->GetStaticMethodID(threadClass,
                                "currentThread",  "()Ljava/lang/Thread;");
     DASSERT(currentThreadMethodID != NULL);
 }
 
+#undef ExceptionOccurred
+
 /*
  * Class:     sun_java2d_windows_GDIWindowSurfaceData
  * Method:    initOps
@@ -394,6 +403,9 @@
     wsdo->invalid = JNI_FALSE;
     wsdo->lockType = WIN32SD_LOCK_UNLOCKED;
     wsdo->peer = env->NewWeakGlobalRef(peer);
+    if (env->ExceptionOccurred()) {
+        return;
+    }
     wsdo->depth = depth;
     wsdo->pixelMasks[0] = redMask;
     wsdo->pixelMasks[1] = greenMask;
@@ -997,7 +1009,7 @@
 
     ThreadGraphicsInfo *info = GetThreadGraphicsInfo(env, wsdo);
     GDIWinSD_InitDC(env, wsdo, info, type, patrop, clip, comp, color);
-    return info->hDC;
+    return env->ExceptionCheck() ? (HDC)NULL : info->hDC;
 }
 
 JNIEXPORT void JNICALL
@@ -1056,8 +1068,14 @@
             int topInset = wsdo->insets.top;
             Region_StartIteration(env, &clipInfo);
             jint numrects = Region_CountIterationRects(&clipInfo);
-            RGNDATA *lpRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(safe_Malloc,
+            RGNDATA *lpRgnData;
+            try {
+                lpRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(safe_Malloc,
                     sizeof(RGNDATAHEADER), numrects, sizeof(RECT));
+            } catch (std::bad_alloc&) {
+                JNU_ThrowOutOfMemoryError(env, "Initialization of surface region data failed.");
+                return;
+            }
             const DWORD nCount = sizeof(RGNDATAHEADER) + numrects * sizeof(RECT);
             lpRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
             lpRgnData->rdh.iType = RDH_RECTANGLES;
@@ -1086,6 +1104,9 @@
             env->DeleteWeakGlobalRef(info->clip);
         }
         info->clip = env->NewWeakGlobalRef(clip);
+        if (env->ExceptionCheck()) {
+            return;
+        }
     }
 
     // init composite
--- a/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Thu May 01 14:21:29 2014 -0700
@@ -235,7 +235,7 @@
 
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
-    return (*env)->NewString(env, pattern, wcslen(pattern));
+    return (*env)->NewString(env, pattern, (jsize)wcslen(pattern));
 }
 
 /*
@@ -263,6 +263,7 @@
   (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) {
     WCHAR buf[BUFLEN];
     const jchar *langtag;
+    jstring tmp_string;
 
     // AM
     int got;
@@ -270,13 +271,21 @@
     CHECK_NULL_RETURN(langtag, NULL);
     got = getLocaleInfoWrapper(langtag, LOCALE_S1159, buf, BUFLEN);
     if (got) {
-        (*env)->SetObjectArrayElement(env, ampms, 0, (*env)->NewString(env, buf, wcslen(buf)));
+        tmp_string = (*env)->NewString(env, buf, (jsize)wcslen(buf));
+        if (tmp_string != NULL) {
+            (*env)->SetObjectArrayElement(env, ampms, 0, tmp_string);
+        }
     }
 
-    // PM
-    got = getLocaleInfoWrapper(langtag, LOCALE_S2359, buf, BUFLEN);
-    if (got) {
-        (*env)->SetObjectArrayElement(env, ampms, 1, (*env)->NewString(env, buf, wcslen(buf)));
+    if (!(*env)->ExceptionCheck(env)){
+        // PM
+        got = getLocaleInfoWrapper(langtag, LOCALE_S2359, buf, BUFLEN);
+        if (got) {
+            tmp_string = (*env)->NewString(env, buf, (jsize)wcslen(buf));
+            if (tmp_string != NULL) {
+                (*env)->SetObjectArrayElement(env, ampms, 1, tmp_string);
+            }
+        }
     }
 
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
@@ -293,13 +302,17 @@
   (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray eras) {
     WCHAR ad[BUFLEN];
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    jstring tmp_string;
     CHECK_NULL_RETURN(langtag, eras);
 
     getCalendarInfoWrapper(langtag, getCalendarID(langtag), NULL,
                       CAL_SERASTRING, ad, BUFLEN, NULL);
 
     // Windows does not provide B.C. era.
-    (*env)->SetObjectArrayElement(env, eras, 1, (*env)->NewString(env, ad, wcslen(ad)));
+    tmp_string = (*env)->NewString(env, ad, (jsize)wcslen(ad));
+    if (tmp_string != NULL) {
+        (*env)->SetObjectArrayElement(env, eras, 1, tmp_string);
+    }
 
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
@@ -371,7 +384,7 @@
     CHECK_NULL_RETURN(pattern, NULL);
 
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
-    ret = (*env)->NewString(env, pattern, wcslen(pattern));
+    ret = (*env)->NewString(env, pattern, (jsize)wcslen(pattern));
     free(pattern);
 
     return ret;
@@ -411,7 +424,7 @@
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
-        return (*env)->NewString(env, buf, wcslen(buf));
+        return (*env)->NewString(env, buf, (jsize)wcslen(buf));
     } else {
         return currencySymbol;
     }
@@ -474,7 +487,7 @@
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
-        return (*env)->NewString(env, buf, wcslen(buf));
+        return (*env)->NewString(env, buf, (jsize)wcslen(buf));
     } else {
         return infinity;
     }
@@ -495,7 +508,7 @@
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
-        return (*env)->NewString(env, buf, wcslen(buf));
+        return (*env)->NewString(env, buf, (jsize)wcslen(buf));
     } else {
         return internationalCurrencySymbol;
     }
@@ -558,7 +571,7 @@
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
-        return (*env)->NewString(env, buf, wcslen(buf));
+        return (*env)->NewString(env, buf, (jsize)wcslen(buf));
     } else {
         return nan;
     }
@@ -701,7 +714,7 @@
     (*env)->ReleaseStringChars(env, jStr, pjChar);
 
     if (got) {
-        return (*env)->NewString(env, buf, wcslen(buf));
+        return (*env)->NewString(env, buf, (jsize)wcslen(buf));
     } else {
         return NULL;
     }
@@ -754,9 +767,10 @@
 
 void replaceCalendarArrayElems(JNIEnv *env, jstring jlangtag, jobjectArray jarray, CALTYPE* pCalTypes, int offset, int length) {
     WCHAR name[BUFLEN];
-    const jchar *langtag;
+    const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
     int calid;
-    langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    jstring tmp_string;
+
     CHECK_NULL(langtag);
     calid = getCalendarID(langtag);
 
@@ -765,8 +779,10 @@
         for (i = 0; i < length; i++) {
             getCalendarInfoWrapper(langtag, calid, NULL,
                               pCalTypes[i], name, BUFLEN, NULL);
-            (*env)->SetObjectArrayElement(env, jarray, i + offset,
-                          (*env)->NewString(env, name, wcslen(name)));
+            tmp_string = (*env)->NewString(env, name, (jsize)wcslen(name));
+            if (tmp_string != NULL) {
+                (*env)->SetObjectArrayElement(env, jarray, i + offset, tmp_string);
+            }
         }
     }
 
--- a/src/windows/native/sun/windows/ThemeReader.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/ThemeReader.cpp	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -233,7 +233,7 @@
         Themed = InitThemes();
         TryLoadingThemeLib = TRUE;
     }
-    return Themed;
+    return JNI_IS_TRUE(Themed);
 }
 
 
@@ -271,6 +271,10 @@
 (JNIEnv *env, jclass klass, jstring widget) {
 
     LPCTSTR str = (LPCTSTR) JNU_GetStringPlatformChars(env, widget, NULL);
+    if (str == NULL) {
+        JNU_ThrowOutOfMemoryError(env, 0);
+        return 0;
+    }
     // We need to open the Theme on a Window that will stick around.
     // The best one for that purpose is the Toolkit window.
     HTHEME htheme = OpenThemeData(AwtToolkit::GetInstance().GetHWnd(), str);
@@ -485,6 +489,7 @@
 
     if (insetsClassID == NULL) {
         jclass insetsClassIDLocal = env->FindClass("java/awt/Insets");
+        CHECK_NULL_RETURN(insetsClassIDLocal, NULL);
         insetsClassID = (jclass)env->NewGlobalRef(insetsClassIDLocal);
         env->DeleteLocalRef(insetsClassIDLocal);
     }
@@ -533,7 +538,7 @@
 JNIEXPORT jboolean JNICALL Java_sun_awt_windows_ThemeReader_isThemePartDefined
 (JNIEnv *env, jclass klass, jlong theme, jint part, jint state) {
     HTHEME hTheme = (HTHEME) theme;
-    return IsThemePartDefined(hTheme, part, state);
+    return JNI_IS_TRUE(IsThemePartDefined(hTheme, part, state));
 }
 
 /*
@@ -562,12 +567,14 @@
 
         if (colorClassID == NULL) {
             jclass colorClassIDLocal = env->FindClass("java/awt/Color");
+            CHECK_NULL_RETURN(colorClassIDLocal, NULL);
             colorClassID = (jclass)env->NewGlobalRef(colorClassIDLocal);
             env->DeleteLocalRef(colorClassIDLocal);
         }
 
         if (colorMID == NULL) {
             colorMID = env->GetMethodID(colorClassID, "<init>", "(III)V");
+            CHECK_NULL_RETURN(colorMID, NULL);
         }
         jobject colorObj = env->NewObject(colorClassID,
                 colorMID, GetRValue(color), GetGValue(color),GetBValue(color));
@@ -628,7 +635,7 @@
         HRESULT hres = GetThemeBool(hTheme, part, state, prop, &retVal);
         assert_result(hres, env);
     }
-    return retVal;
+    return JNI_IS_TRUE(retVal);
 }
 
 /*
@@ -640,15 +647,11 @@
 (JNIEnv *env, jclass klass, jlong  theme, jint prop) {
     HTHEME hTheme = (HTHEME)theme;
     if (hTheme != NULL) {
-        return GetThemeSysBool(hTheme, prop);
+        return JNI_IS_TRUE(GetThemeSysBool(hTheme, prop));
     }
-    return FALSE;
+    return JNI_FALSE;
 }
 
-
-
-
-
 /*
  * Class:     sun_awt_windows_ThemeReader
  * Method:    getPoint
@@ -673,12 +676,14 @@
 
         if (pointClassID == NULL) {
             jclass pointClassIDLocal = env->FindClass("java/awt/Point");
+            CHECK_NULL_RETURN(pointClassIDLocal, NULL);
             pointClassID = (jclass)env->NewGlobalRef(pointClassIDLocal);
             env->DeleteLocalRef(pointClassIDLocal);
         }
 
         if (pointMID == NULL) {
             pointMID = env->GetMethodID(pointClassID, "<init>", "(II)V");
+            CHECK_NULL_RETURN(pointMID, NULL);
         }
         jobject pointObj = env->NewObject(pointClassID, pointMID, point.x, point.y);
 
@@ -720,11 +725,13 @@
         static jclass dimClassID = NULL;
         if (dimClassID == NULL) {
             jclass dimClassIDLocal = env->FindClass("java/awt/Dimension");
+            CHECK_NULL_RETURN(dimClassIDLocal, NULL);
             dimClassID = (jclass)env->NewGlobalRef(dimClassIDLocal);
             env->DeleteLocalRef(dimClassIDLocal);
         }
         if (dimMID == NULL) {
             dimMID = env->GetMethodID(dimClassID, "<init>", "(II)V");
+            CHECK_NULL_RETURN(dimMID, NULL);
         }
         jobject dimObj = env->NewObject(dimClassID, dimMID, point.x, point.y);
 
@@ -755,11 +762,13 @@
             static jclass dimClassID = NULL;
             if (dimClassID == NULL) {
                 jclass dimClassIDLocal = env->FindClass("java/awt/Dimension");
+                CHECK_NULL_RETURN(dimClassIDLocal, NULL);
                 dimClassID = (jclass)env->NewGlobalRef(dimClassIDLocal);
                 env->DeleteLocalRef(dimClassIDLocal);
             }
             if (dimMID == NULL) {
                 dimMID = env->GetMethodID(dimClassID, "<init>", "(II)V");
+                CHECK_NULL_RETURN(dimMID, NULL);
             }
             jobject dimObj = env->NewObject(dimClassID, dimMID, size.cx, size.cy);
             if (safe_ExceptionOccurred(env)) {
--- a/src/windows/native/sun/windows/WPrinterJob.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/WPrinterJob.cpp	Thu May 01 14:21:29 2014 -0700
@@ -130,6 +130,9 @@
 
     jstring utf_str;
     jclass clazz = env->FindClass("java/lang/String");
+    if (clazz == NULL) {
+        return NULL;
+    }
     jobjectArray nameArray;
 
     try {
@@ -240,6 +243,9 @@
 
     LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
                                                             printer, NULL);
+    if (printerName == NULL) {
+        return NULL;
+    }
 
     jfloatArray printableArray = NULL;
 
@@ -262,7 +268,7 @@
             if (pDevMode != NULL) {
                 ::GlobalFree(pDevMode);
             }
-
+            DeleteDC(pdc);
             ::ClosePrinter(hPrinter);
             JNU_ReleaseStringPlatformChars(env, printer, printerName);
             return printableArray;
@@ -283,25 +289,21 @@
         int resy = GetDeviceCaps(pdc, LOGPIXELSY);
 
         printableArray=env->NewFloatArray(4);
-        if (printableArray == NULL) {
-            throw std::bad_alloc();
+        if (printableArray != NULL) {
+            jfloat *iPrintables =
+                env->GetFloatArrayElements(printableArray, NULL);
+            if (iPrintables != NULL) {
+                iPrintables[0] = (float)left/resx;
+                iPrintables[1] = (float)top/resy;
+                iPrintables[2] = (float)width/resx;
+                iPrintables[3] = (float)height/resy;
+                env->ReleaseFloatArrayElements(printableArray, iPrintables, 0);
+            }
         }
-        jboolean isCopy;
-        jfloat *iPrintables = env->GetFloatArrayElements(printableArray,
-                                                         &isCopy),
-            *savePrintables = iPrintables;
-
-        iPrintables[0] = (float)left/resx;
-        iPrintables[1] = (float)top/resy;
-        iPrintables[2] = (float)width/resx;
-        iPrintables[3] = (float)height/resy;
-
-        env->ReleaseFloatArrayElements(printableArray, savePrintables, 0);
-
         GlobalFree(pDevMode);
+        DeleteDC(pdc);
     }
 
-    DeleteDC(pdc);
     JNU_ReleaseStringPlatformChars(env, printer, printerName);
 
     return printableArray;
@@ -309,6 +311,60 @@
     CATCH_BAD_ALLOC_RET(NULL);
 }
 
+jintArray getIDs(JNIEnv *env, jstring printer, jstring port, int dm_id)
+{
+
+  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
+  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
+
+  if (printerName == NULL || printerPort == NULL) {
+      if (printerName != NULL) {
+          JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      }
+      if (printerPort != NULL) {
+          JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      }
+      return NULL;
+  }
+
+  SAVE_CONTROLWORD
+  int numIDs = ::DeviceCapabilities(printerName, printerPort, dm_id,
+                                    NULL, NULL);
+  RESTORE_CONTROLWORD
+
+  jintArray idArray = NULL;
+  if (numIDs > 0) {
+      idArray = env->NewIntArray(numIDs);
+      if (idArray != NULL) {
+          jint *jpcIndices = env->GetIntArrayElements(idArray, NULL);
+          if (jpcIndices != NULL) {
+              jint *saveFormats = jpcIndices;
+              LPTSTR buf = NULL;
+              try {
+                  buf = (LPTSTR)new char[numIDs * sizeof(WORD)];
+              } catch (std::bad_alloc&) {
+                  buf = NULL;
+              }
+              if (buf != NULL) {
+                  if (::DeviceCapabilities(printerName, printerPort,
+                                           dm_id, buf, NULL) != -1) {
+                      WORD *id = (WORD *)buf;
+                      for (int i = 0; i < numIDs; i++, id++) {
+                          jpcIndices[i] = *id;
+                      }
+                  }
+                  RESTORE_CONTROLWORD
+                  delete[] buf;
+              }
+              env->ReleaseIntArrayElements(idArray, saveFormats, 0);
+          }
+      }
+  }
+
+  JNU_ReleaseStringPlatformChars(env, printer, printerName);
+  JNU_ReleaseStringPlatformChars(env, port, printerPort);
+  return idArray;
+}
 
 JNIEXPORT jintArray JNICALL
 Java_sun_print_Win32PrintService_getAllMediaIDs(JNIEnv *env,
@@ -316,45 +372,7 @@
                                                 jstring printer,
                                                 jstring port)
 {
-  TRY;
-
-  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
-  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
-  jintArray mediasizeArray = NULL;
-
-  SAVE_CONTROLWORD
-  int numSizes = ::DeviceCapabilities(printerName, printerPort,
-                                      DC_PAPERS,   NULL, NULL);
-  RESTORE_CONTROLWORD
-
-  if (numSizes > 0) {
-
-    mediasizeArray = env->NewIntArray(numSizes);
-    if (mediasizeArray == NULL) {
-      throw std::bad_alloc();
-    }
-
-    jboolean isCopy;
-    jint *jpcIndices = env->GetIntArrayElements(mediasizeArray,
-                                       &isCopy), *saveFormats = jpcIndices;
-    LPTSTR papersBuf = (LPTSTR)new char[numSizes * sizeof(WORD)];
-    if (::DeviceCapabilities(printerName, printerPort,
-                             DC_PAPERS, papersBuf, NULL) != -1) {
-      RESTORE_CONTROLWORD
-      WORD *pDmPaperSize = (WORD *)papersBuf;
-      for (int i = 0; i < numSizes; i++, pDmPaperSize++) {
-        jpcIndices[i] = *pDmPaperSize;
-      }
-    }
-    delete[] papersBuf;
-    env->ReleaseIntArrayElements(mediasizeArray, saveFormats, 0);
-  }
-
-  JNU_ReleaseStringPlatformChars(env, printer, printerName);
-  JNU_ReleaseStringPlatformChars(env, port, printerPort);
-  return mediasizeArray;
-
-  CATCH_BAD_ALLOC_RET(NULL);
+    return getIDs(env, printer, port, DC_PAPERS);
 }
 
 
@@ -364,47 +382,7 @@
                                                   jstring printer,
                                                   jstring port)
 {
-  TRY;
-
-  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
-                                                          printer, NULL);
-  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
-
-  jintArray mediaTrayArray = NULL;
-
-  SAVE_CONTROLWORD
-  int nBins = ::DeviceCapabilities(printerName, printerPort,
-                                   DC_BINS,   NULL, NULL) ;
-  RESTORE_CONTROLWORD
-  if (nBins > 0) {
-    mediaTrayArray = env->NewIntArray(nBins);
-    if (mediaTrayArray == NULL) {
-      throw std::bad_alloc();
-    }
-
-    jboolean isCopy;
-    jint *jpcIndices = env->GetIntArrayElements(mediaTrayArray,
-                                           &isCopy), *saveFormats = jpcIndices;
-
-    LPTSTR buf = (LPTSTR)new char[nBins * sizeof(WORD)];
-
-    if (::DeviceCapabilities(printerName, printerPort,
-                             DC_BINS, buf, NULL) != -1) {
-      RESTORE_CONTROLWORD
-      WORD *pBins = (WORD *)buf;
-      for (int i = 0; i < nBins; i++) {
-        jpcIndices[i] = *(pBins+i);
-      }
-    }
-    delete[] buf;
-    env->ReleaseIntArrayElements(mediaTrayArray, saveFormats, 0);
-  }
-
-  JNU_ReleaseStringPlatformChars(env, printer, printerName);
-  JNU_ReleaseStringPlatformChars(env, port, printerPort);
-  return mediaTrayArray;
-
-  CATCH_BAD_ALLOC_RET(NULL);
+    return getIDs(env, printer, port, DC_BINS);
 }
 
 
@@ -414,100 +392,139 @@
                                                   jstring printer,
                                                   jstring port)
 {
-  TRY;
-
-  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
-                                                          printer, NULL);
+  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
   LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
 
-  jintArray mediaArray = NULL;
+  if (printerName == NULL || printerPort == NULL) {
+      if (printerName != NULL) {
+          JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      }
+      if (printerPort != NULL) {
+          JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      }
+      return NULL;
+  }
 
   SAVE_CONTROLWORD
-  int nPapers = ::DeviceCapabilities(printerName, printerPort,
-                                      DC_PAPERSIZE,   NULL, NULL) ;
+  int nPapers = ::DeviceCapabilities(printerName, printerPort, DC_PAPERSIZE,
+                                     NULL, NULL) ;
   RESTORE_CONTROLWORD
-  if (nPapers > 0) {
-    mediaArray = env->NewIntArray(nPapers*2);
-    if (mediaArray == NULL) {
-      throw std::bad_alloc();
-    }
 
-    jboolean isCopy;
-    jint *jpcIndices = env->GetIntArrayElements(mediaArray,
-                                          &isCopy), *saveFormats = jpcIndices;
+  jintArray mediaArray = NULL;
+  jint *saveFormats = NULL;
 
-    LPTSTR buf = (LPTSTR)new char[nPapers * sizeof(POINT)]; // array of POINTs
-
-    if (::DeviceCapabilities(printerName, printerPort,
-                             DC_PAPERSIZE, buf, NULL) != -1) {
-
-      POINT *pDim = (POINT *)buf;
-      for (int i = 0; i < nPapers; i++) {
-        jpcIndices[i*2] = (pDim+i)->x;
-        jpcIndices[i*2+1] = (pDim+i)->y;
+  if (nPapers > 0) {
+      mediaArray = env->NewIntArray(nPapers*2);
+      if (mediaArray != NULL) {
+          jint *jpcIndices = env->GetIntArrayElements(mediaArray, NULL);
+          if (jpcIndices != NULL) {
+              saveFormats = jpcIndices;
+              LPTSTR buf = NULL;
+              try {
+                  buf = (LPTSTR)new char[nPapers * sizeof(POINT)];
+              } catch (std::bad_alloc&) {
+                  buf = NULL;
+              }
+              if (buf != NULL) {
+                  if (::DeviceCapabilities(printerName, printerPort,
+                                           DC_PAPERSIZE, buf, NULL) != -1) {
+                      POINT *pDim = (POINT *)buf;
+                      for (int i = 0; i < nPapers; i++) {
+                          jpcIndices[i*2] = (pDim+i)->x;
+                          jpcIndices[i*2+1] = (pDim+i)->y;
+                      }
+                  }
+                  RESTORE_CONTROLWORD
+                  delete[] buf;
+              }
+              env->ReleaseIntArrayElements(mediaArray, saveFormats, 0);
+              saveFormats = NULL;
+          }
       }
-    }
-    RESTORE_CONTROLWORD
-    delete[] buf;
-    env->ReleaseIntArrayElements(mediaArray, saveFormats, 0);
   }
 
   JNU_ReleaseStringPlatformChars(env, printer, printerName);
   JNU_ReleaseStringPlatformChars(env, port, printerPort);
+  if (mediaArray != NULL && saveFormats != NULL) {
+      env->ReleaseIntArrayElements(mediaArray, saveFormats, 0);
+  }
   return mediaArray;
 
-  CATCH_BAD_ALLOC_RET(NULL);
 }
 
 
 jobjectArray getAllDCNames(JNIEnv *env, jobject peer, jstring printer,
                  jstring port, unsigned int dc_id, unsigned int buf_len)
 {
-  TRY;
 
-  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
-                                                          printer, NULL);
+  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
   LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
 
+  if (printerName == NULL || printerPort == NULL) {
+      if (printerName != NULL) {
+          JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      }
+      if (printerPort != NULL) {
+          JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      }
+      return NULL;
+  }
+
   jstring utf_str;
-  jclass cls = env->FindClass("java/lang/String");
-  jobjectArray names= NULL;
+  jobjectArray names = NULL;
   LPTSTR buf = NULL;
   SAVE_CONTROLWORD
   int cReturned = ::DeviceCapabilities(printerName, printerPort,
                                          dc_id, NULL, NULL);
   RESTORE_CONTROLWORD
-  if (cReturned > 0) {
-
-    buf = (LPTSTR)new char[cReturned * buf_len * sizeof(TCHAR)];
-    if (buf == NULL) {
-      throw std::bad_alloc();
-    }
+  if (cReturned <= 0) {
+      JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      return NULL;
+  }
 
-    cReturned = ::DeviceCapabilities(printerName, printerPort,
-                                     dc_id, buf, NULL);
-    RESTORE_CONTROLWORD
+  try {
+      buf = (LPTSTR)new char[cReturned * buf_len * sizeof(TCHAR)];
+  } catch (std::bad_alloc&) {
+      buf = NULL;
+  }
+  if (buf == NULL) {
+      JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
+     return NULL;
+  }
 
-    if (cReturned > 0) {
-      names = env->NewObjectArray(cReturned, cls, NULL);
-      if (names == NULL) {
-        throw std::bad_alloc();
+  cReturned = ::DeviceCapabilities(printerName, printerPort,
+                                   dc_id, buf, NULL);
+  RESTORE_CONTROLWORD
+
+  JNU_ReleaseStringPlatformChars(env, printer, printerName);
+  JNU_ReleaseStringPlatformChars(env, port, printerPort);
+
+  if (cReturned > 0) {
+      jclass cls = env->FindClass("java/lang/String");
+      if (cls != NULL) {
+          names = env->NewObjectArray(cReturned, cls, NULL);
+      }
+      if (names == NULL || cls == NULL) {
+          delete buf;
+          return names;
       }
 
       for (int i = 0; i < cReturned; i++) {
-        utf_str = JNU_NewStringPlatform(env, buf+(buf_len*i));
-        if (utf_str == NULL) {
-          throw std::bad_alloc();
+          utf_str = JNU_NewStringPlatform(env, buf+(buf_len*i));
+            if (utf_str == NULL) {
+                delete buf;
+                return names;
+            }
+            env->SetObjectArrayElement(names, i, utf_str);
+            env->DeleteLocalRef(utf_str);
         }
-        env->SetObjectArrayElement(names, i, utf_str);
-        env->DeleteLocalRef(utf_str);
-      }
     }
     delete[] buf;
-  }
-  return names;
+    return names;
 
-  CATCH_BAD_ALLOC_RET(NULL);
 }
 
 
@@ -540,6 +557,16 @@
   LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
   LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
 
+  if (printerName == NULL || printerPort == NULL) {
+      if (printerName != NULL) {
+          JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      }
+      if (printerPort != NULL) {
+          JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      }
+      return 1;
+  }
+
   SAVE_CONTROLWORD
   int numCopies = ::DeviceCapabilities(printerName, printerPort,
                                        DC_COPIES,   NULL, NULL);
@@ -573,48 +600,58 @@
                                                    jstring printer,
                                                    jstring port)
 {
-  TRY;
-
   LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
   LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
 
-  jintArray resolutionArray = NULL;
+ if (printerName == NULL || printerPort == NULL) {
+      if (printerName != NULL) {
+          JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      }
+      if (printerPort != NULL) {
+          JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      }
+      return NULL;
+  }
 
   SAVE_CONTROLWORD
   int nResolutions = ::DeviceCapabilities(printerName, printerPort,
                                           DC_ENUMRESOLUTIONS, NULL, NULL);
   RESTORE_CONTROLWORD
+
+  jintArray resolutionArray = NULL;
   if (nResolutions > 0) {
     resolutionArray = env->NewIntArray(nResolutions*2);
-    if (resolutionArray == NULL) {
-      throw std::bad_alloc();
+    if (resolutionArray != NULL) {
+        jint *jpcIndices = env->GetIntArrayElements(resolutionArray, NULL);
+        if (jpcIndices != NULL) {
+            jint *saveFormats = jpcIndices;
+            LPTSTR resBuf = NULL;
+            try {
+                resBuf = (LPTSTR)new char[nResolutions * sizeof(LONG) * 2];
+            } catch (std::bad_alloc&) {
+                resBuf = NULL;
+            }
+            if (resBuf != NULL) {
+                if (::DeviceCapabilities(printerName, printerPort,
+                                         DC_ENUMRESOLUTIONS, resBuf,
+                                         NULL) != -1) {
+                    LONG *pResolution = (LONG *)resBuf;
+                    for (int i = 0; i < nResolutions; i++) {
+                        jpcIndices[i*2] = *pResolution++;
+                        jpcIndices[i*2+1] = *pResolution++;
+                    }
+                }
+                RESTORE_CONTROLWORD
+                delete[] resBuf;
+            }
+            env->ReleaseIntArrayElements(resolutionArray, saveFormats, 0);
+        }
     }
-
-    jboolean isCopy;
-    jint *jpcIndices = env->GetIntArrayElements(resolutionArray,
-                                          &isCopy), *saveFormats = jpcIndices;
-
-    LPTSTR resBuf = (LPTSTR)new char[nResolutions * sizeof(LONG) * 2]; // pairs of long
-
-    if (::DeviceCapabilities(printerName, printerPort,
-                             DC_ENUMRESOLUTIONS, resBuf, NULL) != -1) {
-
-      LONG *pResolution = (LONG *)resBuf;
-      for (int i = 0; i < nResolutions; i++) {
-        jpcIndices[i*2] = *pResolution++;
-        jpcIndices[i*2+1] = *pResolution++;
-      }
-    }
-    RESTORE_CONTROLWORD
-    delete[] resBuf;
-    env->ReleaseIntArrayElements(resolutionArray, saveFormats, 0);
   }
 
   JNU_ReleaseStringPlatformChars(env, printer, printerName);
   JNU_ReleaseStringPlatformChars(env, printer, printerPort);
   return resolutionArray;
-
-  CATCH_BAD_ALLOC_RET(NULL);
 }
 
 
@@ -672,6 +709,7 @@
   } catch (std::bad_alloc&) {
     delete [] buffer;
     JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
+    return NULL;
   }
 
   if (printerPort == NULL) {
@@ -692,6 +730,17 @@
 {
   LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
   LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
+
+  if (printerName == NULL || printerPort == NULL) {
+      if (printerName != NULL) {
+          JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      }
+      if (printerPort != NULL) {
+          JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      }
+      return NULL;
+  }
+
   // 0x1000 is a flag to indicate that getCapabilities has already been called.
   // 0x0001 is a flag for color support and supported is the default.
   jint ret = 0x1001;
@@ -761,28 +810,41 @@
   HANDLE      hPrinter;
   LPDEVMODE   pDevMode = NULL;
 
-  TRY;
-
   LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
   LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);
 
-  jintArray defaultArray = env->NewIntArray(NDEFAULT);
-  if (defaultArray == NULL) {
-      throw std::bad_alloc();
+  if (printerName == NULL || printerPort == NULL) {
+      if (printerName != NULL) {
+          JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      }
+      if (printerPort != NULL) {
+          JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      }
+      return NULL;
   }
 
-  jboolean isCopy;
-  jint *defIndices = env->GetIntArrayElements(defaultArray,
-                                          &isCopy), *saveFormats = defIndices;
+  jint* defIndices = NULL;
+  jintArray defaultArray = env->NewIntArray(NDEFAULT);
+  if (defaultArray != NULL) {
+      defIndices = env->GetIntArrayElements(defaultArray, NULL);
+  }
+  if (defIndices == NULL) {
+      JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      JNU_ReleaseStringPlatformChars(env, port, printerPort);
+      return NULL;
+  }
 
-  for (int i=0; i<NDEFAULT; i++) {
-      defIndices[i]=GETDEFAULT_ERROR;
+  jint *saveFormats = defIndices;
+
+  for (int i=0; i < NDEFAULT; i++) {
+      defIndices[i] = GETDEFAULT_ERROR;
   }
 
   /* Start by opening the printer */
   if (!::OpenPrinter(printerName, &hPrinter, NULL)) {
       env->ReleaseIntArrayElements(defaultArray, saveFormats, 0);
       JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      JNU_ReleaseStringPlatformChars(env, port, printerPort);
       return defaultArray;
   }
 
@@ -794,6 +856,7 @@
       ::ClosePrinter(hPrinter);
       env->ReleaseIntArrayElements(defaultArray, saveFormats, 0);
       JNU_ReleaseStringPlatformChars(env, printer, printerName);
+      JNU_ReleaseStringPlatformChars(env, port, printerPort);
       return defaultArray;
   }
 
@@ -863,7 +926,6 @@
       defIndices[8] = pDevMode->dmColor;
   }
 
-
   GlobalFree(pDevMode);
   ::ClosePrinter(hPrinter);
 
@@ -873,8 +935,6 @@
   JNU_ReleaseStringPlatformChars(env, port, printerPort);
 
   return defaultArray;
-
-  CATCH_BAD_ALLOC_RET(NULL);
 }
 
 
@@ -891,6 +951,9 @@
     int ret=0;
 
     LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
+    if (printerName == NULL) {
+        return -1;
+    }
 
     // Start by opening the printer
     if (!::OpenPrinter(printerName, &hPrinter, NULL)) {
@@ -959,13 +1022,15 @@
   jclass myClass = env->GetObjectClass(self);
   jfieldID fieldId = env->GetFieldID(myClass, fieldName, "J");
   DASSERT(fieldId != 0);
-
   return fieldId;
 }
 
 
 static inline HANDLE getHPrinter(JNIEnv *env, jobject self) {
   jfieldID fieldId = getIdOfLongField(env, self, HPRINTER_STR);
+  if (fieldId == (jfieldID)0) {
+      return (HANDLE)NULL;
+  }
   return (HANDLE)(env->GetLongField(self, fieldId));
 }
 
@@ -979,6 +1044,9 @@
   HANDLE      hPrinter;
   DOC_INFO_1  DocInfo;
   LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL);
+  if (printerName == NULL) {
+      return false;
+  }
   DASSERT(jobname != NULL);
   LPTSTR lpJobName = (LPTSTR)JNU_GetStringPlatformChars(env, jobname, NULL);
   LPTSTR jname = _tcsdup(lpJobName);
@@ -1016,8 +1084,12 @@
 
   // store handle
   jfieldID fieldId = getIdOfLongField(env, peer, HPRINTER_STR);
-  env->SetLongField(peer, fieldId, reinterpret_cast<jlong>(hPrinter));
-  return true;
+  if (fieldId == (jfieldID)0) {
+      return false;
+  } else {
+      env->SetLongField(peer, fieldId, reinterpret_cast<jlong>(hPrinter));
+      return true;
+  }
 }
 
 
@@ -1039,6 +1111,9 @@
 
   try {
     data=(jbyte *)env->GetPrimitiveArrayCritical(dataArray, 0);
+    if (data == NULL) {
+        return false;
+    }
 
     // Send the data to the printer.
     if( ! ::WritePrinter(hPrinter, data, count,(LPDWORD)&dwBytesWritten)) {
--- a/src/windows/native/sun/windows/awt.h	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt.h	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,8 @@
 class AwtObject;
 typedef AwtObject* PDATA;
 
+#define JNI_IS_TRUE(obj) ((obj) ? JNI_TRUE : JNI_FALSE)
+
 #define JNI_CHECK_NULL_GOTO(obj, msg, where) {                            \
     if (obj == NULL) {                                                    \
         env->ExceptionClear();                                            \
--- a/src/windows/native/sun/windows/awt_Choice.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Choice.cpp	Thu May 01 14:21:29 2014 -0700
@@ -157,6 +157,7 @@
                                                      "preferredSize",
                                                      "()Ljava/awt/Dimension;").l;
             DASSERT(!safe_ExceptionOccurred(env));
+            if (env->ExceptionCheck()) goto done;
 
             if (dimension != NULL && width == 0) {
                 width = env->GetIntField(dimension, AwtDimension::widthID);
@@ -337,9 +338,8 @@
                                              "preferredSize",
                                              "()Ljava/awt/Dimension;").l;
     DASSERT(!safe_ExceptionOccurred(env));
-    if (dimension == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(dimension, NULL);
+
     /* This size is window size of choice and it's too big for each
      * drop down item height.
      */
@@ -605,7 +605,8 @@
            for (i = 0; i < itemCount; i++)
            {
                jstring item = (jstring)env->GetObjectArrayElement(items, i);
-               JNI_CHECK_NULL_GOTO(item, "null item", next_elem);
+               if (env->ExceptionCheck()) goto done;
+               if (item == NULL) goto next_elem;
                c->SendMessage(CB_INSERTSTRING, index + i, JavaStringBuffer(env, item));
                env->DeleteLocalRef(item);
 next_elem:
--- a/src/windows/native/sun/windows/awt_Component.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Component.cpp	Thu May 01 14:21:29 2014 -0700
@@ -1729,9 +1729,11 @@
       case WM_IME_SETCONTEXT:
           // lParam is passed as pointer and it can be modified.
           mr = WmImeSetContext(static_cast<BOOL>(wParam), &lParam);
+          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
           break;
       case WM_IME_NOTIFY:
           mr = WmImeNotify(wParam, lParam);
+          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
           break;
       case WM_IME_STARTCOMPOSITION:
           mr = WmImeStartComposition();
@@ -4085,7 +4087,7 @@
 {
     if (mr != mrConsume)  {
         HWND proxy = GetProxyFocusOwner();
-        if (proxy != NULL) {
+        if (proxy != NULL && ::IsWindowEnabled(proxy)) {
             retVal = ComCtl32Util::GetInstance().DefWindowProc(NULL, proxy, message, wParam, lParam);
             mr = mrConsume;
         }
@@ -6112,7 +6114,7 @@
     c = (AwtComponent *)pData;
     if (::IsWindow(c->GetHWnd()))
     {
-        result = (jboolean)c->InheritsNativeMouseWheelBehavior();
+        result = JNI_IS_TRUE(c->InheritsNativeMouseWheelBehavior());
     }
 ret:
     env->DeleteGlobalRef(self);
@@ -6928,9 +6930,9 @@
 {
     TRY;
 
-    return (jboolean)AwtToolkit::GetInstance().SyncCall(
+    return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall(
         (void *(*)(void *))AwtComponent::_NativeHandlesWheelScrolling,
-        env->NewGlobalRef(self));
+        env->NewGlobalRef(self)));
     // global ref is deleted in _NativeHandlesWheelScrolling
 
     CATCH_BAD_ALLOC_RET(NULL);
@@ -6949,9 +6951,9 @@
 
     jobject selfGlobalRef = env->NewGlobalRef(self);
 
-    return (jboolean)AwtToolkit::GetInstance().SyncCall(
+    return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall(
         (void*(*)(void*))AwtComponent::_IsObscured,
-        (void *)selfGlobalRef);
+        (void *)selfGlobalRef));
     // selfGlobalRef is deleted in _IsObscured
 
     CATCH_BAD_ALLOC_RET(NULL);
--- a/src/windows/native/sun/windows/awt_Font.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Font.cpp	Thu May 01 14:21:29 2014 -0700
@@ -49,9 +49,12 @@
     if (obj == NULL) {
         return JNI_FALSE;
     }
-    if (env->EnsureLocalCapacity(2))
+    if (env->EnsureLocalCapacity(2)) {
+        env->ExceptionClear();
         return JNI_FALSE;
+    }
     jobject peer = env->CallObjectMethod(obj, AwtFont::peerMID);
+    env->ExceptionClear();
     if (peer == NULL) {
         return JNI_FALSE;
     }
@@ -66,10 +69,12 @@
 {
     DASSERT(font != NULL);
     if (env->EnsureLocalCapacity(2)) {
+        env->ExceptionClear();
         return NULL;
     }
     jobject peer = env->CallObjectMethod(font, AwtFont::peerMID);
     DASSERT(peer != NULL);
+    if (peer == NULL) return NULL;
     jstring textComponentFontName =
             (jstring) env->GetObjectField(peer, AwtFont::textComponentFontNameID);
     env->DeleteLocalRef(peer);
@@ -191,6 +196,9 @@
     }
 
     awtFont = Create(env, font, angle, awScale);
+    if (awtFont == NULL) {
+        return NULL;
+    }
 
     env->SetLongField(font, AwtFont::pDataID,
         reinterpret_cast<jlong>(awtFont));
@@ -272,6 +280,9 @@
         if (cfnum > 0) {
             // Ask peer class for the text component font name
             jstring jTextComponentFontName = GetTextComponentFontName(env, font);
+            if (jTextComponentFontName == NULL) {
+                return NULL;
+            }
             LPCWSTR textComponentFontName = JNU_GetStringPlatformChars(env, jTextComponentFontName, NULL);
 
             awtFont->m_textInput = -1;
@@ -285,6 +296,9 @@
                                                  AwtFont::nativeNameID);
                 wName = JNU_GetStringPlatformChars(env, nativeName, NULL);
                 DASSERT(wName);
+                if (wName == NULL) {
+                    wName = L"Arial";
+                }
 
                 //On NT platforms, if the font is not Symbol or Dingbats
                 //use "W" version of Win32 APIs directly, info the FontDescription
@@ -321,7 +335,12 @@
             // Instantiation for English version.
             jstring fontName = (jstring)env->GetObjectField(font,
                                                             AwtFont::nameID);
-            wName = JNU_GetStringPlatformChars(env, fontName, NULL);
+            if (fontName != NULL) {
+                wName = JNU_GetStringPlatformChars(env, fontName, NULL);
+            }
+            if (wName == NULL) {
+                wName = L"Arial";
+            }
 
             WCHAR* wEName;
             if (!wcscmp(wName, L"Helvetica") || !wcscmp(wName, L"SansSerif")) {
@@ -647,6 +666,9 @@
     //"useUnicode" field might not be initialized correctly (font in Menu Component,
     //for example").
     AwtFont* awtFont = AwtFont::GetFont(env, font);
+    if (awtFont == NULL) {
+        return size;
+    }
 
     if (IsMultiFont(env, font)) {
         jobject peer = env->CallObjectMethod(font, AwtFont::peerMID);
@@ -668,6 +690,9 @@
     if (arrayLength == 0) {
         int length = env->GetStringLength(str);
         LPCWSTR strW = JNU_GetStringPlatformChars(env, str, NULL);
+        if (strW == NULL) {
+            return size;
+        }
         VERIFY(::SelectObject(hDC, awtFont->GetHFont()));
         if (AwtComponent::GetRTLReadingOrder()){
             VERIFY(!draw || ::ExtTextOut(hDC, x, y, ETO_RTLREADING, NULL,
@@ -692,6 +717,9 @@
             }
 
             int fdIndex = getFontDescriptorNumber(env, font, fontDescriptor);
+            if (env->ExceptionCheck()) {
+                return size;  //fdIndex==0 return could be exception or not.
+            }
             VERIFY(::SelectObject(hDC, awtFont->GetHFont(fdIndex)));
 
             /*
@@ -705,10 +733,14 @@
              * extend buflen and bad things will happen.
              */
             unsigned char* buffer = NULL;
-            jboolean unicodeUsed = env->GetBooleanField(fontDescriptor, AwtFont::useUnicodeID);
+            jboolean unicodeUsed =
+                env->GetBooleanField(fontDescriptor, AwtFont::useUnicodeID);
             try {
                 buffer = (unsigned char *)
                     env->GetPrimitiveArrayCritical(convertedBytes, 0);
+                if (buffer == NULL) {
+                    return size;
+                }
                 int buflen = (buffer[0] << 24) | (buffer[1] << 16) |
                     (buffer[2] << 8) | buffer[3];
 
@@ -816,8 +848,11 @@
     jchar *strp = new jchar[len];
     env->GetCharArrayRegion(str, off, len, strp);
     jstring jstr = env->NewString(strp, len);
-    jint result = Java_sun_awt_windows_WFontMetrics_stringWidth(env, self,
-                                                                jstr);
+    jint result = 0;
+    if (jstr != NULL) {
+        result = Java_sun_awt_windows_WFontMetrics_stringWidth(env, self,
+                                                               jstr);
+    }
     delete [] strp;
     return result;
 
@@ -850,13 +885,25 @@
     try {
         jintArray array = (jintArray)env->GetObjectField(self,
                                                          AwtFont::widthsID);
+        if (array == NULL) {
+            JNU_ThrowNullPointerException(env, "Can't access widths array.");
+            return NULL;
+        }
         pStrBody = (char *)env->GetPrimitiveArrayCritical(str, 0);
+        if (pStrBody == NULL) {
+            JNU_ThrowNullPointerException(env, "Can't access str bytes.");
+            return NULL;
+        }
         char *pStr = pStrBody + off;
 
         jint *widths = NULL;
         try {
             widths = (jint *)env->GetPrimitiveArrayCritical(array, 0);
-
+            if (widths == NULL) {
+                env->ReleasePrimitiveArrayCritical(str, pStrBody, 0);
+                JNU_ThrowNullPointerException(env, "Can't access widths.");
+                return NULL;
+            }
             for (; len; len--) {
                 result += widths[*pStr++];
             }
@@ -915,29 +962,15 @@
 JNIEXPORT void JNICALL
 Java_sun_awt_windows_WFontMetrics_initIDs(JNIEnv *env, jclass cls)
 {
-    TRY;
-
-    AwtFont::widthsID = env->GetFieldID(cls, "widths", "[I");
-    AwtFont::ascentID = env->GetFieldID(cls, "ascent", "I");
-    AwtFont::descentID = env->GetFieldID(cls, "descent", "I");
-    AwtFont::leadingID = env->GetFieldID(cls, "leading", "I");
-    AwtFont::heightID = env->GetFieldID(cls, "height", "I");
-    AwtFont::maxAscentID = env->GetFieldID(cls, "maxAscent", "I");
-    AwtFont::maxDescentID = env->GetFieldID(cls, "maxDescent", "I");
-    AwtFont::maxHeightID = env->GetFieldID(cls, "maxHeight", "I");
-    AwtFont::maxAdvanceID = env->GetFieldID(cls, "maxAdvance", "I");
-
-    DASSERT(AwtFont::widthsID != NULL);
-    DASSERT(AwtFont::ascentID != NULL);
-    DASSERT(AwtFont::descentID != NULL);
-    DASSERT(AwtFont::leadingID != NULL);
-    DASSERT(AwtFont::heightID != NULL);
-    DASSERT(AwtFont::maxAscentID != NULL);
-    DASSERT(AwtFont::maxDescentID != NULL);
-    DASSERT(AwtFont::maxHeightID != NULL);
-    DASSERT(AwtFont::maxAdvanceID != NULL);
-
-    CATCH_BAD_ALLOC;
+   CHECK_NULL(AwtFont::widthsID = env->GetFieldID(cls, "widths", "[I"));
+   CHECK_NULL(AwtFont::ascentID = env->GetFieldID(cls, "ascent", "I"));
+   CHECK_NULL(AwtFont::descentID = env->GetFieldID(cls, "descent", "I"));
+   CHECK_NULL(AwtFont::leadingID = env->GetFieldID(cls, "leading", "I"));
+   CHECK_NULL(AwtFont::heightID = env->GetFieldID(cls, "height", "I"));
+   CHECK_NULL(AwtFont::maxAscentID = env->GetFieldID(cls, "maxAscent", "I"));
+   CHECK_NULL(AwtFont::maxDescentID = env->GetFieldID(cls, "maxDescent", "I"));
+   CHECK_NULL(AwtFont::maxHeightID = env->GetFieldID(cls, "maxHeight", "I"));
+   AwtFont::maxAdvanceID = env->GetFieldID(cls, "maxAdvance", "I");
 }
 
 } /* extern "C" */
@@ -952,28 +985,16 @@
 JNIEXPORT void JNICALL
 Java_java_awt_Font_initIDs(JNIEnv *env, jclass cls)
 {
-    TRY;
-
-    AwtFont::peerMID = env->GetMethodID(cls, "getPeer",
-                                        "()Ljava/awt/peer/FontPeer;");
-    AwtFont::pDataID = env->GetFieldID(cls, "pData", "J");
-    AwtFont::nameID = env->GetFieldID(cls, "name", "Ljava/lang/String;");
-    AwtFont::sizeID = env->GetFieldID(cls, "size", "I");
-    AwtFont::styleID = env->GetFieldID(cls, "style", "I");
-
+    CHECK_NULL(AwtFont::peerMID = env->GetMethodID(cls, "getPeer",
+         "()Ljava/awt/peer/FontPeer;"));
+    CHECK_NULL(AwtFont::pDataID = env->GetFieldID(cls, "pData", "J"));
+    CHECK_NULL(AwtFont::nameID =
+         env->GetFieldID(cls, "name", "Ljava/lang/String;"));
+    CHECK_NULL(AwtFont::sizeID = env->GetFieldID(cls, "size", "I"));
+    CHECK_NULL(AwtFont::styleID = env->GetFieldID(cls, "style", "I"));
     AwtFont::getFontMID =
       env->GetStaticMethodID(cls, "getFont",
                              "(Ljava/lang/String;)Ljava/awt/Font;");
-
-    DASSERT(AwtFont::peerMID != NULL);
-    DASSERT(AwtFont::pDataID != NULL);
-    DASSERT(AwtFont::nameID != NULL);
-    DASSERT(AwtFont::sizeID != NULL);
-    DASSERT(AwtFont::styleID != NULL);
-
-    DASSERT(AwtFont::getFontMID != NULL);
-
-    CATCH_BAD_ALLOC;
 }
 
 } /* extern "C" */
@@ -988,15 +1009,9 @@
 JNIEXPORT void JNICALL
 Java_java_awt_FontMetrics_initIDs(JNIEnv *env, jclass cls)
 {
-    TRY;
-
-    AwtFont::fontID = env->GetFieldID(cls, "font", "Ljava/awt/Font;");
+    CHECK_NULL(AwtFont::fontID =
+          env->GetFieldID(cls, "font", "Ljava/awt/Font;"));
     AwtFont::getHeightMID = env->GetMethodID(cls, "getHeight", "()I");
-
-    DASSERT(AwtFont::fontID);
-    DASSERT(AwtFont::getHeightMID);
-
-    CATCH_BAD_ALLOC;
 }
 
 } /* extern "C" */
@@ -1010,16 +1025,10 @@
 JNIEXPORT void JNICALL
 Java_sun_awt_FontDescriptor_initIDs(JNIEnv *env, jclass cls)
 {
-    TRY;
-
-    AwtFont::nativeNameID = env->GetFieldID(cls, "nativeName",
-                                            "Ljava/lang/String;");
+    CHECK_NULL(AwtFont::nativeNameID =
+               env->GetFieldID(cls, "nativeName", "Ljava/lang/String;"));
     AwtFont::useUnicodeID = env->GetFieldID(cls, "useUnicode", "Z");
 
-    DASSERT(AwtFont::nativeNameID != NULL);
-    DASSERT(AwtFont::useUnicodeID != NULL);
-
-    CATCH_BAD_ALLOC;
 }
 
 } /* extern "C" */
@@ -1034,20 +1043,13 @@
 JNIEXPORT void JNICALL
 Java_sun_awt_PlatformFont_initIDs(JNIEnv *env, jclass cls)
 {
-    TRY;
-
-    AwtFont::fontConfigID = env->GetFieldID(cls, "fontConfig", "Lsun/awt/FontConfiguration;");
-    AwtFont::componentFontsID =
-        env->GetFieldID(cls, "componentFonts", "[Lsun/awt/FontDescriptor;");
+    CHECK_NULL(AwtFont::fontConfigID =
+        env->GetFieldID(cls, "fontConfig", "Lsun/awt/FontConfiguration;"));
+    CHECK_NULL(AwtFont::componentFontsID =
+        env->GetFieldID(cls, "componentFonts", "[Lsun/awt/FontDescriptor;"));
     AwtFont::makeConvertedMultiFontStringMID =
         env->GetMethodID(cls, "makeConvertedMultiFontString",
                          "(Ljava/lang/String;)[Ljava/lang/Object;");
-
-    DASSERT(AwtFont::makeConvertedMultiFontStringMID != NULL);
-    DASSERT(AwtFont::componentFontsID != NULL);
-    DASSERT(AwtFont::fontConfigID != NULL);
-
-    CATCH_BAD_ALLOC;
 }
 
 } /* extern "C" */
@@ -1862,8 +1864,10 @@
     static CCombinedSegTableManager tableManager;
 
     jstring fontName = (jstring)env->GetObjectField(self, AwtFont::fontNameID);
-    DASSERT(fontName != NULL);
+    DASSERT(fontName != NULL); // leave in for debug mode.
+    CHECK_NULL_RETURN(fontName, FALSE);  // in production, just return
     LPCWSTR fontNameW = JNU_GetStringPlatformChars(env, fontName, NULL);
+    CHECK_NULL_RETURN(fontNameW, FALSE);
     CCombinedSegTable* pTable = tableManager.GetTable(fontNameW);
     JNU_ReleaseStringPlatformChars(env, fontName, fontNameW);
     return (pTable->In((USHORT) ch) ? JNI_TRUE : JNI_FALSE);
--- a/src/windows/native/sun/windows/awt_Frame.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_Frame.cpp	Thu May 01 14:21:29 2014 -0700
@@ -351,6 +351,8 @@
         case WM_IME_STARTCOMPOSITION:
         case WM_IME_ENDCOMPOSITION:
         case WM_IME_COMPOSITION:
+        case WM_IME_SETCONTEXT:
+        case WM_IME_NOTIFY:
         case WM_IME_CONTROL:
         case WM_IME_COMPOSITIONFULL:
         case WM_IME_SELECT:
--- a/src/windows/native/sun/windows/awt_InputMethod.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_InputMethod.cpp	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -320,13 +320,18 @@
     // current language ID (returned from 'getJavaIDFromLangID') is in
     // ASCII encoding, so we use 'GetStringUTFChars' to retrieve requested
     // language ID from the 'localeString' object.
-    const char * current = getJavaIDFromLangID(AwtComponent::GetInputLanguage());
     jboolean isCopy;
     const char * requested = env->GetStringUTFChars(localeString, &isCopy);
-    if ((current != NULL) && (strcmp(current, requested) == 0)) {
-        env->ReleaseStringUTFChars(localeString, requested);
+    CHECK_NULL_RETURN(requested, JNI_FALSE);
+
+    const char * current = getJavaIDFromLangID(AwtComponent::GetInputLanguage());
+    if (current != NULL) {
+        if (strcmp(current, requested) == 0) {
+            env->ReleaseStringUTFChars(localeString, requested);
+            free((void *)current);
+            return JNI_TRUE;
+        }
         free((void *)current);
-        return JNI_TRUE;
     }
 
     // get list of available HKLs.  Adding the user's preferred layout on top of the layout
@@ -334,7 +339,10 @@
     // looking up suitable layout.
     int layoutCount = ::GetKeyboardLayoutList(0, NULL) + 1;  // +1 for user's preferred HKL
     HKL FAR * hKLList = (HKL FAR *)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(HKL), layoutCount);
-    DASSERT(!safe_ExceptionOccurred(env));
+    if (hKLList == NULL) {
+        env->ReleaseStringUTFChars(localeString, requested);
+        return JNI_FALSE;
+    }
     ::GetKeyboardLayoutList(layoutCount - 1, &(hKLList[1]));
     hKLList[0] = getDefaultKeyboardLayout(); // put user's preferred layout on top of the list
 
@@ -342,20 +350,23 @@
     jboolean retValue = JNI_FALSE;
     for (int i = 0; i < layoutCount; i++) {
         const char * supported = getJavaIDFromLangID(LOWORD(hKLList[i]));
-        if ((supported != NULL) && (strcmp(supported, requested) == 0)) {
-            // use special message to call ActivateKeyboardLayout() in main thread.
-            if (AwtToolkit::GetInstance().SendMessage(WM_AWT_ACTIVATEKEYBOARDLAYOUT, (WPARAM)onActivate, (LPARAM)hKLList[i])) {
-                //also need to change the same keyboard layout for the Java AWT-EventQueue thread
-                AwtToolkit::activateKeyboardLayout(hKLList[i]);
-                retValue = JNI_TRUE;
+        if (supported != NULL) {
+            if (strcmp(supported, requested) == 0) {
+                // use special message to call ActivateKeyboardLayout() in main thread.
+                if (AwtToolkit::GetInstance().SendMessage(WM_AWT_ACTIVATEKEYBOARDLAYOUT, (WPARAM)onActivate, (LPARAM)hKLList[i])) {
+                    //also need to change the same keyboard layout for the Java AWT-EventQueue thread
+                    AwtToolkit::activateKeyboardLayout(hKLList[i]);
+                    retValue = JNI_TRUE;
+                }
+                free((void *)supported);
+                break;
             }
-            break;
+            free((void *)supported);
         }
     }
 
     env->ReleaseStringUTFChars(localeString, requested);
     free(hKLList);
-    free((void *)current);
     return retValue;
 
     CATCH_BAD_ALLOC_RET(JNI_FALSE);
@@ -445,7 +456,7 @@
     // get list of available HKLs
     int layoutCount = ::GetKeyboardLayoutList(0, NULL);
     HKL FAR * hKLList = (HKL FAR *)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(HKL), layoutCount);
-    DASSERT(!safe_ExceptionOccurred(env));
+    CHECK_NULL_RETURN(hKLList, NULL);
     ::GetKeyboardLayoutList(layoutCount, hKLList);
 
     // get list of Java locale names while getting rid of duplicates
@@ -453,8 +464,13 @@
     int destIndex = 0;
     int javaLocaleNameCount = 0;
     int current = 0;
+
     const char ** javaLocaleNames = (const char **)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(char *), layoutCount);
-    DASSERT(!safe_ExceptionOccurred(env));
+    if (javaLocaleNames == NULL) {
+        free(hKLList);
+        return NULL;
+    }
+
     for (; srcIndex < layoutCount; srcIndex++) {
         const char * srcLocaleName = getJavaIDFromLangID(LOWORD(hKLList[srcIndex]));
 
@@ -477,18 +493,33 @@
         }
     }
 
+    jobjectArray locales = NULL;
     // convert it to an array of Java locale objects
     jclass localeClass = env->FindClass("java/util/Locale");
-    jobjectArray locales = env->NewObjectArray(javaLocaleNameCount, localeClass, NULL);
+    if (localeClass != NULL) {
+        locales = env->NewObjectArray(javaLocaleNameCount, localeClass, NULL);
+        if (locales != NULL) {
+
+            for (current = 0; current < javaLocaleNameCount; current++) {
+                jobject obj = CreateLocaleObject(env, javaLocaleNames[current]);
+                if (env->ExceptionCheck()) {
+                    env->DeleteLocalRef(locales);
+                    locales = NULL;
+                    break;
+                }
+                env->SetObjectArrayElement(locales,
+                                           current,
+                                           obj);
+            }
+
+        }
+        env->DeleteLocalRef(localeClass);
+    }
+
     for (current = 0; current < javaLocaleNameCount; current++) {
-        env->SetObjectArrayElement(locales,
-                                   current,
-                                   CreateLocaleObject(env, javaLocaleNames[current]));
         free((void *)javaLocaleNames[current]);
     }
-    DASSERT(!safe_ExceptionOccurred(env));
 
-    env->DeleteLocalRef(localeClass);
     free(hKLList);
     free(javaLocaleNames);
     return locales;
@@ -542,6 +573,7 @@
 
     // create Locale object
     jobject langtagObj = env->NewStringUTF(name);
+    CHECK_NULL_RETURN(langtagObj, NULL);
     jobject localeObj = JNU_CallStaticMethodByName(env,
                                                    NULL,
                                                    "java/util/Locale",
--- a/src/windows/native/sun/windows/awt_List.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_List.cpp	Thu May 01 14:21:29 2014 -0700
@@ -614,7 +614,8 @@
             {
                 LPTSTR itemPtr = NULL;
                 jstring item = (jstring)env->GetObjectArrayElement(items, i);
-                JNI_CHECK_NULL_GOTO(item, "null item", next_item);
+                if (env->ExceptionCheck()) goto ret;
+                if (item == NULL) goto next_item;
                 itemPtr = (LPTSTR)JNU_GetStringPlatformChars(env, item, 0);
                 if (itemPtr == NULL)
                 {
@@ -1017,8 +1018,8 @@
     ses->list = env->NewGlobalRef(self);
     ses->index = index;
 
-    return (jboolean)AwtToolkit::GetInstance().SyncCall(
-        (void *(*)(void *))AwtList::_IsSelected, ses);
+    return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall(
+                       (void *(*)(void *))AwtList::_IsSelected, ses));
     // global ref and ses are deleted in _IsSelected
 
     CATCH_BAD_ALLOC_RET(FALSE);
--- a/src/windows/native/sun/windows/awt_MenuItem.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_MenuItem.cpp	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -152,6 +152,9 @@
         if (dw == ERROR_OUTOFMEMORY)
         {
             jstring errorMsg = JNU_NewStringPlatform(env, L"too many menu handles");
+            if (errorMsg == NULL) {
+                throw std::bad_alloc();
+            }
             createError = JNU_NewObjectByName(env, "java/lang/OutOfMemoryError",
                                                    "(Ljava/lang/String;)V",
                                                    errorMsg);
@@ -164,16 +167,19 @@
                 NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                 (LPTSTR)&buf, 0, NULL);
             jstring s = JNU_NewStringPlatform(env, buf);
+            if (s == NULL) {
+                throw std::bad_alloc();
+            }
             createError = JNU_NewObjectByName(env, "java/lang/InternalError",
                                                    "(Ljava/lang/String;)V", s);
             LocalFree(buf);
             env->DeleteLocalRef(s);
         }
+        if (createError == NULL) {
+            throw std::bad_alloc();
+        }
         env->SetObjectField(self, AwtObject::createErrorID, createError);
-        if (createError != NULL)
-        {
-            env->DeleteLocalRef(createError);
-        }
+        env->DeleteLocalRef(createError);
         return FALSE;
     }
     return TRUE;
@@ -238,12 +244,18 @@
     jobject self = GetPeer(env);
     jobject target = env->GetObjectField(self, AwtObject::targetID);
     jobject font = JNU_CallMethodByName(env, 0, target, "getFont_NoClientCode", "()Ljava/awt/Font;").l;
+    env->DeleteLocalRef(target);
+    if (env->ExceptionCheck()) {
+        throw std::bad_alloc();
+    }
 
     if (font == NULL) {
         font = env->NewLocalRef(GetDefaultFont(env));
+        if (env->ExceptionCheck()) {
+            throw std::bad_alloc();
+        }
     }
 
-    env->DeleteLocalRef(target);
     return font;
 }
 
@@ -251,13 +263,22 @@
 AwtMenuItem::GetDefaultFont(JNIEnv *env) {
     if (AwtMenuItem::systemFont == NULL) {
         jclass cls = env->FindClass("sun/awt/windows/WMenuItemPeer");
-        DASSERT(cls != NULL);
+        if (cls == NULL) {
+            throw std::bad_alloc();
+        }
 
         AwtMenuItem::systemFont =
             env->CallStaticObjectMethod(cls, AwtMenuItem::getDefaultFontMID);
-        DASSERT(AwtMenuItem::systemFont);
+        if (env->ExceptionCheck()) {
+            env->DeleteLocalRef(cls);
+            throw std::bad_alloc();
+        }
 
         AwtMenuItem::systemFont = env->NewGlobalRef(AwtMenuItem::systemFont);
+        if (systemFont == NULL) {
+            env->DeleteLocalRef(cls);
+            throw std::bad_alloc();
+        }
     }
     return AwtMenuItem::systemFont;
 }
@@ -284,8 +305,19 @@
     DWORD crBack,crText;
     HBRUSH hbrBack;
 
-    jobject font = GetFont(env);
+    jobject font;
+    try {
+        font = GetFont(env);
+    } catch (std::bad_alloc&) {
+        env->DeleteLocalRef(target);
+        throw;
+    }
+
     jstring text = GetJavaString(env);
+    if (env->ExceptionCheck()) {
+        env->DeleteLocalRef(target);
+        throw std::bad_alloc();
+    }
     size = AwtFont::getMFStringSize(hDC, font, text);
 
     /* 4700350: If the font size is taller than the menubar, change to the
@@ -294,7 +326,13 @@
      */
     if (IsTopMenu() && size.cy > ::GetSystemMetrics(SM_CYMENU)) {
         env->DeleteLocalRef(font);
-        font = env->NewLocalRef(GetDefaultFont(env));
+        try {
+            font = env->NewLocalRef(GetDefaultFont(env));
+        } catch (std::bad_alloc&) {
+            env->DeleteLocalRef(target);
+            env->DeleteLocalRef(text);
+            throw;
+        }
         size = AwtFont::getMFStringSize(hDC, font, text);
     }
 
@@ -452,6 +490,10 @@
     /* font is a java.awt.Font */
     jobject font = GetFont(env);
     jstring text = GetJavaString(env);
+    if (env->ExceptionCheck()) {
+        env->DeleteLocalRef(font);
+        throw std::bad_alloc();
+    }
     SIZE size = AwtFont::getMFStringSize(hDC, font, text);
 
     /* 4700350: If the font size is taller than the menubar, change to the
@@ -459,7 +501,14 @@
      * client area.  -bchristi
      */
     if (IsTopMenu() && size.cy > ::GetSystemMetrics(SM_CYMENU)) {
-        jobject defFont = GetDefaultFont(env);
+        jobject defFont;
+        try {
+            defFont = GetDefaultFont(env);
+        } catch (std::bad_alloc&) {
+            env->DeleteLocalRef(text);
+            env->DeleteLocalRef(font);
+            throw;
+        }
         env->DeleteLocalRef(font);
         font = env->NewLocalRef(defFont);
         size = AwtFont::getMFStringSize(hDC, font, text);
@@ -468,13 +517,31 @@
     jstring fontName =
         (jstring)JNU_CallMethodByName(env, 0,font, "getName",
                                       "()Ljava/lang/String;").l;
+    if (env->ExceptionCheck()) {
+        env->DeleteLocalRef(text);
+        env->DeleteLocalRef(font);
+        throw std::bad_alloc();
+    }
+
     /* fontMetrics is a Hsun_awt_windows_WFontMetrics */
     jobject fontMetrics =  GetFontMetrics(env, font);
-
+    if (env->ExceptionCheck()) {
+        env->DeleteLocalRef(text);
+        env->DeleteLocalRef(font);
+        env->DeleteLocalRef(fontName);
+        throw std::bad_alloc();
+    }
 
 //     int height = env->GetIntField(fontMetrics, AwtFont::heightID);
     int height = (jint)JNU_CallMethodByName(env, 0, fontMetrics, "getHeight",
                                             "()I").i;
+    if (env->ExceptionCheck()) {
+        env->DeleteLocalRef(text);
+        env->DeleteLocalRef(font);
+        env->DeleteLocalRef(fontName);
+        env->DeleteLocalRef(fontMetrics);
+        throw std::bad_alloc();
+    }
 
     measureInfo.itemHeight = height;
     measureInfo.itemHeight += measureInfo.itemHeight/3;
@@ -520,10 +587,14 @@
         if (env->PushLocalFrame(2) < 0)
             return NULL;
         jclass cls = env->FindClass("java/awt/Toolkit");
+        CHECK_NULL_RETURN(cls, NULL);
         jobject toolkitLocal =
             env->CallStaticObjectMethod(cls, AwtToolkit::getDefaultToolkitMID);
+        env->DeleteLocalRef(cls);
+        CHECK_NULL_RETURN(toolkitLocal, NULL);
         toolkit = env->NewGlobalRef(toolkitLocal);
-        DASSERT(!safe_ExceptionOccurred(env));
+        env->DeleteLocalRef(toolkitLocal);
+        CHECK_NULL_RETURN(toolkit, NULL);
         env->PopLocalFrame(0);
     }
     /*
@@ -739,6 +810,10 @@
             {
                 empty = JNU_NewStringPlatform(env, TEXT(""));
             }
+            if (env->ExceptionCheck()) {
+                badAlloc = 1;
+                goto ret;
+            }
             LPCTSTR labelPtr;
             if (empty != NULL)
             {
@@ -846,10 +921,9 @@
     TRY;
 
     AwtMenuItem::fontID = env->GetFieldID(cls, "font", "Ljava/awt/Font;");
+    CHECK_NULL(AwtMenuItem::fontID);
     AwtMenuItem::appContextID = env->GetFieldID(cls, "appContext", "Lsun/awt/AppContext;");
 
-    DASSERT(AwtMenuItem::fontID != NULL);
-
     CATCH_BAD_ALLOC;
 }
 
@@ -868,11 +942,9 @@
     TRY;
 
     AwtMenuItem::labelID = env->GetFieldID(cls, "label", "Ljava/lang/String;");
+    CHECK_NULL(AwtMenuItem::labelID);
     AwtMenuItem::enabledID = env->GetFieldID(cls, "enabled", "Z");
 
-    DASSERT(AwtMenuItem::labelID != NULL);
-    DASSERT(AwtMenuItem::enabledID != NULL);
-
     CATCH_BAD_ALLOC;
 }
 
@@ -892,8 +964,6 @@
 
     AwtMenuItem::stateID = env->GetFieldID(cls, "state", "Z");
 
-    DASSERT(AwtMenuItem::stateID != NULL);
-
     CATCH_BAD_ALLOC;
 }
 
@@ -917,15 +987,13 @@
     TRY;
 
     AwtMenuItem::isCheckboxID = env->GetFieldID(cls, "isCheckbox", "Z");
+    CHECK_NULL(AwtMenuItem::isCheckboxID);
     AwtMenuItem::shortcutLabelID = env->GetFieldID(cls, "shortcutLabel",
                                                    "Ljava/lang/String;");
+    CHECK_NULL(AwtMenuItem::shortcutLabelID);
     AwtMenuItem::getDefaultFontMID =
         env->GetStaticMethodID(cls, "getDefaultFont", "()Ljava/awt/Font;");
 
-    DASSERT(AwtMenuItem::isCheckboxID != NULL);
-    DASSERT(AwtMenuItem::shortcutLabelID != NULL);
-    DASSERT(AwtMenuItem::getDefaultFontMID != NULL);
-
     CATCH_BAD_ALLOC;
 }
 
--- a/src/windows/native/sun/windows/awt_PrintControl.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_PrintControl.cpp	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -233,107 +233,166 @@
     TRY;
 
     jclass cls = env->FindClass("sun/awt/windows/WPrinterJob");
+    CHECK_NULL(cls);
 
     AwtPrintControl::dialogOwnerPeerID =
       env->GetFieldID(cls, "dialogOwnerPeer", "Ljava/awt/peer/ComponentPeer;");
+    DASSERT(AwtPrintControl::dialogOwnerPeerID != NULL);
+    CHECK_NULL(AwtPrintControl::dialogOwnerPeerID);
+
     AwtPrintControl::getPrintDCID = env->GetMethodID(cls, "getPrintDC", "()J");
+    DASSERT(AwtPrintControl::getPrintDCID != NULL);
+    CHECK_NULL(AwtPrintControl::getPrintDCID);
+
     AwtPrintControl::setPrintDCID =
         env->GetMethodID(cls, "setPrintDC", "(J)V");
+    DASSERT(AwtPrintControl::setPrintDCID != NULL);
+    CHECK_NULL(AwtPrintControl::setPrintDCID);
+
     AwtPrintControl::getDevmodeID = env->GetMethodID(cls, "getDevMode", "()J");
+    DASSERT(AwtPrintControl::getDevmodeID != NULL);
+    CHECK_NULL(AwtPrintControl::getDevmodeID);
+
     AwtPrintControl::setDevmodeID =
         env->GetMethodID(cls, "setDevMode", "(J)V");
+    DASSERT(AwtPrintControl::setDevmodeID != NULL);
+    CHECK_NULL(AwtPrintControl::setDevmodeID);
+
     AwtPrintControl::getDevnamesID =
         env->GetMethodID(cls, "getDevNames", "()J");
+    DASSERT(AwtPrintControl::getDevnamesID != NULL);
+    CHECK_NULL(AwtPrintControl::getDevnamesID);
+
     AwtPrintControl::setDevnamesID =
         env->GetMethodID(cls, "setDevNames", "(J)V");
+    DASSERT(AwtPrintControl::setDevnamesID != NULL);
+    CHECK_NULL(AwtPrintControl::setDevnamesID);
+
     AwtPrintControl::driverDoesMultipleCopiesID =
       env->GetFieldID(cls, "driverDoesMultipleCopies", "Z");
+    DASSERT(AwtPrintControl::driverDoesMultipleCopiesID != NULL);
+    CHECK_NULL(AwtPrintControl::driverDoesMultipleCopiesID);
+
     AwtPrintControl::driverDoesCollationID =
       env->GetFieldID(cls, "driverDoesCollation", "Z");
+    DASSERT(AwtPrintControl::driverDoesCollationID != NULL);
+    CHECK_NULL(AwtPrintControl::driverDoesCollationID);
+
     AwtPrintControl::getCopiesID =
       env->GetMethodID(cls, "getCopiesAttrib", "()I");
+    DASSERT(AwtPrintControl::getCopiesID != NULL);
+    CHECK_NULL(AwtPrintControl::getCopiesID);
+
     AwtPrintControl::getCollateID =
       env->GetMethodID(cls, "getCollateAttrib","()I");
+    DASSERT(AwtPrintControl::getCollateID != NULL);
+    CHECK_NULL(AwtPrintControl::getCollateID);
+
     AwtPrintControl::getOrientID =
       env->GetMethodID(cls, "getOrientAttrib", "()I");
+    DASSERT(AwtPrintControl::getOrientID != NULL);
+    CHECK_NULL(AwtPrintControl::getOrientID);
+
     AwtPrintControl::getFromPageID =
       env->GetMethodID(cls, "getFromPageAttrib", "()I");
+    DASSERT(AwtPrintControl::getFromPageID != NULL);
+    CHECK_NULL(AwtPrintControl::getFromPageID);
+
     AwtPrintControl::getToPageID =
       env->GetMethodID(cls, "getToPageAttrib", "()I");
+    DASSERT(AwtPrintControl::getToPageID != NULL);
+    CHECK_NULL(AwtPrintControl::getToPageID);
+
     AwtPrintControl::getMinPageID =
       env->GetMethodID(cls, "getMinPageAttrib", "()I");
+    DASSERT(AwtPrintControl::getMinPageID != NULL);
+    CHECK_NULL(AwtPrintControl::getMinPageID);
+
     AwtPrintControl::getMaxPageID =
       env->GetMethodID(cls, "getMaxPageAttrib", "()I");
+    DASSERT(AwtPrintControl::getMaxPageID != NULL);
+    CHECK_NULL(AwtPrintControl::getMaxPageID);
+
     AwtPrintControl::getDestID =
       env->GetMethodID(cls, "getDestAttrib", "()Z");
+    DASSERT(AwtPrintControl::getDestID != NULL);
+    CHECK_NULL(AwtPrintControl::getDestID);
+
     AwtPrintControl::getQualityID =
       env->GetMethodID(cls, "getQualityAttrib", "()I");
+    DASSERT(AwtPrintControl::getQualityID != NULL);
+    CHECK_NULL(AwtPrintControl::getQualityID);
+
     AwtPrintControl::getColorID =
       env->GetMethodID(cls, "getColorAttrib", "()I");
+    DASSERT(AwtPrintControl::getColorID != NULL);
+    CHECK_NULL(AwtPrintControl::getColorID);
+
     AwtPrintControl::getSidesID =
       env->GetMethodID(cls, "getSidesAttrib", "()I");
+    DASSERT(AwtPrintControl::getSidesID != NULL);
+    CHECK_NULL(AwtPrintControl::getSidesID);
+
     AwtPrintControl::getPrinterID =
       env->GetMethodID(cls, "getPrinterAttrib", "()Ljava/lang/String;");
+    DASSERT(AwtPrintControl::getPrinterID != NULL);
+    CHECK_NULL(AwtPrintControl::getPrinterID);
+
     AwtPrintControl::getWin32MediaID =
         env->GetMethodID(cls, "getWin32MediaAttrib", "()[I");
+    DASSERT(AwtPrintControl::getWin32MediaID != NULL);
+    CHECK_NULL(AwtPrintControl::getWin32MediaID);
+
     AwtPrintControl::setWin32MediaID =
       env->GetMethodID(cls, "setWin32MediaAttrib", "(III)V");
+    DASSERT(AwtPrintControl::setWin32MediaID != NULL);
+    CHECK_NULL(AwtPrintControl::setWin32MediaID);
+
     AwtPrintControl::getWin32MediaTrayID =
         env->GetMethodID(cls, "getMediaTrayAttrib", "()I");
+    DASSERT(AwtPrintControl::getWin32MediaTrayID != NULL);
+    CHECK_NULL(AwtPrintControl::getWin32MediaTrayID);
+
     AwtPrintControl::setWin32MediaTrayID =
       env->GetMethodID(cls, "setMediaTrayAttrib", "(I)V");
+    DASSERT(AwtPrintControl::setWin32MediaTrayID != NULL);
+    CHECK_NULL(AwtPrintControl::setWin32MediaTrayID);
+
     AwtPrintControl::getSelectID =
       env->GetMethodID(cls, "getSelectAttrib", "()I");
+    DASSERT(AwtPrintControl::getSelectID != NULL);
+    CHECK_NULL(AwtPrintControl::getSelectID);
+
     AwtPrintControl::getPrintToFileEnabledID =
       env->GetMethodID(cls, "getPrintToFileEnabled", "()Z");
+    DASSERT(AwtPrintControl::getPrintToFileEnabledID != NULL);
+    CHECK_NULL(AwtPrintControl::getPrintToFileEnabledID);
 
     AwtPrintControl::setNativeAttID =
       env->GetMethodID(cls, "setNativeAttributes", "(III)V");
+    DASSERT(AwtPrintControl::setNativeAttID != NULL);
+    CHECK_NULL(AwtPrintControl::setNativeAttID);
 
     AwtPrintControl::setRangeCopiesID =
       env->GetMethodID(cls, "setRangeCopiesAttribute", "(IIZI)V");
+    DASSERT(AwtPrintControl::setRangeCopiesID != NULL);
+    CHECK_NULL(AwtPrintControl::setRangeCopiesID);
+
     AwtPrintControl::setResID =
       env->GetMethodID(cls, "setResolutionDPI", "(II)V");
+    DASSERT(AwtPrintControl::setResID != NULL);
+    CHECK_NULL(AwtPrintControl::setResID);
 
     AwtPrintControl::setPrinterID =
       env->GetMethodID(cls, "setPrinterNameAttrib", "(Ljava/lang/String;)V");
+    DASSERT(AwtPrintControl::setPrinterID != NULL);
+    CHECK_NULL(AwtPrintControl::setPrinterID);
 
     AwtPrintControl::setJobAttributesID =
         env->GetMethodID(cls, "setJobAttributes",
         "(Ljavax/print/attribute/PrintRequestAttributeSet;IISSSSSSS)V");
-
-    DASSERT(AwtPrintControl::driverDoesMultipleCopiesID != NULL);
-    DASSERT(AwtPrintControl::getPrintDCID != NULL);
-    DASSERT(AwtPrintControl::setPrintDCID != NULL);
-    DASSERT(AwtPrintControl::getDevmodeID != NULL);
-    DASSERT(AwtPrintControl::setDevmodeID != NULL);
-    DASSERT(AwtPrintControl::getDevnamesID != NULL);
-    DASSERT(AwtPrintControl::setDevnamesID != NULL);
-    DASSERT(AwtPrintControl::driverDoesCollationID != NULL);
-    DASSERT(AwtPrintControl::getWin32MediaID != NULL);
-    DASSERT(AwtPrintControl::setWin32MediaID != NULL);
-    DASSERT(AwtPrintControl::getWin32MediaTrayID != NULL);
-    DASSERT(AwtPrintControl::setWin32MediaTrayID != NULL);
-    DASSERT(AwtPrintControl::setRangeCopiesID != NULL);
-    DASSERT(AwtPrintControl::setResID != NULL);
-    DASSERT(AwtPrintControl::setNativeAttID != NULL);
-    DASSERT(AwtPrintControl::dialogOwnerPeerID != NULL);
-    DASSERT(AwtPrintControl::getCopiesID != NULL);
-    DASSERT(AwtPrintControl::getOrientID != NULL);
-    DASSERT(AwtPrintControl::getPrinterID != NULL);
-    DASSERT(AwtPrintControl::getCollateID != NULL);
-    DASSERT(AwtPrintControl::getFromPageID != NULL);
-    DASSERT(AwtPrintControl::getToPageID != NULL);
-    DASSERT(AwtPrintControl::getMinPageID != NULL);
-    DASSERT(AwtPrintControl::getMaxPageID != NULL);
-    DASSERT(AwtPrintControl::getDestID != NULL);
-    DASSERT(AwtPrintControl::getQualityID != NULL);
-    DASSERT(AwtPrintControl::getColorID != NULL);
-    DASSERT(AwtPrintControl::getSidesID != NULL);
-    DASSERT(AwtPrintControl::getSelectID != NULL);
-    DASSERT(AwtPrintControl::getPrintToFileEnabledID != NULL);
     DASSERT(AwtPrintControl::setJobAttributesID != NULL);
-
+    CHECK_NULL(AwtPrintControl::setJobAttributesID);
 
     CATCH_BAD_ALLOC;
 }
@@ -606,6 +665,10 @@
 
         LPTSTR getName = (LPTSTR)JNU_GetStringPlatformChars(env,
                                                       printerName, NULL);
+        if (getName == NULL) {
+            env->DeleteLocalRef(printerName);
+            throw std::bad_alloc();
+        }
 
         BOOL samePrinter = FALSE;
 
@@ -652,6 +715,7 @@
                     if (portName != NULL) {
                       free(portName);
                     }
+                    env->DeleteLocalRef(printerName);
                     return FALSE;
                 }
 
@@ -664,11 +728,13 @@
                 if (portName != NULL) {
                   free(portName);
                 }
+                env->DeleteLocalRef(printerName);
                 return FALSE;
             }
 
             delete [] buffer;
         }
+        env->DeleteLocalRef(printerName);
         // PrintDlg may change the values of hDevMode and hDevNames so we
         // re-initialize our saved handles.
         AwtPrintControl::setPrintHDMode(env, printCtrl, NULL);
--- a/src/windows/native/sun/windows/awt_PrintDialog.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_PrintDialog.cpp	Thu May 01 14:21:29 2014 -0700
@@ -193,11 +193,24 @@
     // as peer object is used later on another thread, create a global ref
     jobject peerGlobalRef = env->NewGlobalRef(peer);
     DASSERT(peerGlobalRef != NULL);
+    CHECK_NULL_RETURN(peerGlobalRef, 0);
     jobject target = env->GetObjectField(peerGlobalRef, AwtObject::targetID);
     DASSERT(target != NULL);
+    if (target == NULL) {
+        env->DeleteGlobalRef(peerGlobalRef);
+        return 0;
+    }
     jobject parent = env->GetObjectField(peerGlobalRef, AwtPrintDialog::parentID);
     jobject control = env->GetObjectField(target, AwtPrintDialog::controlID);
     DASSERT(control != NULL);
+    if (control == NULL) {
+        env->DeleteGlobalRef(peerGlobalRef);
+        env->DeleteLocalRef(target);
+        if (parent != NULL) {
+          env->DeleteLocalRef(parent);
+        }
+        return 0;
+    }
 
     AwtComponent *awtParent = (parent != NULL) ? (AwtComponent *)JNI_GET_PDATA(parent) : NULL;
     HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL;
@@ -206,7 +219,18 @@
     memset(&pd, 0, sizeof(PRINTDLG));
     pd.lStructSize = sizeof(PRINTDLG);
     pd.lCustData = (LPARAM)peerGlobalRef;
-    BOOL ret = AwtPrintControl::InitPrintDialog(env, control, pd);
+    BOOL ret;
+    try {
+        ret = AwtPrintControl::InitPrintDialog(env, control, pd);
+    } catch (std::bad_alloc&) {
+        env->DeleteGlobalRef(peerGlobalRef);
+        env->DeleteLocalRef(target);
+        if (parent != NULL) {
+          env->DeleteLocalRef(parent);
+        }
+        env->DeleteLocalRef(control);
+        throw;
+    }
     if (!ret) {
         /* Couldn't use the printer, or spooler isn't running
          * Call Page dialog with ' PD_RETURNDEFAULT' so it doesn't try
--- a/src/windows/native/sun/windows/awt_new.cpp	Thu May 01 12:51:13 2014 -0700
+++ b/src/windows/native/sun/windows/awt_new.cpp	Thu May 01 14:21:29 2014 -0700
@@ -149,7 +149,7 @@
 handle_bad_alloc(void) {
     if (jvm != NULL) {
         JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-        if (env != NULL) {
+        if (env != NULL && !env->ExceptionCheck()) {
             JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/jdi/EvalInterfaceStatic.sh	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,126 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#  @test
+#  @bug 8031195
+#  @summary JDB allows evaluation of calls to static interface methods
+#  @author Jaroslav Bachorik
+#
+#  @run shell/timeout=300 EvalInterfaceStatic.sh
+
+#  The test exercises the ability to invoke static methods on interfaces.
+#  Static interface methods are a new feature added in JDK8.
+#
+#  The test makes sure that it is, at all, possible to invoke an interface
+#  static method and that the static methods are not inherited by extending
+#  interfaces.
+
+classname=EvalStaticInterfaces
+
+createJavaFile()
+{
+    cat <<EOF > $classname.java.1
+public interface $classname {
+    static String staticMethod1() {
+        return "base:staticMethod1";
+    }
+
+    static String staticMethod2() {
+        return "base:staticMethod2";
+    }
+
+    public static void main(String[] args) {
+        // prove that these work
+        System.out.println("base staticMethod1(): " + $classname.staticMethod1());
+        System.out.println("base staticMethod2(): " + $classname.staticMethod2());
+        System.out.println("overridden staticMethod2(): " + Extended$classname.staticMethod2());
+        System.out.println("base staticMethod3(): " + Extended$classname.staticMethod3());
+
+        gus();
+    }
+
+    static void gus() {
+        int x = 0;             // @1 breakpoint
+    }
+}
+
+interface Extended$classname extends $classname {
+    static String staticMethod2() {
+        return "extended:staticMethod2";
+    }
+
+    static String staticMethod3() {
+        return "extended:staticMethod3";
+    }
+}
+
+
+
+EOF
+}
+
+# drive jdb by sending cmds to it and examining its output
+dojdbCmds()
+{
+    setBkpts @1
+    runToBkpt @1
+
+    cmd eval "$classname.staticMethod1()"
+    jdbFailIfNotPresent "base:staticMethod1" 2
+
+    cmd eval "$classname.staticMethod2()"
+    jdbFailIfNotPresent "base:staticMethod2" 2
+
+    cmd eval "Extended$classname.staticMethod1()"
+    jdbFailIfPresent "base:staticMethod1" 2
+
+    cmd eval "Extended$classname.staticMethod2()"
+    jdbFailIfNotPresent "extended:staticMethod2" 2
+
+    cmd eval "Extended$classname.staticMethod3()"
+    jdbFailIfNotPresent "extended:staticMethod3" 2
+}
+
+
+mysetup()
+{
+    if [ -z "$TESTSRC" ] ; then
+        TESTSRC=.
+    fi
+
+    for ii in . $TESTSRC $TESTSRC/.. ; do
+        if [ -r "$ii/ShellScaffold.sh" ] ; then
+            . $ii/ShellScaffold.sh
+            break
+        fi
+    done
+}
+
+# You could replace this next line with the contents
+# of ShellScaffold.sh and this script will run just the same.
+mysetup
+
+runit
+pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/jdi/InterfaceMethodsTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,422 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ *  @test
+ *  @bug 8031195
+ *  @summary  JDI: Add support for static and default methods in interfaces
+ *
+ *  @run build TestScaffold VMConnection TargetListener TargetAdapter
+ *  @run build InterfaceMethodsTest
+ *  @run main InterfaceMethodsTest
+ */
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import java.util.Collections;
+
+public class InterfaceMethodsTest extends TestScaffold {
+    private static final int RESULT_A = 1;
+    private static final int RESULT_B = 1;
+    private static final int RESULT_TARGET = 1;
+    static interface InterfaceA {
+        static int staticMethodA() {
+            System.out.println("-InterfaceA: static interface method A-");
+            return RESULT_A;
+        }
+        static int staticMethodB() {
+            System.out.println("-InterfaceA: static interface method B-");
+            return RESULT_A;
+        }
+        default int defaultMethodA() {
+            System.out.println("-InterfaceA: default interface method A-");
+            return RESULT_A;
+        }
+        default int defaultMethodB() {
+            System.out.println("-InterfaceA: default interface method B-");
+            return RESULT_A;
+        }
+        default int defaultMethodC() {
+            System.out.println("-InterfaceA: default interface method C-");
+            return RESULT_A;
+        }
+
+        int implementedMethod();
+    }
+
+    static interface InterfaceB extends InterfaceA {
+        @Override
+        default int defaultMethodC() {
+            System.out.println("-InterfaceB: overridden default interface method C-");
+            return RESULT_B;
+        }
+        default int defaultMethodD() {
+            System.out.println("-InterfaceB: default interface method D-");
+            return RESULT_B;
+        }
+
+        static int staticMethodB() {
+            System.out.println("-InterfaceB: overridden static interface method B-");
+            return RESULT_B;
+        }
+
+        static int staticMethodC() {
+            System.out.println("-InterfaceB: static interface method C-");
+            return RESULT_B;
+        }
+    }
+
+    final static class TargetClass implements InterfaceB {
+        public int classMethod() {
+            System.out.println("-TargetClass: class only method-");
+            return RESULT_TARGET;
+        }
+
+        @Override
+        public int implementedMethod() {
+            System.out.println("-TargetClass: implemented non-default interface method-");
+            return RESULT_TARGET;
+        }
+
+        @Override
+        public int defaultMethodB() {
+            System.out.println("-TargetClass: overridden default interface method D");
+
+            return RESULT_TARGET;
+        }
+
+        public static void main(String[] args) {
+            TargetClass tc = new TargetClass();
+            tc.doTests(tc);
+        }
+
+        private void doTests(TargetClass ref) {
+            // break
+        }
+    }
+
+    public InterfaceMethodsTest(String[] args) {
+        super(args);
+    }
+
+    public static void main(String[] args) throws Exception {
+        new InterfaceMethodsTest(args).startTests();
+    }
+
+    private static final String TEST_CLASS_NAME = InterfaceMethodsTest.class.getName().replace('.', '/');
+    private static final String TARGET_CLASS_NAME = TargetClass.class.getName().replace('.', '/');
+    private static final String INTERFACEA_NAME = InterfaceA.class.getName().replace('.', '/');
+    private static final String INTERFACEB_NAME = InterfaceB.class.getName().replace('.', '/');
+
+    protected void runTests() throws Exception {
+        /*
+         * Get to the top of main()
+         * to determine targetClass and mainThread
+         */
+        BreakpointEvent bpe = startToMain(TARGET_CLASS_NAME);
+
+        bpe = resumeTo(TARGET_CLASS_NAME, "doTests", "(L" + TARGET_CLASS_NAME +";)V");
+
+        mainThread = bpe.thread();
+
+        StackFrame frame = mainThread.frame(0);
+        ObjectReference thisObject = frame.thisObject();
+        ObjectReference ref = (ObjectReference)frame.getArgumentValues().get(0);
+
+        ReferenceType targetClass = bpe.location().declaringType();
+        testImplementationClass(targetClass, thisObject);
+
+        testInterfaceA(ref);
+
+        testInterfaceB(ref);
+
+        /*
+         * resume the target listening for events
+         */
+        listenUntilVMDisconnect();
+
+        /*
+         * deal with results of test
+         * if anything has called failure("foo") testFailed will be true
+         */
+        if (!testFailed) {
+            println("InterfaceMethodsTest: passed");
+        } else {
+            throw new Exception("InterfaceMethodsTest: failed");
+        }
+    }
+
+    private void testInterfaceA(ObjectReference ref) {
+        // Test non-virtual calls on InterfaceA
+
+        ReferenceType ifaceClass = (ReferenceType)vm().classesByName(INTERFACEA_NAME).get(0);
+        /* Default method calls */
+
+        // invoke the InterfaceA's "defaultMethodA"
+        testInvokePos(ifaceClass, ref, "defaultMethodA", "()I", vm().mirrorOf(RESULT_A));
+
+        // invoke the InterfaceA's "defaultMethodB"
+        testInvokePos(ifaceClass, ref, "defaultMethodB", "()I", vm().mirrorOf(RESULT_A));
+
+        // invoke the InterfaceA's "defaultMethodC"
+        testInvokePos(ifaceClass, ref, "defaultMethodC", "()I", vm().mirrorOf(RESULT_A));
+
+        // "defaultMethodD" from InterfaceB is not accessible from here
+        testInvokeNeg(ifaceClass, ref, "defaultMethodD", "()I", vm().mirrorOf(RESULT_B),
+                "Attempted to invoke non-existing method");
+
+        // trying to invoke the asbtract method "implementedMethod"
+        testInvokeNeg(ifaceClass, ref, "implementedMethod", "()I", vm().mirrorOf(TARGET_CLASS_NAME),
+                "Invocation of non-default methods is not supported");
+
+
+        /* Static method calls */
+
+        // invoke interface static method A
+        testInvokePos(ifaceClass, null, "staticMethodA", "()I", vm().mirrorOf(RESULT_A));
+
+        // try to invoke static method A on the instance
+        testInvokePos(ifaceClass, ref, "staticMethodA", "()I", vm().mirrorOf(RESULT_A));
+
+        // invoke interface static method B
+        testInvokePos(ifaceClass, null, "staticMethodB", "()I", vm().mirrorOf(RESULT_A));
+
+        // try to invoke static method B on the instance
+        testInvokePos(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_A));
+    }
+
+    private void testInterfaceB(ObjectReference ref) {
+        // Test non-virtual calls on InterfaceB
+        ReferenceType ifaceClass = (ReferenceType)vm().classesByName(INTERFACEB_NAME).get(0);
+
+        /* Default method calls */
+
+        // invoke the inherited "defaultMethodA"
+        testInvokePos(ifaceClass, ref, "defaultMethodA", "()I", vm().mirrorOf(RESULT_A));
+
+        // invoke the inherited "defaultMethodB"
+        testInvokePos(ifaceClass, ref, "defaultMethodB", "()I", vm().mirrorOf(RESULT_A));
+
+        // invoke the inherited and overridden "defaultMethodC"
+        testInvokePos(ifaceClass, ref, "defaultMethodC", "()I", vm().mirrorOf(RESULT_B));
+
+        // invoke InterfaceB only "defaultMethodD"
+        testInvokePos(ifaceClass, ref, "defaultMethodD", "()I", vm().mirrorOf(RESULT_B));
+
+        // "implementedMethod" is not present in InterfaceB
+        testInvokeNeg(ifaceClass, ref, "implementedMethod", "()I", vm().mirrorOf(RESULT_TARGET),
+                "Invocation of non-default methods is not supported");
+
+
+        /* Static method calls*/
+
+        // "staticMethodA" must not be inherited by InterfaceB
+        testInvokeNeg(ifaceClass, null, "staticMethodA", "()I", vm().mirrorOf(RESULT_A),
+                "Static interface methods are not inheritable");
+
+        // however it is possible to call "staticMethodA" on the actual instance
+        testInvokeNeg(ifaceClass, ref, "staticMethodA", "()I", vm().mirrorOf(RESULT_A),
+                "Static interface methods are not inheritable");
+
+        // "staticMethodB" is overridden in InterfaceB
+        testInvokePos(ifaceClass, null, "staticMethodB", "()I", vm().mirrorOf(RESULT_B));
+
+        // the instance invokes the overriden form of "staticMethodB" from InterfaceB
+        testInvokePos(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_B));
+
+        // "staticMethodC" is present only in InterfaceB
+        testInvokePos(ifaceClass, null, "staticMethodC", "()I", vm().mirrorOf(RESULT_B));
+
+        // "staticMethodC" should be reachable from the instance too
+        testInvokePos(ifaceClass, ref, "staticMethodC", "()I", vm().mirrorOf(RESULT_B));
+    }
+
+    private void testImplementationClass(ReferenceType targetClass, ObjectReference thisObject) {
+        // Test invocations on the implementation object
+
+        /* Default method calls */
+
+        // "defaultMethodA" is accessible and not overridden
+        testInvokePos(targetClass, thisObject, "defaultMethodA", "()I", vm().mirrorOf(RESULT_TARGET));
+
+        // "defaultMethodB" is accessible and overridden in TargetClass
+        testInvokePos(targetClass, thisObject, "defaultMethodB", "()I", vm().mirrorOf(RESULT_TARGET));
+
+        // "defaultMethodC" is accessible and overridden in InterfaceB
+        testInvokePos(targetClass, thisObject, "defaultMethodC", "()I", vm().mirrorOf(RESULT_TARGET));
+
+        // "defaultMethodD" is accessible
+        testInvokePos(targetClass, thisObject, "defaultMethodD", "()I", vm().mirrorOf(RESULT_TARGET));
+
+
+        /* Non-default instance method calls */
+
+        // "classMethod" declared in TargetClass is accessible
+        testInvokePos(targetClass, thisObject, "classMethod", "()I", vm().mirrorOf(RESULT_TARGET));
+
+        // the abstract "implementedMethod" has been implemented in TargetClass
+        testInvokePos(targetClass, thisObject, "implementedMethod", "()I", vm().mirrorOf(RESULT_TARGET));
+
+
+        /* Static method calls */
+
+        // All the static methods declared by the interfaces are not reachable from the instance of the implementor class
+        testInvokeNeg(targetClass, thisObject, "staticMethodA", "()I", vm().mirrorOf(RESULT_A),
+                "Static interface methods are not inheritable");
+
+        testInvokeNeg(targetClass, thisObject, "staticMethodB", "()I", vm().mirrorOf(RESULT_B),
+                "Static interface methods are not inheritable");
+
+        testInvokeNeg(targetClass, thisObject, "staticMethodC", "()I", vm().mirrorOf(RESULT_B),
+                "Static interface methods are not inheritable");
+
+        // All the static methods declared by the interfaces are not reachable through the implementor class
+        testInvokeNeg(targetClass, null, "staticMethodA", "()I", vm().mirrorOf(RESULT_A),
+                "Static interface methods are not inheritable");
+
+        testInvokeNeg(targetClass, null, "staticMethodB", "()I", vm().mirrorOf(RESULT_B),
+                "Static interface methods are not inheritable");
+
+        testInvokeNeg(targetClass, null, "staticMethodC", "()I", vm().mirrorOf(RESULT_B),
+                "Static interface methods are not inheritable");
+    }
+
+    private void testInvokePos(ReferenceType targetClass, ObjectReference ref, String methodName,
+                               String methodSig, Value value) {
+        logInvocation(ref, methodName, methodSig, targetClass);
+        try {
+            invoke(targetClass, ref, methodName, methodSig, value);
+            System.err.println("--- PASSED");
+        } catch (Exception e) {
+            System.err.println("--- FAILED");
+            failure("FAILED: Invocation failed with error message " + e.getLocalizedMessage());
+        }
+    }
+
+    private void testInvokeNeg(ReferenceType targetClass, ObjectReference ref, String methodName,
+                               String methodSig, Value value, String msg) {
+        logInvocation(ref, methodName, methodSig, targetClass);
+        try {
+            invoke(targetClass, ref, methodName, methodSig, value);
+            System.err.println("--- FAILED");
+            failure("FAILED: " + msg);
+        } catch (Exception e) {
+            System.err.println("--- PASSED");
+
+        }
+    }
+
+    private void invoke(ReferenceType targetClass, ObjectReference ref, String methodName,
+                        String methodSig, Value value)
+    throws Exception {
+        Method method = getMethod(targetClass, methodName, methodSig);
+        if (method == null) {
+            throw new Exception("Can't find method: " + methodName  + " for class = " + targetClass);
+        }
+
+        println("Invoking " + (method.isAbstract() ? "abstract " : " ") + "method: " + method);
+
+        Value returnValue = null;
+        if (ref != null) {
+            returnValue = invokeInstance(ref, method);
+        } else {
+            returnValue = invokeStatic(targetClass, method);
+        }
+
+        println("        return val = " + returnValue);
+        // It has to be the same value as what we passed in!
+        if (returnValue.equals(value)) {
+            println("         " + method.name() + " return value matches: "
+                    + value);
+        } else {
+            if (value != null) {
+                throw new Exception(method.name() + " returned: " + returnValue +
+                                    " expected: " + value );
+            } else {
+                println("         " + method.name() + " return value : " + returnValue);
+            }
+
+        }
+    }
+
+    private Value invokeInstance(ObjectReference ref, Method method) throws Exception {
+        return ref.invokeMethod(mainThread, method, Collections.emptyList(), ObjectReference.INVOKE_NONVIRTUAL);
+    }
+
+    private Value invokeStatic(ReferenceType refType, Method method) throws Exception {
+        if (refType instanceof ClassType) {
+            return ((ClassType)refType).invokeMethod(mainThread, method, Collections.emptyList(), ObjectReference.INVOKE_NONVIRTUAL);
+        } else {
+            return ((InterfaceType)refType).invokeMethod(mainThread, method, Collections.emptyList(), ObjectReference.INVOKE_NONVIRTUAL);
+        }
+    }
+
+    private Method getMethod(ReferenceType rt, String name, String signature) {
+        if (rt == null) return null;
+        Method m = findMethod(rt, name, signature);
+        if (m == null) {
+            if (rt instanceof ClassType) {
+                for (Object ifc : ((ClassType)rt).interfaces()) {
+                    m = getMethod((ReferenceType)ifc, name, signature);
+                    if (m != null) {
+                        break;
+                    }
+                }
+                if (m == null) {
+                    m = getMethod(((ClassType)rt).superclass(), name, signature);
+                } else {
+                    if (m.isStatic()) {
+                        // interface static methods are not inherited
+                        m = null;
+                    }
+                }
+            } else if (rt instanceof InterfaceType) {
+                for(Object ifc : ((InterfaceType)rt).superinterfaces()) {
+                    m = getMethod((ReferenceType)ifc, name, signature);
+                    if (m != null) {
+                        if (m.isStatic()) {
+                            // interface static methods are not inherited
+                            m = null;
+                        }
+                        break;
+                    }
+                }
+            }
+        }
+
+        return m;
+    }
+
+    private void logInvocation(ObjectReference ref, String methodName, String methodSig, ReferenceType targetClass) {
+        if (ref != null) {
+            System.err.println("Invoking: " + ref.referenceType().name() + "." +
+                    methodName + methodSig + " with target of type " +
+                    targetClass.name());
+        } else {
+            System.err.println("Invoking static : " + targetClass.name() + "." +
+                    methodName + methodSig);
+        }
+    }
+}
+
+
+
--- a/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Thu May 01 14:21:29 2014 -0700
@@ -58,6 +58,7 @@
 
             ProcessBuilder pb = ProcessTools.
                 createJavaProcessBuilder(
+                    "-XX:+UseConcMarkSweepGC",  // this will cause UseParNewGC to be FLAG_SET_ERGO
                     "-XX:+PrintGCDetails",
                     "-XX:Flags=" + flagsFile.getAbsolutePath(),
                     "-cp", System.getProperty("test.class.path") + File.pathSeparator + getToolsJarPath(),
@@ -84,12 +85,20 @@
             setOptionUsingAttach("HeapDumpPath", "/a/sample/path");
 
             // check the origin field for all the options we set
+
+            // Not set, so should be default
             checkOrigin("ManagementServer", Origin.DEFAULT);
+            // Set on the command line
             checkOrigin("PrintGCDetails", Origin.VM_CREATION);
+            // Set in _JAVA_OPTIONS
             checkOrigin("PrintOopAddress", Origin.ENVIRON_VAR);
+            // Set in -XX:Flags file
             checkOrigin("PrintSafepointStatistics", Origin.CONFIG_FILE);
+            // Set through j.l.m
             checkOrigin("HeapDumpOnOutOfMemoryError", Origin.MANAGEMENT);
-            checkOrigin("NewSize", Origin.ERGONOMIC);
+            // Should be set by the VM, when we set UseConcMarkSweepGC
+            checkOrigin("UseParNewGC", Origin.ERGONOMIC);
+            // Set using attach
             checkOrigin("HeapDumpPath", Origin.ATTACH_ON_DEMAND);
         }
     }
--- a/test/demo/jvmti/mtrace/TraceJFrame.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/demo/jvmti/mtrace/TraceJFrame.java	Thu May 01 14:21:29 2014 -0700
@@ -36,7 +36,7 @@
 
 public class TraceJFrame {
     public static void main(String args[]) throws Exception {
-        if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
+        if (GraphicsEnvironment.isHeadless()) {
             System.out.println("JFrame test was skipped due to headless mode");
         } else {
             DemoRun demo;
--- a/test/java/awt/Frame/7024749/bug7024749.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/java/awt/Frame/7024749/bug7024749.java	Thu May 01 14:21:29 2014 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7024749
+ * @bug 7024749 8019990
  * @summary JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
  * @library ../../regtesthelpers
  * @build Util
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Frame/SlideNotResizableTest/SlideNotResizableTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.event.InputEvent;
+
+/**
+ * @test
+ * @bug 8032595
+ * @summary setResizable(false) makes a frame slide down
+ * @author Petr Pchelko
+ */
+
+public class SlideNotResizableTest {
+
+    private static volatile boolean passed = false;
+    private static final Dimension FRAME_SIZE = new Dimension(100, 100);
+    private static final Point FRAME_LOCATION = new Point(200, 200);
+
+    public static void main(String[] args) throws Throwable {
+        Frame aFrame = null;
+        try {
+            aFrame = new Frame();
+            aFrame.setSize(FRAME_SIZE);
+            aFrame.setLocation(FRAME_LOCATION);
+            aFrame.setResizable(false);
+            aFrame.setVisible(true);
+
+            sync();
+
+            if (!aFrame.getLocation().equals(FRAME_LOCATION)) {
+                throw new RuntimeException("FAILED: Wrong frame position");
+            }
+        } finally {
+            if (aFrame != null) {
+                aFrame.dispose();
+            }
+        }
+    }
+
+    private static void sync() throws InterruptedException {
+        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        Thread.sleep(1000);
+    }
+}
--- a/test/java/awt/Paint/bug8024864.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/java/awt/Paint/bug8024864.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 8024864
+ * @bug 8024864 8031422
  * @summary [macosx] Problems with rendering of controls
  * @author Petr Pchelko
  * @library ../regtesthelpers
@@ -65,7 +65,7 @@
                 Util.waitForIdle(r);
 
                 Dimension frameSize = frame.getSize();
-                Point loc = new Point(frameSize.width - 5, frameSize.height - 5);
+                Point loc = new Point(frameSize.width - 15, frameSize.height - 15);
                 SwingUtilities.convertPointToScreen(loc, frame);
                 Color c = r.getPixelColor(loc.x, loc.y);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/datatransfer/DataFlavor/EqualsHashCodeSymmetryTest/EqualsHashCodeSymmetryTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.datatransfer.DataFlavor;
+
+/**
+ * @test
+ * @bug 8038999
+ * @summary DataFlavor.equals is not symmetric
+ * @author Petr Pchelko <petr.pchelko@oracle.com>
+ */
+public class EqualsHashCodeSymmetryTest {
+
+    private static final DataFlavor[] dataFlavors = {
+            DataFlavor.stringFlavor,
+            DataFlavor.imageFlavor,
+            DataFlavor.javaFileListFlavor,
+            DataFlavor.allHtmlFlavor,
+            DataFlavor.selectionHtmlFlavor,
+            DataFlavor.fragmentHtmlFlavor,
+            createFlavor("text/html; class=java.lang.String"),
+            new DataFlavor(String.class, "My test flavor number 1"),
+            new DataFlavor(String.class, "My test flavor number 2"),
+            new DataFlavor(StringBuilder.class, "My test flavor number 1")
+    };
+
+    public static void main(String[] args) {
+        testEqualsSymmetry();
+        testEqualsHashCodeConsistency();
+        testSimpleCollision();
+    }
+
+    private static void testEqualsSymmetry() {
+        for (DataFlavor flavor1 : dataFlavors) {
+            for (DataFlavor flavor2 : dataFlavors) {
+                if (flavor1.equals(flavor2) != flavor2.equals(flavor1)) {
+                    throw new RuntimeException(
+                            String.format("Equals is not symmetric for %s and %s", flavor1, flavor2));
+                }
+            }
+        }
+    }
+
+    private static void testEqualsHashCodeConsistency() {
+        for (DataFlavor flavor1 : dataFlavors) {
+            for (DataFlavor flavor2 : dataFlavors) {
+                if ((flavor1.equals(flavor2) && flavor1.hashCode() != flavor2.hashCode())) {
+                    throw new RuntimeException(
+                            String.format("Equals and hash code not consistent for %s and %s", flavor1, flavor2));
+                }
+            }
+        }
+    }
+
+    private static void testSimpleCollision() {
+        if (createFlavor("text/html; class=java.lang.String").hashCode() == DataFlavor.allHtmlFlavor.hashCode()) {
+            throw new RuntimeException("HashCode collision because the document parameter is not used");
+        }
+    }
+
+    private static DataFlavor createFlavor(String mime) {
+        try {
+            return new DataFlavor(mime);
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/dnd/DragSourceListenerSerializationTest/DragSourceListenerSerializationTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 4422345 8039083
+  @summary tests serialization of DragSourceListeners
+  @author das@sparc.spb.su area=dnd
+  @library ../../../../lib/testlibrary
+  @build jdk.testlibrary.Asserts
+  @run main/othervm DragSourceListenerSerializationTest
+*/
+
+import java.awt.Button;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.awt.datatransfer.StringSelection;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceAdapter;
+import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DragSourceMotionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.TooManyListenersException;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static jdk.testlibrary.Asserts.assertEquals;
+
+public class DragSourceListenerSerializationTest {
+    public static void main(String[] args) throws Exception {
+        DragSource ds = new DragSource();
+        TestDragSourceAdapter dsa1 = new TestDragSourceAdapter(1);
+        TestDragSourceAdapter dsa2 = new TestDragSourceAdapter(2);
+        Component c = new Button();
+        DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(c,
+                DnDConstants.ACTION_COPY,
+                e -> e.startDrag(null, null));
+        MouseEvent me = new MouseEvent(c, MouseEvent.MOUSE_PRESSED, 0,
+                InputEvent.CTRL_MASK, 100, 100, 0, false);
+        DragGestureEvent dge = new DragGestureEvent(dgr, DnDConstants.ACTION_COPY,
+                new Point(100, 100),
+                Arrays.asList(me));
+        DragSourceContext dsc = new DragSourceContext(
+                Toolkit.getDefaultToolkit().createDragSourceContextPeer(dge),
+                dge,
+                new Cursor(Cursor.HAND_CURSOR),
+                null, null, new StringSelection("TEXT"), null);
+
+        ds.addDragSourceListener(dsa1);
+        ds.addDragSourceListener(dsa2);
+        ds.addDragSourceListener(dsa2);
+        ds.addDragSourceMotionListener(dsa1);
+        ds.addDragSourceMotionListener(dsa1);
+        ds.addDragSourceMotionListener(dsa2);
+        dsc.addDragSourceListener(dsa2);
+
+        byte[] serialized;
+        try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
+             ObjectOutputStream oos = new ObjectOutputStream(bos)) {
+            oos.writeObject(dsc);
+            serialized = bos.toByteArray();
+        }
+
+        DragSourceContext dsc_copy;
+        try (ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
+             ObjectInputStream ois = new ObjectInputStream(bis)) {
+            dsc_copy = (DragSourceContext) ois.readObject();
+        }
+
+        try {
+            dsc_copy.addDragSourceListener(dsa1);
+            throw new RuntimeException("Test failed. Listener addition succeeded");
+        } catch (TooManyListenersException ignored) {
+        }
+
+        try {
+            dsc_copy.addDragSourceListener(dsa2);
+            throw new RuntimeException("Test failed. Listener addition succeeded");
+        } catch (TooManyListenersException ignored) {
+        }
+
+        try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
+             ObjectOutputStream oos = new ObjectOutputStream(bos)) {
+            oos.writeObject(ds);
+            serialized = bos.toByteArray();
+        }
+
+        DragSource ds_copy;
+        try (ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
+             ObjectInputStream ois = new ObjectInputStream(bis)) {
+             ds_copy = (DragSource) ois.readObject();
+        }
+
+        DragSourceListener[] dsls = ds_copy.getDragSourceListeners();
+        assertEquals(3, dsls.length, "DragSourceListeners number");
+        assertEquals(1, Stream.of(dsls).filter(dsa1::equals).collect(Collectors.counting()).intValue());
+        assertEquals(2, Stream.of(dsls).filter(dsa2::equals).collect(Collectors.counting()).intValue());
+
+        DragSourceMotionListener[] dsmls = ds_copy.getDragSourceMotionListeners();
+        assertEquals(3, dsmls.length, "DragSourceMotionListeners number");
+        assertEquals(2, Stream.of(dsmls).filter(dsa1::equals).collect(Collectors.counting()).intValue());
+        assertEquals(1, Stream.of(dsmls).filter(dsa2::equals).collect(Collectors.counting()).intValue());
+    }
+}
+
+class TestDragSourceAdapter extends DragSourceAdapter implements Serializable {
+    final int id;
+
+    TestDragSourceAdapter(int id) {
+        this.id = id;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public boolean equals(Object obj) {
+        if (obj instanceof TestDragSourceAdapter) {
+            TestDragSourceAdapter tdsa = (TestDragSourceAdapter) obj;
+            return tdsa.getId() == getId();
+        }
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/Dialog/DestinationTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4846344 4851365 4851321 4851316 4863656 5046198 6293139
+ * @summary Confirm that cancelling the dialog will not prompt for file.
+ * @run main/manual DestinationTest
+ */
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.io.*;
+
+public class DestinationTest extends Frame implements ActionListener {
+    //Declare things used in the test, like buttons and labels here
+
+    DisplayImages images;
+    Button nativeDlg, nativeDlg2, commonSelectionDlg, commonRangeDlg, fileDlg;
+
+    public DestinationTest() {
+
+        images = new DisplayImages();
+        images.setSize(530, 480);
+        add(images, "Center");
+
+        Panel printpanel = new Panel();
+
+        nativeDlg = new Button("Native");
+        nativeDlg.addActionListener(this);
+        printpanel.add(nativeDlg);
+
+        nativeDlg2 = new Button("Native 2");
+        nativeDlg2.addActionListener(this);
+        printpanel.add(nativeDlg2);
+
+        commonSelectionDlg = new Button("Common Selection");
+        commonSelectionDlg.addActionListener(this);
+        printpanel.add(commonSelectionDlg);
+
+        commonRangeDlg = new Button("Common Range");
+        commonRangeDlg.addActionListener(this);
+        printpanel.add(commonRangeDlg);
+
+        fileDlg = new Button("Print To File - Common Dialog");
+        fileDlg.addActionListener(this);
+        printpanel.add(fileDlg);
+
+        add(printpanel, "South");
+        setSize(900, 300);
+        setVisible(true);
+    }
+
+    public static void main (String args[]) {
+        DestinationTest test = new DestinationTest();
+    }
+
+
+    public void actionPerformed(ActionEvent e) {
+
+        JobAttributes  ja = new JobAttributes();
+        PageAttributes pa = new PageAttributes();
+        ja.setDestination(JobAttributes.DestinationType.FILE);
+        ja.setFileName("test_file_name.prn");
+
+        if(e.getSource()== nativeDlg) {
+            ja.setDefaultSelection(JobAttributes.DefaultSelectionType.SELECTION);
+            ja.setPageRanges(new int[][] {new int[] {2,3}, new int[] {5,6}});
+            ja.setDialog(JobAttributes.DialogType.NATIVE);
+        }
+
+        if(e.getSource()== nativeDlg2) {
+            ja.setFileName("");
+            ja.setDialog(JobAttributes.DialogType.NATIVE);
+        }
+
+        if(e.getSource()== commonRangeDlg) {
+            ja = new JobAttributes();
+            ja.setDefaultSelection(JobAttributes.DefaultSelectionType.RANGE);
+            ja.setPageRanges(new int[][] {new int[] {1,3}, new int[] {5,6}});
+            ja.setDialog(JobAttributes.DialogType.COMMON);
+        }
+
+        if (e.getSource() == fileDlg) {
+            ja = new JobAttributes();
+            ja.setDestination(JobAttributes.DestinationType.FILE);
+            ja.setDialog(JobAttributes.DialogType.COMMON);
+        }
+
+        if(e.getSource()== commonSelectionDlg) {
+            ja.setDefaultSelection(JobAttributes.DefaultSelectionType.SELECTION);
+            ja.setDialog(JobAttributes.DialogType.COMMON);
+        }
+
+        PrintJob pjob = getToolkit().getPrintJob(this,"Printing Test",ja,pa);
+        System.out.println("6293139: Chosen printer is: "+ja.getPrinter());
+        if(pjob != null) {
+
+            Graphics pg = pjob.getGraphics();
+
+            if(pg != null) {
+                //images.printAll(pg);
+                this.printAll(pg);
+                pg.dispose();
+            }
+            pjob.end();
+        }
+    }
+}
+
+class DisplayImages extends Canvas {
+
+    public void paint(Graphics g) {
+
+        g.setFont(new Font("Helvetica", Font.BOLD, 12));
+        g.drawString("PRINTING TEST", 1, 10);
+        g.drawString(" 4846344: Confirm that cancelling the native dialog will not prompt for file.", 1, 25);
+        g.drawString(" 4851365: Confirm that printing in native dialog shows test_file_name.prn as default.", 1, 40);
+        g.drawString(" 4851321: Confirm that in the Common Range dialog, page ranges is set to 1-6.", 1, 55);
+        g.drawString(" 4851316: Confirm that NPE is not thrown upon selecting Common Selection dialog.", 1, 70);
+        g.drawString(" 4863656: Confirm that no IAE is thrown when printing in native dialog.", 1, 85);
+        g.drawString(" 4864444: Confirm that the default directory in Native 2 is same as current one with no filename set.", 1, 100);
+        g.drawString(" 5046198: Confirm that the default filename in Common Range dialog when printing to a file is same as that of PrintToFile dialog.", 1, 115);
+        g.drawString(" 6293139: In Common Range dialog, change printer before printing then confirm the chosen printer.", 1, 130);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/Dialog/MediaInPrintable.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4869575 6361766
+ * @summary Setting orientation in the page format does not have any effect on the printout. To test 6361766, the application must exit.
+ * @run main/manual MediaInPrintable
+ */
+import java.awt.*;
+import java.awt.print.*;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+
+public class MediaInPrintable implements Printable {
+        private static Font fnt = new Font("Helvetica",Font.PLAIN,24);
+        public static void main(String[] args) {
+
+            System.out.println("arguments : native1 | native2\nExpected output :\n\tnative1 -  Landscape orientation.\n\tnative2 - Legal paper is selected.");
+            if (args.length == 0) {
+                return;
+            }
+
+
+            // Get a PrinterJob
+            PrinterJob job = PrinterJob.getPrinterJob();
+            PageFormat pf = new PageFormat();
+
+            if (args[0].equals("native1")) {
+                pf.setOrientation(PageFormat.LANDSCAPE);
+                job.setPrintable(new MediaInPrintable(), pf);
+                if (job.printDialog()) {
+                        // Print the job if the user didn't cancel printing
+                        try {
+                                job.print();
+                        } catch (Exception e) {
+                                e.printStackTrace();
+                        }
+                }
+            } else if (args[0].equals("native2")) {
+                Paper p = new Paper();
+                p.setSize(612.0, 1008.0);
+                p.setImageableArea(72.0, 72.0, 468.0, 864.0);
+                pf.setPaper(p);
+
+                job.setPrintable(new MediaInPrintable(), pf);
+                if (job.printDialog()) {
+                        // Print the job if the user didn't cancel printing
+                        try {
+                                job.print();
+                        } catch (Exception e) {
+                                e.printStackTrace();
+                        }
+                }
+
+            }
+
+                //System.exit(0);
+        }
+
+        public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
+        if (pageIndex > 0) {
+                return Printable.NO_SUCH_PAGE;
+        }
+        g.setFont(fnt);
+        g.setColor(Color.green);
+        g.drawString("Page " + (pageIndex+1), 100, 100);
+        return Printable.PAGE_EXISTS;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/Dialog/PrintApplet.html	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,29 @@
+!--
+ Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<title>PrintApplet</title>
+<h1>PrintApplet</h1>
+
+
+<applet code="PrintApplet.class" width=300 height=300>
+</applet><p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/Dialog/PrintApplet.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 5024549
+  @summary   Pass if dialogs are modal.
+  @run applet/manual PrintApplet.html
+*/
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.*;
+import java.awt.print.*;
+import javax.swing.*;
+
+public class PrintApplet extends JApplet implements Printable {
+    private JButton jButton1 = new JButton();
+
+
+    public PrintApplet() {
+    }
+
+    public void init() {
+        try {
+            jbInit();
+        }
+        catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void jbInit() throws Exception {
+        jButton1.setText("PRINT");
+        jButton1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                jButton1_actionPerformed(e);
+            }
+        });
+        jButton1.setBounds(new Rectangle(165, 248, 80, 30));
+        this.setSize(new Dimension(400,300));
+        this.getContentPane().setLayout(null);
+        this.getContentPane().setBackground(Color.pink);
+        this.getContentPane().add(jButton1, BorderLayout.SOUTH);
+    }
+
+    public void start() {
+    }
+
+    public void stop() {
+    }
+
+    public void destroy() {
+    }
+
+    public String getAppletInfo() {
+        return "Applet inf";
+    }
+
+    public String[][] getParameterInfo() {
+        return null;
+    }
+
+
+   public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
+       System.out.println("Calling print");
+       if (page == 0) {
+           Graphics2D g2 = (Graphics2D)g;
+           g2.translate(pf.getImageableX(), pf.getImageableY());
+           g2.setColor(Color.black);
+           g2.drawString("Hello World", 20, 100);
+
+           return Printable.PAGE_EXISTS;
+       }
+       return Printable.NO_SUCH_PAGE;
+   }
+
+
+
+    void jButton1_actionPerformed(ActionEvent e) {
+      PrinterJob printJob = null;
+      PageFormat pageFormat = null;
+      Paper prtPaper = null;
+      boolean bPrintFlg = true;
+
+
+      try{
+         printJob = PrinterJob.getPrinterJob();
+
+      }
+      catch(SecurityException se){
+
+         bPrintFlg = false;
+      }
+
+      if (bPrintFlg) {
+
+         pageFormat = printJob.pageDialog(printJob.defaultPage());
+         System.out.println("PrintApplet: pageFormat = "+pageFormat.getWidth()/72.0+" x "+pageFormat.getHeight()/72.0);
+         if (pageFormat != null) {
+
+            prtPaper = pageFormat.getPaper();
+            pageFormat.setPaper(prtPaper);
+
+
+            printJob.setPrintable(this, pageFormat);
+         }
+
+         if (printJob.printDialog()) {
+
+             try {
+                 printJob.print();
+             }
+             catch (java.awt.print.PrinterException ex) {
+                 ex.printStackTrace();
+             }
+
+         }
+
+      }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/Dialog/PrintDialog.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 6342748
+  @summary  Pass if dialogs display correctly
+  @run main/manual PrintDialog
+*/
+import java.awt.print.*;
+import javax.print.attribute.*;
+
+public class PrintDialog {
+
+    public static void main(java.lang.String[] args) {
+        PrinterJob pj = PrinterJob.getPrinterJob();
+        PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet();
+        System.out.println("Verify page setup dialog appears correctly then cancel or OK");
+        pj.pageDialog(pSet);
+        System.out.println("Verify all tabs of print dialog appear correctly then cancel or OK");
+        pj.printDialog(pSet);
+        return;
+     }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/Dialog/PrintDlgApp.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 4865976 7158366
+  @summary  Pass if it program exits.
+  @run main/manual PrintDlgApp
+*/
+import java.awt.*;
+import java.awt.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.Destination;
+import java.util.Locale;
+
+import javax.print.*;
+
+class PrintDlgApp implements Printable {
+        /**
+         * Constructor
+         */
+        public PrintDlgApp() {
+                super();
+        }
+        /**
+         * Starts the application.
+         */
+        public static void main(java.lang.String[] args) {
+                PrintDlgApp pd = new PrintDlgApp();
+                PrinterJob pj = PrinterJob.getPrinterJob();
+                System.out.println(pj);
+                PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet();
+                pSet.add(new Copies(1));
+                //PageFormat pf = pj.pageDialog(pSet);
+                PageFormat pf = new PageFormat();
+                System.out.println("Setting Printable...pf = "+pf);
+                if (pf == null) {
+                    return;
+                }
+                pj.setPrintable(pd,pf);
+
+                //try { pj.setPrintService(services[0]); } catch(Exception e) { e.printStackTrace(); }
+                pSet.add(new Destination(new java.io.File("./out.prn").toURI()));
+                System.out.println("open PrintDialog..");
+                for (int i=0; i<2; i++) {
+                if (pj.printDialog(pSet)) {
+                        try {
+                                System.out.println("About to print the data ...");
+                                pj.print(pSet);
+                                System.out.println("Printed");
+                        }
+                        catch (PrinterException pe) {
+                                pe.printStackTrace();
+                        }
+                }
+                }
+
+        }
+
+        //printable interface
+        public int print(Graphics g, PageFormat pf, int pi) throws
+PrinterException {
+
+                if (pi > 0) {
+                        System.out.println("pi is greater than 0");
+                        return Printable.NO_SUCH_PAGE;
+                }
+                // Simply draw two rectangles
+                Graphics2D g2 = (Graphics2D)g;
+                g2.setColor(Color.black);
+                g2.translate(pf.getImageableX(), pf.getImageableY());
+                g2.drawRect(1,1,200,300);
+                g2.drawRect(1,1,25,25);
+                System.out.println("print method called "+pi);
+                return Printable.PAGE_EXISTS;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/Dialog/PrintDlgPageable.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4869502 4869539
+ * @summary Confirm that ToPage is populated for argument =2. Range is disabled for argument = 0.
+ * @run main/manual PrintDlgPageable
+ */
+import java.awt.*;
+import java.awt.print.*;
+import java.util.Locale;
+
+import javax.print.*;
+
+class PrintDlgPageable implements Printable {
+    public static int arg;
+        /**
+         * Constructor
+         */
+         public PrintDlgPageable() {
+                super();
+        }
+        /**
+         * Starts the application.
+         */
+        public static void main(java.lang.String[] args) {
+            if (args.length < 1) {
+                System.out.println("usage: java PrintDlgPageable { 0 | 2}");
+                return;
+            }
+            arg = Integer.parseInt(args[0]);
+                PrintDlgPageable pd = new PrintDlgPageable();
+                PrinterJob pj = PrinterJob.getPrinterJob();
+                PageableHandler handler = new PageableHandler();
+                pj.setPageable(handler);
+
+                System.out.println("open PrintDialog..");
+                if (pj.printDialog()) {
+                        try {
+                                System.out.println("About to print the data ...");
+                                pj.print();
+                                System.out.println("Printed");
+                        }
+                        catch (PrinterException pe) {
+                                pe.printStackTrace();
+                        }
+                }
+
+        }
+
+        //printable interface
+        public int print(Graphics g, PageFormat pf, int pi) throws
+PrinterException {
+
+                /*if (pi > 0) {
+                        System.out.println("pi is greater than 0");
+                        return Printable.NO_SUCH_PAGE;
+                }*/
+                // Simply draw two rectangles
+                Graphics2D g2 = (Graphics2D)g;
+                g2.setColor(Color.black);
+                g2.translate(pf.getImageableX(), pf.getImageableY());
+                g2.drawRect(1,1,200,300);
+                g2.drawRect(1,1,25,25);
+                System.out.println("print method called "+pi + " Orientation "+pf.getOrientation());
+                return Printable.PAGE_EXISTS;
+        }
+}
+
+class PageableHandler implements Pageable {
+
+        PageFormat pf = new PageFormat();
+
+        public int getNumberOfPages() {
+                return PrintDlgPageable.arg;
+                //return 0;
+        }
+
+        public Printable getPrintable(int pageIndex) {
+                return new PrintDlgPageable();
+        }
+
+        public PageFormat getPageFormat(int pageIndex) {
+                System.out.println("getPageFormat called "+pageIndex);
+                if (pageIndex == 0) {
+                        pf.setOrientation(PageFormat.PORTRAIT);
+                        System.out.println("Orientation returned from Pageable "+findOrientation(pf.getOrientation()));
+                        return pf;
+                } else {
+                        pf.setOrientation(PageFormat.LANDSCAPE);
+                        System.out.println("Orientation returned from Pageable "+findOrientation(pf.getOrientation()));
+                        return pf;
+                }
+        }
+
+        public String findOrientation(int orient) {
+                if (orient == PageFormat.LANDSCAPE) {
+                        return "LANDSCAPE";
+                }else if (orient == PageFormat.PORTRAIT) {
+                        return "PORTRAIT";
+                } else if (orient == PageFormat.REVERSE_LANDSCAPE) {
+                        return "REVERSE LANDSCAPE";
+                } else {
+                        return null;
+                }
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<!--  
+  @test
+  @bug 6365992 6379599
+  @summary REG: Showing and disposing a native print dialog makes the main frame inactive, Win32
+  @author Dmitry.Cherepanov@SUN.COM area=awt.printdialog
+  @run applet/manual=yesno RestoreActiveWindowTest.html
+  -->
+<head>
+<title>RestoreActiveWindowTest</title>
+</head>
+<body>
+
+<h1>RestoreActiveWindowTest<br>Bug ID: 6365992</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="RestoreActiveWindowTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  test
+  @bug 6365992 6379599
+  @summary REG: Showing and disposing a native print dialog makes the main frame inactive, Win32
+  @author Dmitry.Cherepanov@SUN.COM area=awt.printdialog
+  @run applet/manual=yesno RestoreActiveWindowTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import javax.print.attribute.*;
+
+public class RestoreActiveWindowTest extends Applet
+{
+    Button showBtn1 = new Button("show a native print dialog");
+    Button showBtn2 = new Button("show a native page dialog");
+
+    public void init()
+    {
+        showBtn1.addActionListener(new ActionListener(){
+                public void actionPerformed(ActionEvent ae) {
+                    PrinterJob.getPrinterJob().printDialog();
+                }
+            });
+        showBtn2.addActionListener(new ActionListener(){
+                public void actionPerformed(ActionEvent ae){
+                    PrinterJob.getPrinterJob().pageDialog(new PageFormat());
+                }
+            });
+
+        add(showBtn1);
+        add(showBtn2);
+
+        String[] instructions = {
+            "1.1) Click on 'show a native print dialog'. A native print dialog will come up.",
+            "1.2) Click on the 'close'(X) button. The dialog will be closed.",
+            "1.3) After the dialog closing another window should become the active window.",
+            "1.4) If there no any active window then the test failed.",
+            "2.1) Click on 'show a native page dialog'. A native page dialog will come up.",
+            "2.2) Click on the 'close'(X) button. The dialog will be closed.",
+            "2.3) After the dialog closing another window should become the active window.",
+            "2.4) If there no any active window then the test failed.",
+            "3) Test Passed."
+        };
+
+        Sysout.createDialogWithInstructions( instructions );
+
+    }//End  init()
+
+   public void start ()
+    {
+      //Get things going.  Request focus, set size, et cetera
+      setSize (200,200);
+      show();
+
+    }// start()
+
+    //The rest of this class is the actions which perform the test...
+
+    //Use Sysout.println to communicate with the user NOT System.out!!
+    //Sysout.println ("Something Happened!");
+
+}// class ManualYesNoTest
+
+/* Place other classes related to the test after this line */
+
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/CustomPaper.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4355514
+ * @bug 4385157
+ * @author Jennifer Godinez
+ * @summary Prints a rectangle to show the imageable area of a
+ *          12in x 14in custom paper size.
+ * @run main/manual CustomPaper
+ */
+
+import java.awt.*;
+import java.awt.print.*;
+import java.awt.geom.*;
+
+public class CustomPaper implements Pageable, Printable{
+
+  private static double PIXELS_PER_INCH = 72.0;
+
+  private PrinterJob printerJob;
+  private PageFormat pageFormat;
+
+  CustomPaper(){
+    printerJob = PrinterJob.getPrinterJob();
+    createPageFormat();
+  }
+
+  private void createPageFormat(){
+    pageFormat = new PageFormat();
+    Paper p = new Paper();
+    double width   = 12.0*PIXELS_PER_INCH;
+    double height  = 14.0*PIXELS_PER_INCH;
+    double ix      = PIXELS_PER_INCH;
+    double iy      = PIXELS_PER_INCH;
+    double iwidth  = width  - 2.0*PIXELS_PER_INCH;
+    double iheight = height - 2.0*PIXELS_PER_INCH;
+    p.setSize(width, height);
+    p.setImageableArea(ix, iy, iwidth, iheight);
+    pageFormat.setPaper(p);
+  }
+
+  public Printable getPrintable(int index){
+    return this;
+  }
+
+  public PageFormat getPageFormat(int index){
+    return pageFormat;
+  }
+
+  public int getNumberOfPages(){
+    return 1;
+  }
+
+  public void print(){
+    if(printerJob.printDialog())
+        {
+      try{
+        printerJob.setPageable(this);
+        printerJob.print();
+      }catch(Exception e){e.printStackTrace();}
+    }
+
+  }
+
+  public int print(Graphics g, PageFormat pf, int pageIndex){
+    if(pageIndex == 0){
+        Graphics2D g2 = (Graphics2D)g;
+        Rectangle2D r = new Rectangle2D.Double(pf.getImageableX(),
+                                               pf.getImageableY(),
+                                               pf.getImageableWidth(),
+                                               pf.getImageableHeight());
+      g2.setStroke(new BasicStroke(3.0f));
+      g2.draw(r);
+      return PAGE_EXISTS;
+    }else{
+      return NO_SUCH_PAGE;
+    }
+  }
+
+  public static void main(String[] args){
+
+        String[] instructions =
+        {
+            "You must have a printer that supports custom paper size of ",
+            "at least 12 x 14 inches to perform this test. It requires",
+            "user interaction and you must have a 12 x 14 inch paper available.",
+            " ",
+            "To test bug ID 4385157, click OK on print dialog box to print.",
+            " ",
+            "To test bug ID 4355514, select the printer in the Print Setup dialog and add a ",
+            "custom paper size under Printer properties' Paper selection menu. ",
+            "Set the dimension  to width=12 inches and height=14 inches.",
+            "Select this custom paper size before proceeding to print.",
+            " ",
+            "Visual inspection of the one-page printout is needed. A passing",
+            "test will print a rectangle of the imageable area which is approximately",
+            "10 x 12 inches.",
+        };
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        CustomPaper pt = new CustomPaper();
+        pt.print();
+        //System.exit (0);
+  }
+
+}
+
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/NullPaper.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,423 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 4199506
+  @summary  java.awt.print.PageFormat.setpaper(Paper paper)
+                 assertion test fails by not throwing
+                 NullPointerException when a null paper instance is
+                 passed as argument and this is specified in the doc.
+  @author rbi: area=PageFormat
+  @run main NullPaper
+*/
+
+
+//*** global search and replace NullPaper with name of the test ***
+
+/**
+ * NullPaper.java
+ *
+ * summary: java.awt.print.PageFormat.setpaper(Paper paper)
+                 assertion test fails by not throwing
+                 NullPointerException when a null paper instance is
+                 passed as argument and this is specified in the doc.
+
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+
+// This test is a "main" test as applets would need Runtime permission
+// "queuePrintJob".
+
+public class NullPaper {
+
+   private static void init()
+    {
+        //*** Create instructions for the user here ***
+
+        String[] instructions =
+        {
+         "This test should throw a NullPointerException. ",
+         "If the NullPointerException is correctly thrown ",
+         "by the call to setPaper() then the test succeeds. ",
+         "If no exception is thrown by setPaper() or if an ",
+         "exception other than NullPointerException is thrown ",
+         "then the test fails."
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+    boolean settingNullWorked = false;
+
+    try {
+        /* Setting the paper to null should throw an exception.
+         * The bug was the exception was not being thrown.
+         */
+        new PageFormat().setPaper(null);
+        settingNullWorked = true;
+
+    /* If the test succeeds we'll end up here, so write
+     * to standard out.
+     */
+    } catch (NullPointerException e) {
+        pass();
+
+    /* The test failed if we end up here because an exception
+     * other than the one we were expecting was thrown.
+     */
+    } catch (Exception e) {
+        fail("Instead of the expected NullPointerException, '" + e + "' was thrown.");
+    }
+
+    if (settingNullWorked) {
+        fail("The expected NullPointerException was not thrown");
+    }
+
+    }//End  init()
+
+
+   /*****************************************************
+     Standard Test Machinery Section
+      DO NOT modify anything in this section -- it's a
+      standard chunk of code which has all of the
+      synchronisation necessary for the test harness.
+      By keeping it the same in all tests, it is easier
+      to read and understand someone else's test, as
+      well as insuring that all tests behave correctly
+      with the test harness.
+     There is a section following this for test-defined
+      classes
+   ******************************************************/
+   private static boolean theTestPassed = false;
+   private static boolean testGeneratedInterrupt = false;
+   private static String failureMessage = "";
+
+   private static Thread mainThread = null;
+
+   private static int sleepTime = 300000;
+
+   public static void main( String args[] ) throws InterruptedException
+    {
+      mainThread = Thread.currentThread();
+      try
+       {
+         init();
+       }
+      catch( TestPassedException e )
+       {
+         //The test passed, so just return from main and harness will
+         // interepret this return as a pass
+         return;
+       }
+      //At this point, neither test passed nor test failed has been
+      // called -- either would have thrown an exception and ended the
+      // test, so we know we have multiple threads.
+
+      //Test involves other threads, so sleep and wait for them to
+      // called pass() or fail()
+      try
+       {
+         Thread.sleep( sleepTime );
+         //Timed out, so fail the test
+         throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+       }
+      catch (InterruptedException e)
+       {
+         if( ! testGeneratedInterrupt ) throw e;
+
+         //reset flag in case hit this code more than once for some reason (just safety)
+         testGeneratedInterrupt = false;
+         if ( theTestPassed == false )
+          {
+            throw new RuntimeException( failureMessage );
+          }
+       }
+
+    }//main
+
+   public static synchronized void setTimeoutTo( int seconds )
+    {
+      sleepTime = seconds * 1000;
+    }
+
+   public static synchronized void pass()
+    {
+      Sysout.println( "The test passed." );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //first check if this is executing in main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //Still in the main thread, so set the flag just for kicks,
+         // and throw a test passed exception which will be caught
+         // and end the test.
+         theTestPassed = true;
+         throw new TestPassedException();
+       }
+      //pass was called from a different thread, so set the flag and interrupt
+      // the main thead.
+      theTestPassed = true;
+      testGeneratedInterrupt = true;
+      mainThread.interrupt();
+    }//pass()
+
+   public static synchronized void fail()
+    {
+      //test writer didn't specify why test failed, so give generic
+      fail( "it just plain failed! :-)" );
+    }
+
+   public static synchronized void fail( String whyFailed )
+    {
+      Sysout.println( "The test failed: " + whyFailed );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //check if this called from main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //If main thread, fail now 'cause not sleeping
+         throw new RuntimeException( whyFailed );
+       }
+      theTestPassed = false;
+      testGeneratedInterrupt = true;
+      failureMessage = whyFailed;
+      mainThread.interrupt();
+    }//fail()
+
+ }// class NullPaper
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+ {
+ }
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// make listeners in a class defined here, and instantiate them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+   static int newVar = 0;
+
+   public void eventDispatched(AWTEvent e)
+    {
+      //Counting events to see if we get enough
+      eventCount++;
+
+      if( eventCount == 20 )
+       {
+         //got enough events, so pass
+
+         NullPaper.pass();
+       }
+      else if( tries == 20 )
+       {
+         //tried too many times without getting enough events so fail
+
+         NullPaper.fail();
+       }
+
+    }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog implements ActionListener
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+   Panel  buttonP = new Panel();
+   Button passB = new Button( "pass" );
+   Button failB = new Button( "fail" );
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      passB = new Button( "pass" );
+      passB.setActionCommand( "pass" );
+      passB.addActionListener( this );
+      buttonP.add( "East", passB );
+
+      failB = new Button( "fail" );
+      failB.setActionCommand( "fail" );
+      failB.addActionListener( this );
+      buttonP.add( "West", failB );
+
+      add( "South", buttonP );
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+   //catch presses of the passed and failed buttons.
+   //simply call the standard pass() or fail() static methods of
+   //NullPaper
+   public void actionPerformed( ActionEvent e )
+    {
+      if( e.getActionCommand() == "pass" )
+       {
+         NullPaper.pass();
+       }
+      else
+       {
+         NullPaper.fail();
+       }
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/Orient.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,460 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 4236095
+  @summary  Confirm that the you get three pages of output, one
+            each in portrait, landscape, and reverse landscape
+            orientations.
+  @author rbi: area=PageFormat
+  @run main/manual Orient
+*/
+
+
+//*** global search and replace Orient with name of the test ***
+
+/**
+ * Orient.java
+ *
+ * summary:
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+
+// This test is a "main" test as applets would need Runtime permission
+// "queuePrintJob".
+
+public class Orient implements Printable {
+
+   private static void init()
+    {
+        //*** Create instructions for the user here ***
+
+        String[] instructions =
+        {
+         "On-screen inspection is not possible for this printing-specific",
+         "test therefore its only output is three printed pages.",
+         "To be able to run this test it is required to have a default",
+         "printer configured in your user environment.",
+         "",
+         "Visual inspection of the printed page is needed. A passing",
+         "test will print three pages each containing a large oval ",
+         "with the text describing the orientation: PORTRAIT, LANDSCAPE",
+         "or REVERSE_LANDSCAPE, inside of it. The first page will ",
+         "be emitted in portait orientation, the second page in landscape ",
+         "orientation and the third page in reverse-landscape orientation. ",
+         "On each page the oval will be wholly within the imageable area ",
+         "of the page. In a failing test the oval on the third page ",
+         "will be clipped against the imageable area.",
+         "Axes will indicate the direction of increasing X and Y"
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+        PrinterJob pjob = PrinterJob.getPrinterJob();
+
+        Book book = new Book();
+
+        // Page 1
+        PageFormat portrait = pjob.defaultPage();
+        portrait.setOrientation(PageFormat.PORTRAIT);
+        book.append(new Orient(), portrait);
+
+        // Page 2
+        PageFormat landscape = pjob.defaultPage();
+        landscape.setOrientation(PageFormat.LANDSCAPE);
+        book.append(new Orient(), landscape);
+
+        // Page 3
+        PageFormat reverseLandscape = pjob.defaultPage();
+        reverseLandscape.setOrientation(PageFormat.REVERSE_LANDSCAPE);
+        book.append(new Orient(), reverseLandscape);
+
+        pjob.setPageable(book);
+        try {
+            pjob.print();
+        } catch (PrinterException e) {
+            e.printStackTrace();
+        }
+
+    }//End  init()
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.translate(pf.getImageableX(), pf.getImageableY());
+        drawGraphics(g2d, pf);
+        return Printable.PAGE_EXISTS;
+    }
+
+    void drawGraphics(Graphics2D g, PageFormat pf) {
+        double iw = pf.getImageableWidth();
+        double ih = pf.getImageableHeight();
+
+        g.setColor(Color.black);
+        String orientation;
+        switch (pf.getOrientation()) {
+           case PageFormat.PORTRAIT  : orientation = "PORTRAIT";
+                                       break;
+           case PageFormat.LANDSCAPE : orientation = "LANDSCAPE";
+                                       break;
+           case PageFormat.REVERSE_LANDSCAPE :
+                                       orientation = "REVERSE_LANDSCAPE";
+                                       break;
+           default                   : orientation = "INVALID";
+        }
+        g.drawString(orientation, 100, 300);
+        g.draw(new Ellipse2D.Double(0, 0, iw, ih));
+        g.drawString("(0,0)", 5,15);
+        g.drawLine(0,0,300,0);
+        g.drawString("X", 300,15);
+        g.drawLine(0,0,0,300);
+        g.drawString("Y",5,300);
+    }
+
+
+   /*****************************************************
+     Standard Test Machinery Section
+      DO NOT modify anything in this section -- it's a
+      standard chunk of code which has all of the
+      synchronisation necessary for the test harness.
+      By keeping it the same in all tests, it is easier
+      to read and understand someone else's test, as
+      well as insuring that all tests behave correctly
+      with the test harness.
+     There is a section following this for test-defined
+      classes
+   ******************************************************/
+   private static boolean theTestPassed = false;
+   private static boolean testGeneratedInterrupt = false;
+   private static String failureMessage = "";
+
+   private static Thread mainThread = null;
+
+   private static int sleepTime = 300000;
+
+   public static void main( String args[] ) throws InterruptedException
+    {
+      mainThread = Thread.currentThread();
+      try
+       {
+         init();
+       }
+      catch( TestPassedException e )
+       {
+         //The test passed, so just return from main and harness will
+         // interepret this return as a pass
+         return;
+       }
+      //At this point, neither test passed nor test failed has been
+      // called -- either would have thrown an exception and ended the
+      // test, so we know we have multiple threads.
+
+      //Test involves other threads, so sleep and wait for them to
+      // called pass() or fail()
+      try
+       {
+         Thread.sleep( sleepTime );
+         //Timed out, so fail the test
+         throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+       }
+      catch (InterruptedException e)
+       {
+         if( ! testGeneratedInterrupt ) throw e;
+
+         //reset flag in case hit this code more than once for some reason (just safety)
+         testGeneratedInterrupt = false;
+         if ( theTestPassed == false )
+          {
+            throw new RuntimeException( failureMessage );
+          }
+       }
+
+    }//main
+
+   public static synchronized void setTimeoutTo( int seconds )
+    {
+      sleepTime = seconds * 1000;
+    }
+
+   public static synchronized void pass()
+    {
+      Sysout.println( "The test passed." );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //first check if this is executing in main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //Still in the main thread, so set the flag just for kicks,
+         // and throw a test passed exception which will be caught
+         // and end the test.
+         theTestPassed = true;
+         throw new TestPassedException();
+       }
+      //pass was called from a different thread, so set the flag and interrupt
+      // the main thead.
+      theTestPassed = true;
+      testGeneratedInterrupt = true;
+      mainThread.interrupt();
+    }//pass()
+
+   public static synchronized void fail()
+    {
+      //test writer didn't specify why test failed, so give generic
+      fail( "it just plain failed! :-)" );
+    }
+
+   public static synchronized void fail( String whyFailed )
+    {
+      Sysout.println( "The test failed: " + whyFailed );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //check if this called from main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //If main thread, fail now 'cause not sleeping
+         throw new RuntimeException( whyFailed );
+       }
+      theTestPassed = false;
+      testGeneratedInterrupt = true;
+      failureMessage = whyFailed;
+      mainThread.interrupt();
+    }//fail()
+
+ }// class Orient
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+ {
+ }
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// make listeners in a class defined here, and instantiate them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+   static int newVar = 0;
+
+   public void eventDispatched(AWTEvent e)
+    {
+      //Counting events to see if we get enough
+      eventCount++;
+
+      if( eventCount == 20 )
+       {
+         //got enough events, so pass
+
+         Orient.pass();
+       }
+      else if( tries == 20 )
+       {
+         //tried too many times without getting enough events so fail
+
+         Orient.fail();
+       }
+
+    }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog implements ActionListener
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+   Panel  buttonP = new Panel();
+   Button passB = new Button( "pass" );
+   Button failB = new Button( "fail" );
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      passB = new Button( "pass" );
+      passB.setActionCommand( "pass" );
+      passB.addActionListener( this );
+      buttonP.add( "East", passB );
+
+      failB = new Button( "fail" );
+      failB.setActionCommand( "fail" );
+      failB.addActionListener( this );
+      buttonP.add( "West", failB );
+
+      add( "South", buttonP );
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+   //catch presses of the passed and failed buttons.
+   //simply call the standard pass() or fail() static methods of
+   //Orient
+   public void actionPerformed( ActionEvent e )
+    {
+      if( e.getActionCommand() == "pass" )
+       {
+         Orient.pass();
+       }
+      else
+       {
+         Orient.fail();
+       }
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/PDialogTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4855801
+ * @summary Changing margins in the page format does not have any effect
+ * @run main/manual PDialogTest
+ */
+import java.awt.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class PDialogTest
+{
+
+    public static void main(String[] args) {
+        PageFormat page=new PageFormat();
+        while(true){
+            page=java.awt.print.PrinterJob.getPrinterJob().pageDialog(page);
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/PageSetupDialog.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,353 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4197377
+ * @bug 4299145
+ * @bug 6358747
+ * @bug 6574633
+ * @summary Page setup dialog settings
+ * @author prr
+ * @run main/manual PageSetupDialog
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+
+public class PageSetupDialog extends Frame implements Printable {
+
+  PrinterJob myPrinterJob;
+  PageFormat myPageFormat;
+  Label pw, ph, pglm, pgiw, pgrm, pgtm, pgih, pgbm;
+  Label myWidthLabel;
+  Label myHeightLabel;
+  Label myImageableXLabel;
+  Label myImageableYLabel;
+  Label myImageableRightLabel;
+  Label myImageableBottomLabel;
+  Label myImageableWidthLabel;
+  Label myImageableHeightLabel;
+  Label myOrientationLabel;
+  Checkbox reverseCB;
+  boolean alpha = false;
+  boolean reverse = false;
+
+  protected void displayPageFormatAttributes() {
+
+    myWidthLabel.setText("Format Width = " + (float)myPageFormat.getWidth());
+    myHeightLabel.setText("Format Height = " + (float)myPageFormat.getHeight());
+    myImageableXLabel.setText
+        ("Format Left Margin = " + (float)myPageFormat.getImageableX());
+    myImageableRightLabel.setText
+        ("Format Right Margin = " + (float)(myPageFormat.getWidth() -
+        (myPageFormat.getImageableX() + myPageFormat.getImageableWidth())));
+    myImageableWidthLabel.setText
+        ("Format ImageableWidth = " + (float)myPageFormat.getImageableWidth());
+    myImageableYLabel.setText
+        ("Format Top Margin = " + (float)myPageFormat.getImageableY());
+    myImageableBottomLabel.setText
+        ("Format Bottom Margin = " + (float)(myPageFormat.getHeight() -
+        (myPageFormat.getImageableY() + myPageFormat.getImageableHeight())));
+    myImageableHeightLabel.setText
+        ("Format ImageableHeight = " + (float)myPageFormat.getImageableHeight());
+    int o = myPageFormat.getOrientation();
+    if (o == PageFormat.LANDSCAPE && reverse) {
+        o = PageFormat.REVERSE_LANDSCAPE;
+        myPageFormat.setOrientation(PageFormat.REVERSE_LANDSCAPE);
+    } else if (o == PageFormat.REVERSE_LANDSCAPE && !reverse) {
+        o = PageFormat.LANDSCAPE;
+        myPageFormat.setOrientation(PageFormat.LANDSCAPE);
+    }
+    myOrientationLabel.setText
+        ("Format Orientation = " +
+                (o == PageFormat.PORTRAIT ? "PORTRAIT" :
+                 o == PageFormat.LANDSCAPE ? "LANDSCAPE" :
+                 o == PageFormat.REVERSE_LANDSCAPE ? "REVERSE_LANDSCAPE" :
+                 "<invalid>"));
+    Paper p = myPageFormat.getPaper();
+    pw.setText("Paper Width = " + (float)p.getWidth());
+    ph.setText("Paper Height = " + (float)p.getHeight());
+    pglm.setText("Paper Left Margin = " + (float)p.getImageableX());
+    pgiw.setText("Paper Imageable Width = " + (float)p.getImageableWidth());
+    pgrm.setText("Paper Right Margin = " +
+         (float)(p.getWidth() - (p.getImageableX()+p.getImageableWidth())));
+    pgtm.setText("Paper Top Margin = " + (float)p.getImageableY());
+    pgih.setText("Paper Imageable Height = " + (float)p.getImageableHeight());
+    pgbm.setText("Paper Bottom Margin = " +
+       (float)(p.getHeight() - (p.getImageableY()+p.getImageableHeight())));
+  }
+
+  public PageSetupDialog() {
+    super ("Page Dialog Test");
+    myPrinterJob = PrinterJob.getPrinterJob();
+    myPageFormat = new PageFormat();
+    Paper p = new Paper();
+    double margin = 1.5*72;
+    p.setImageableArea(margin, margin,
+                       p.getWidth()-2*margin, p.getHeight()-2*margin);
+    myPageFormat.setPaper(p);
+    Panel c = new Panel();
+    c.setLayout (new GridLayout (9, 2, 0, 0));
+    c.add (reverseCB = new Checkbox("reverse if landscape"));
+    c.add (myOrientationLabel = new Label());
+    c.add (myWidthLabel = new Label());
+    c.add (pw = new Label());
+    c.add (myImageableXLabel = new Label());
+    c.add (pglm = new Label());
+    c.add (myImageableRightLabel = new Label());
+    c.add (pgrm = new Label());
+    c.add (myImageableWidthLabel = new Label());
+    c.add (pgiw = new Label());
+    c.add (myHeightLabel = new Label());
+    c.add (ph = new Label());
+    c.add (myImageableYLabel = new Label());
+    c.add (pgtm = new Label());
+    c.add (myImageableHeightLabel = new Label());
+    c.add (pgih = new Label());
+    c.add (myImageableBottomLabel = new Label());
+    c.add (pgbm = new Label());
+
+    reverseCB.addItemListener(new ItemListener() {
+                public void itemStateChanged(ItemEvent e) {
+                       reverse = e.getStateChange() == ItemEvent.SELECTED;
+                       int o = myPageFormat.getOrientation();
+                       if (o == PageFormat.LANDSCAPE ||
+                           o == PageFormat.REVERSE_LANDSCAPE) {
+                           displayPageFormatAttributes();
+                       }
+                }
+    });
+
+    add("Center", c);
+    displayPageFormatAttributes();
+    Panel panel = new Panel();
+    Button pageButton = new Button ("Page Setup...");
+    pageButton.addActionListener(new ActionListener() {
+                public void actionPerformed (ActionEvent e) {
+                        myPageFormat = myPrinterJob.pageDialog (myPageFormat);
+                        displayPageFormatAttributes();
+                }
+    });
+    Button printButton = new Button ("Print ...");
+    printButton.addActionListener(new ActionListener() {
+                public void actionPerformed (ActionEvent e) {
+                    try {
+                         if (myPrinterJob.printDialog()) {
+                             myPrinterJob.setPrintable(PageSetupDialog.this,
+                                                       myPageFormat);
+                             alpha = false;
+                             myPrinterJob.print();
+                    }
+                    } catch (PrinterException pe ) {
+                    }
+                }
+    });
+    Button printAlphaButton = new Button ("Print w/Alpha...");
+    printAlphaButton.addActionListener(new ActionListener() {
+           public void actionPerformed (ActionEvent e) {
+                    try {
+                         if (myPrinterJob.printDialog()) {
+                             myPrinterJob.setPrintable(PageSetupDialog.this,
+                                                       myPageFormat);
+                             alpha = true;
+                             myPrinterJob.print();
+                    }
+                    } catch (PrinterException pe ) {
+                    }
+           }
+    });
+    panel.add (pageButton);
+    panel.add (printButton);
+    panel.add (printAlphaButton);
+    add("South", panel);
+    addWindowListener (new WindowAdapter() {
+         public void windowClosing (WindowEvent e) {
+            dispose();
+            System.exit (0);
+         }
+
+      });
+      //setSize (280, 550);
+      pack();
+      setVisible (true);
+  }
+
+  public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
+
+     if (pageIndex > 0) {
+        return Printable.NO_SUCH_PAGE;
+     }
+
+     Graphics2D g2d = (Graphics2D)graphics;
+     g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
+     g2d.drawString("ORIGIN("+pageFormat.getImageableX()+","+
+                             pageFormat.getImageableY()+")", 20, 20);
+     g2d.drawString("X THIS WAY", 200, 50);
+     g2d.drawString("Y THIS WAY", 60 , 200);
+     g2d.drawString("Graphics is " + g2d.getClass().getName(), 100, 100);
+     g2d.drawRect(0,0,(int)pageFormat.getImageableWidth(),
+                      (int)pageFormat.getImageableHeight());
+     if (alpha) {
+       g2d.setColor(new Color(0,0,255,192));
+     } else {
+        g2d.setColor(Color.blue);
+     }
+     g2d.drawRect(1,1,(int)pageFormat.getImageableWidth()-2,
+                      (int)pageFormat.getImageableHeight()-2);
+
+     return  Printable.PAGE_EXISTS;
+  }
+
+  public static void main( String[] args) {
+
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "This test is very flexible and requires much interaction.",
+         "If the platform print dialog supports it, adjust orientation",
+         "and margins and print pages and compare the results with the",
+         "request."
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+     new PageSetupDialog();
+  }
+
+}
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/ReverseLandscapeTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4254954
+ * @summary PageFormat would fail on solaris when setting orientation
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+
+public class ReverseLandscapeTest extends Frame  {
+
+ private TextCanvas c;
+
+ public static void main(String args[]) {
+    ReverseLandscapeTest f = new ReverseLandscapeTest();
+    f.show();
+ }
+
+ public ReverseLandscapeTest() {
+    super("JDK 1.2 Text Printing");
+
+    c = new TextCanvas();
+    add("Center", c);
+
+    PrinterJob pj = PrinterJob.getPrinterJob();
+
+    PageFormat pf = pj.defaultPage();
+    pf.setOrientation(PageFormat.REVERSE_LANDSCAPE);
+
+    // This code can be added if one wishes to test printing
+//     pf = pj.pageDialog(pf);
+
+//     if (pj != null && pj.printDialog()) {
+
+//         pj.setPrintable(c, pf);
+//         try {
+//             pj.print();
+//         } catch (PrinterException pe) {
+//         } finally {
+//             System.err.println("PRINT RETURNED");
+//         }
+//     }
+
+    addWindowListener(new WindowAdapter() {
+       public void windowClosing(WindowEvent e) {
+             System.exit(0);
+            }
+    });
+
+    pack();
+ }
+
+ class TextCanvas extends Panel implements Printable {
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+      int iw = getWidth();
+      int ih = getHeight();
+      Graphics2D g2d = (Graphics2D)g;
+
+      if (pgIndex > 0)
+         return Printable.NO_SUCH_PAGE;
+
+      g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+      g2d.translate(iw/2, ih/2);
+      g2d.setFont(new Font("Times",Font.PLAIN, 12));
+      g2d.setPaint(new Color(0,0,0));
+      g2d.setStroke(new BasicStroke(1f));
+      g2d.drawString("Print REVERSE_LANDSCAPE", 30, 40);
+
+      return Printable.PAGE_EXISTS;
+    }
+
+    public void paint(Graphics g) {
+      g.drawString("Print REVERSE_LANDSCAPE", 30, 40);
+    }
+
+     public Dimension getPreferredSize() {
+        return new Dimension(250, 100);
+    }
+ }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/SetOrient.html	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,48 @@
+<!--
+ Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+   
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+  
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+  
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!-- 
+   @test
+   @bug 4186119
+   @summary Confirm that the clip and transform of the Graphics2D is
+            affected by the landscape orientation of the PageFormat.
+   @run applet/manual=yesno SetOrient.html
+  -->
+<html>
+  <head>
+    <title>SetOrient</title>
+  </head>
+
+  <body>
+This test prints two pages and sends them to the printer.
+One page is in PORTRAIT orientation and the other is in LANDSCAPE
+orientation.  On each page it draws an ellipse inscribed in the clip
+boundary established by the PrinterJob.  The ellipse should fill the
+page within the bounds established by the default margins and not
+extend off any end or side of the page.  Also, the string "Portrait"
+or "Landscape" should be oriented correctly.
+
+      <applet code="SetOrient.class" width=200 height=200></applet>
+  </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/SetOrient.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @bug 4186119: setting orientation does not affect printer
+ * @summary Confirm that the clip and transform of the Graphics2D is
+ *          affected by the landscape orientation of the PageFormat.
+ * @run applet/manual=yesno SetOrient.html
+ */
+
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import java.applet.Applet;
+
+public class SetOrient extends Applet implements Printable {
+    PrinterJob pjob;
+
+    public void init() {
+        pjob = PrinterJob.getPrinterJob();
+
+        Book book = new Book();
+        PageFormat pf = pjob.defaultPage();
+        pf.setOrientation(PageFormat.PORTRAIT);
+        book.append(this, pf);
+        pf = pjob.defaultPage();
+        pf.setOrientation(PageFormat.LANDSCAPE);
+        book.append(this, pf);
+        pjob.setPageable(book);
+
+        try {
+            pjob.print();
+        } catch (PrinterException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+        Graphics2D g2d = (Graphics2D)g;
+        drawGraphics(g2d, pf);
+        return Printable.PAGE_EXISTS;
+    }
+
+    void drawGraphics(Graphics2D g, PageFormat pf) {
+        double ix = pf.getImageableX();
+        double iy = pf.getImageableY();
+        double iw = pf.getImageableWidth();
+        double ih = pf.getImageableHeight();
+
+        g.setColor(Color.black);
+        g.drawString(((pf.getOrientation() == PageFormat.PORTRAIT)
+                      ? "Portrait" : "Landscape"),
+                     (int) (ix+iw/2), (int) (iy+ih/2));
+        g.draw(new Ellipse2D.Double(ix, iy, iw, ih));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/SmallPaperPrinting.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+   import java.awt.*;
+   import java.awt.print.*;
+
+   public class SmallPaperPrinting
+   {
+      public static void main(String args[])
+      {
+        System.out.println("----------------- Instructions --------------------");
+        System.out.println("Arguments: (none)  - paper width=1,     height=.0001");
+        System.out.println("              1    - paper width=.0001, height=1");
+        System.out.println("              2    - paper width=-1,    height=1");
+        System.out.println("A passing test should catch a PrinterException");
+        System.out.println("and should display \"Print error: (exception msg)\".");
+        System.out.println("---------------------------------------------------\n");
+         PrinterJob job = PrinterJob.getPrinterJob();
+         PageFormat format = job.defaultPage();
+         Paper paper = format.getPaper();
+
+         double w = 1, h = .0001;  // Generates ArithmeticException: / by zero.
+         if(args.length > 0 && args[0].equals("1")) {
+            w = .0001;  h = 1; }  // Generates IllegalArgumentException.
+         else if(args.length > 0 && args[0].equals("2")) {
+            w = -1;  h = 1; }  // Generates NegativeArraySizeException.
+         paper.setSize(w, h);
+         paper.setImageableArea(0, 0, w, h);
+         format.setPaper(paper);
+         job.setPrintable(
+               new Printable() {
+                  public int print(Graphics g, PageFormat page_format, int page) {
+                     return NO_SUCH_PAGE;
+                  }
+               }, format);
+
+         try {
+            job.print(); }
+            catch(PrinterException e) {
+               System.err.println("Print error:\n" + e.getMessage()); // Passing test!
+            }
+      }
+   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PageFormat/ValidateCustom.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4414987
+ * @author Jennifer Godinez
+ * @summary Displays width & height of validated custom paper size
+ * @run main/manual ValidateCustom
+ */
+import java.awt.*;
+import java.awt.print.*;
+import java.awt.geom.*;
+import javax.swing.*;
+
+public class ValidateCustom implements Pageable, Printable{
+
+  private static double PIXELS_PER_INCH = 72.0;
+  private static double WIDTH = 17.0; //width of paper in inches
+  private static double LENGTH = 24.0; //length of paper in inches
+  private static boolean VALIDATE = true;
+
+  private PrinterJob printerJob;
+  private PageFormat pageFormat;
+
+  ValidateCustom(){
+    printerJob = PrinterJob.getPrinterJob();
+    createPageFormat();
+  }
+
+  private void createPageFormat(){
+    pageFormat = new PageFormat();
+    Paper p = new Paper();
+    double width   = WIDTH*PIXELS_PER_INCH;
+    double height  = LENGTH*PIXELS_PER_INCH;
+    double ix      = PIXELS_PER_INCH;
+    double iy      = PIXELS_PER_INCH;
+    double iwidth  = width  - 2.0*PIXELS_PER_INCH;
+    double iheight = height - 2.0*PIXELS_PER_INCH;
+    p.setSize(width, height);
+    p.setImageableArea(ix, iy, iwidth, iheight);
+    pageFormat.setPaper(p);
+  }
+
+  public Printable getPrintable(int index){
+    return this;
+  }
+
+  public PageFormat getPageFormat(int index){
+    return pageFormat;
+  }
+
+  public int getNumberOfPages(){
+    return 1;
+  }
+
+  private void printPaperSize(PageFormat pf){
+    Paper p = pf.getPaper();
+    System.out.println("paper size = ("+p.getWidth()+", "+p.getHeight()+")");
+  }
+
+  public void print(){
+    //if(printerJob.printDialog())
+    {
+      try{
+        //printPaperSize(pageFormat);
+        if(VALIDATE){
+            this.pageFormat = printerJob.validatePage(this.pageFormat);
+        }
+        printPaperSize(pageFormat);
+        //printerJob.setPageable(this);
+        //printerJob.print();
+      }catch(Exception e){e.printStackTrace();}
+    }
+  }
+
+  public int print(Graphics g, PageFormat pf, int pageIndex){
+    if(pageIndex == 0){
+      Graphics2D g2 = (Graphics2D)g;
+      Rectangle2D r = new Rectangle2D.Double(PIXELS_PER_INCH, PIXELS_PER_INCH, PIXELS_PER_INCH, PIXELS_PER_INCH);
+      g2.setStroke(new BasicStroke(1.0f));
+      g2.draw(r);
+      return PAGE_EXISTS;
+    }else{
+      return NO_SUCH_PAGE;
+    }
+  }
+
+  public static void main(String[] args){
+        System.out.println("-----------------instructions--------------------");
+        System.out.println("You must have a printer installed in your system \nthat supports custom paper sizes in order to run this test.");
+        System.out.println("Passing test will display the correct width & height\nof custom paper in 1/72nds of an inch.\n");
+        System.out.println("-------------------------------------------------");
+    ValidateCustom pt = new ValidateCustom();
+    pt.print();
+    try{
+      System.in.read();
+    }catch(Exception e){}
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/Cancel/PrinterJobCancel.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4245280
+ * @summary PrinterJob not cancelled when PrinterJob.cancel() is used
+ * @author prr
+ * @run main/manual PrinterJobCancel
+ */
+
+import java.awt.* ;
+import java.awt.print.* ;
+
+public class PrinterJobCancel extends Thread implements Printable {
+
+  PrinterJob pj ;
+  boolean okayed;
+
+  public static void main ( String args[] ) {
+
+     String[] instructions =
+        {
+         "Test that print job cancellation works.",
+         "You must have a printer available to perform this test.",
+         "This test silently starts a print job and while the job is",
+         "still being printed, cancels the print job",
+         "You should see a message on System.out that the job",
+         "was properly cancelled.",
+         "You will need to kill the application manually since regression",
+         "tests apparently aren't supposed to call System.exit()"
+       };
+
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+      PrinterJobCancel pjc = new PrinterJobCancel() ;
+
+      if (pjc.okayed) {
+          pjc.start();
+          try {
+               Thread.sleep(5000);
+               pjc.pj.cancel();
+          } catch ( InterruptedException e ) {
+          }
+      }
+  }
+
+  public PrinterJobCancel() {
+
+    pj = PrinterJob.getPrinterJob() ;
+    pj.setPrintable(this);
+    okayed = pj.printDialog();
+  }
+
+  public void run() {
+    boolean cancelWorked = false;
+    try {
+        pj.print() ;
+    }
+    catch ( PrinterAbortException paex ) {
+      cancelWorked = true;
+      System.out.println("Job was properly cancelled and we");
+      System.out.println("got the expected PrintAbortException");
+    }
+    catch ( PrinterException prex ) {
+      System.out.println("This is wrong .. we shouldn't be here");
+      System.out.println("Looks like a test failure");
+      prex.printStackTrace() ;
+      //throw prex;
+    }
+    finally {
+       System.out.println("DONE PRINTING");
+       if (!cancelWorked) {
+           System.out.println("Looks like the test failed - we didn't get");
+           System.out.println("the expected PrintAbortException ");
+       }
+    }
+    //System.exit(0);
+  }
+
+  public int print(Graphics g, PageFormat pagef, int pidx) {
+
+     if (pidx > 5) {
+        return( Printable.NO_SUCH_PAGE ) ;
+     }
+
+     Graphics2D g2d = (Graphics2D)g;
+     g2d.translate(pagef.getImageableX(), pagef.getImageableY());
+     g2d.setColor(Color.black);
+
+     g2d.drawString(("This is page"+(pidx+1)), 60 , 80);
+     // Need to slow things down a bit .. important not to try this
+     // on the event dispathching thread of course.
+     try {
+          Thread.sleep(2000);
+     } catch (InterruptedException e) {
+     }
+
+     return ( Printable.PAGE_EXISTS );
+  }
+
+}
+
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/CheckAccess.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4151121
+ * @summary Confirm that PrinterJob.getPrinterJob is access checked.
+ * @author Graham Hamilton
+ */
+
+import java.awt.print.*;
+import java.security.*;
+
+public class CheckAccess {
+
+    static boolean verbose;
+
+    private static void println(String mess) {
+        if (verbose) {
+            System.err.println(mess);
+        }
+    }
+
+    /**
+     * SecurityManager that rejects all print requests,
+     * but allows everything else.
+     */
+    static class PrintHater extends SecurityManager {
+
+        public void checkPermission(Permission p) {
+           // We're easy.
+        }
+
+        public void checkPrintJobAccess() {
+            throw new SecurityException("No way!");
+        }
+    }
+
+    public static void main(String argv[]) {
+
+        if (argv.length > 0 && argv[0].equals("-v")) {
+            verbose = true;
+        }
+
+        // Try to install our own security manager.
+        try {
+            SecurityManager sm = new PrintHater();
+            println("Installing PrintHater security manager");
+            System.setSecurityManager(sm);
+            println("Installed security manager OK");
+
+        } catch (Throwable th) {
+            System.err.println("Failed to install SecurityManager");
+            th.printStackTrace();
+            throw new RuntimeException("Failed to install SecurityManager");
+        }
+
+        try {
+
+            println("Calling PrinterJob.getPrinterJob()");
+            PrinterJob.getPrinterJob();
+
+            // Woops.  We did not get the SecurityException we expected.
+            println("Failed to get SecurityException");
+            throw new RuntimeException("Failed to get expected SecurityException");
+
+        } catch (SecurityException ex) {
+            // Happy, happy.  This is what we want.
+            println("Got expected SecurityException OK.");
+            return;
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/CheckPrivilege.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4151151
+ * @summary Confirm that low-level print code does doPrivilege.
+ * @author Graham Hamilton
+ */
+
+import java.awt.print.*;
+
+public class CheckPrivilege implements Printable {
+
+    static boolean verbose;
+
+    private static void println(String mess) {
+        if (verbose) {
+            System.err.println(mess);
+        }
+    }
+
+    /**
+     * SecurityManager that allows print requests, but
+     * causes things like "exec" to get checked.
+     */
+    static class PrintLover extends SecurityManager {
+        public void checkPrintJobAccess() {
+        }
+        public void checkPackageAccess(String pkg) {
+        }
+        public void checkPropertyAccess(String key) {
+        }
+    }
+
+    /**
+     * Internal exception to boucne us out of the print code
+     */
+    class Printing extends RuntimeException {
+    }
+
+    public static void main(String argv[]) {
+
+        System.out.println( "-----------------------------------------------------------------------");
+        System.out.println( "INSTRUCTIONS: You should have a printer configured in your system to do this test. Test fails if you get this error message:");
+        System.out.println("   \"Regression: printing causes a NullPointerException\"");
+    System.out.println( "-----------------------------------------------------------------------");
+
+        if (argv.length > 0 && argv[0].equals("-v")) {
+            verbose = true;
+        }
+
+        // We need to make sure AWT is initialized.  This is bug #4162674
+        java.awt.Toolkit.getDefaultToolkit();
+
+        // Try to install our own security manager.
+        try {
+            SecurityManager sm = new PrintLover();
+            println("Installing PrintLover security manager");
+            System.setSecurityManager(sm);
+            println("Installed security manager OK");
+
+        } catch (Throwable th) {
+            System.err.println("Failed to install SecurityManager");
+            th.printStackTrace();
+            throw new RuntimeException("Failed to install SecurityManager");
+        }
+
+        try {
+            println("calling getPrinterJob");
+            PrinterJob pj = PrinterJob.getPrinterJob();
+            if ((pj == null) || (pj.getPrintService() == null)){
+                return;
+            }
+
+            println("PrinterJob class is " + pj.getClass());
+            println("calling pj.setPrintable");
+            pj.setPrintable(new CheckPrivilege());
+            println("calling pj.print");
+            pj.print();
+            println("done pj.print");
+
+        } catch (Printing ex) {
+            // We get here if the print request started OK.
+            println("Caught \"Printing\" exception OK");
+
+        } catch (PrinterException ex) {
+            System.err.println("Caught " + ex);
+            throw new RuntimeException("" + ex);
+
+        } catch (NullPointerException ex) {
+            // This is the bug:
+            System.err.println("Caught " + ex);
+            System.err.println("Regression: printing causes a NullPointerException");
+            throw ex;
+        }
+
+        //System.exit(0);
+
+    }
+
+    // Back-call from the new print APIs.
+    // We always say we have bothing to print.
+    public int print(java.awt.Graphics g, PageFormat pf, int index) {
+        println("Started printing " + index);
+        return Printable.NO_SUCH_PAGE;
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/CompareImageable.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 4748055
+  @summary   PASS if the values are same in both cases (2 and 3) below.
+  @run main/manual CompareImageable
+*/
+
+/********************************************************************
+Testcase for comparing the imageable width and height of the paper
+with and without using print dialog.
+
+How to run:
+
+1. Launch the app. You'll find a checkbox and a print button.
+2. Click on the print button with the checkbox unselected. Note the
+imageable width and height displayed on the console
+3. Click on the print button with the checkbox selected. This popus up
+the print dialog. Click ok on the dialog. Note the imageable width and
+height displayed on the console.
+
+Result:  It's a PASS if the values are same in both cases (2 and 3),
+        otherwise not.
+
+*********************************************************************/
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.awt.print.*;
+
+
+public class CompareImageable implements Printable {
+
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+
+       //get the printable width and height of the paper.
+        int pageHeight = (int)pgFmt.getImageableHeight();
+        int pageWidth = (int)pgFmt.getImageableWidth();
+
+        System.out.println("imageable width = " + pageWidth + " height = " + pageHeight);
+        return Printable.NO_SUCH_PAGE;
+    }
+
+
+    public static void main(String [] args) {
+
+        final JFrame frame = new JFrame("Print Test");
+        final JButton printBtn = new JButton("Print");
+        final JCheckBox dialogBtn = new JCheckBox("Native dialog");
+
+        JPanel panel = new JPanel(new FlowLayout());
+        panel.add(dialogBtn);
+        panel.add(printBtn);
+        frame.getContentPane().add(panel);
+
+        printBtn.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+
+                        CompareImageable test = new CompareImageable();
+                        PrinterJob pj = PrinterJob.getPrinterJob();
+
+                        if (dialogBtn.isSelected() && !pj.printDialog()) {
+                                //user clicked 'Cancel' button in the print dialog. No printing.
+                                return;
+                        }
+
+                        if (dialogBtn.isSelected()) {
+                                System.out.println("With print dialog...");
+                        } else {
+                                System.out.println("Without print dialog...");
+                        }
+
+                        if (pj == null) {
+                                System.out.println("No printer job found...");
+                                return;
+                        }
+                        pj.setPrintable(test);
+
+                        try {
+                                pj.print();
+
+                        } catch (Exception ex) {
+                                ex.printStackTrace();
+                        }
+                }
+        });
+
+
+        frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
+        frame.setSize(400, 400);
+        frame.setVisible(true);
+
+    }
+}
Binary file test/java/awt/print/PrinterJob/CustomFont/A.ttf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/CustomFont/CustomFont.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,416 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 4386025
+  @summary fonts not in win32 font directory print incorrectly.
+  @author prr: area=PrinterJob
+  @run main/manual CustomFont
+*/
+import java.io.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+
+
+public class CustomFont implements Printable {
+
+   private Image opaqueimg,transimg;
+
+   private static void init() {
+
+        //*** Create instructions for the user here ***
+
+        String[] instructions = {
+         "On-screen inspection is not possible for this printing-specific",
+         "test therefore its only output is a printed page.",
+         "To be able to run this test it is required to have a default",
+         "printer configured in your user environment.",
+         "",
+         "Visual inspection of the printed page is needed. A passing",
+         "test will print a page on which one line of text will be",
+         "printed: a long string of 'A' characters.",
+         "The A should have of a curly style",
+         "If instead its in the default sansserif font, the test fails",
+       };
+
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+        PrinterJob pjob = PrinterJob.getPrinterJob();
+
+        Book book = new Book();
+
+        PageFormat portrait = pjob.defaultPage();
+        book.append(new CustomFont(),portrait);
+
+        pjob.setPageable(book);
+
+        if (pjob.printDialog()) {
+            try {
+                pjob.print();
+            } catch (PrinterException e) {
+                System.err.println(e);
+                e.printStackTrace();
+            }
+        }
+        System.out.println("Done Printing");
+
+    }//End  init()
+
+
+  Font customFont;
+  public CustomFont() {
+       try {
+             FileInputStream fin = new FileInputStream("A.ttf");
+             Font cf = Font.createFont(Font.TRUETYPE_FONT, fin);
+             customFont = cf.deriveFont(Font.PLAIN, 14);
+        } catch (Exception ioe) {
+             System.err.println(ioe.getMessage());
+             customFont = new Font("serif", Font.PLAIN, 14);
+        }
+  }
+
+  public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+
+       Graphics2D g2D = (Graphics2D) g;
+       g2D.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+
+       g2D.setColor(Color.black);
+       g2D.setFont(customFont);
+       String str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
+       g.drawString(str, 100, 100);
+
+       return Printable.PAGE_EXISTS;
+  }
+
+  /**
+   * The graphics is scaled and the font and the positions
+   * are reduced in respect to the scaling, so that all
+   * printing should be the same.
+   *
+   * @param g2D     graphics2D to paint on
+   * @param font    font to paint
+   * @param scale   scale for the painting
+   * @param x       x position
+   * @param y       y position
+   */
+  private void printScale(Graphics2D g2D, Font font,
+                           float scale, float x, float y) {
+
+    int RES = 72;
+
+    g2D.scale(scale, scale);
+
+    g2D.setFont   (font.deriveFont(10.0f / scale));
+    g2D.drawString("This text is scaled by a factor of " + scale,
+                   x * RES / scale, y * RES / scale);
+
+    g2D.scale(1/scale, 1/scale);
+
+}
+
+   /*****************************************************
+     Standard Test Machinery Section
+      DO NOT modify anything in this section -- it's a
+      standard chunk of code which has all of the
+      synchronisation necessary for the test harness.
+      By keeping it the same in all tests, it is easier
+      to read and understand someone else's test, as
+      well as insuring that all tests behave correctly
+      with the test harness.
+     There is a section following this for test-defined
+      classes
+   ******************************************************/
+   private static boolean theTestPassed = false;
+   private static boolean testGeneratedInterrupt = false;
+   private static String failureMessage = "";
+
+   private static Thread mainThread = null;
+
+   private static int sleepTime = 300000;
+
+   public static void main( String args[] ) throws InterruptedException
+    {
+      mainThread = Thread.currentThread();
+      try
+       {
+         init();
+       }
+      catch( TestPassedException e )
+       {
+         //The test passed, so just return from main and harness will
+         // interepret this return as a pass
+         return;
+       }
+      //At this point, neither test passed nor test failed has been
+      // called -- either would have thrown an exception and ended the
+      // test, so we know we have multiple threads.
+
+      //Test involves other threads, so sleep and wait for them to
+      // called pass() or fail()
+      try
+       {
+         Thread.sleep( sleepTime );
+         //Timed out, so fail the test
+         throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+       }
+      catch (InterruptedException e)
+       {
+         if( ! testGeneratedInterrupt ) throw e;
+
+         //reset flag in case hit this code more than once for some reason (just safety)
+         testGeneratedInterrupt = false;
+         if ( theTestPassed == false )
+          {
+            throw new RuntimeException( failureMessage );
+          }
+       }
+
+    }//main
+
+   public static synchronized void setTimeoutTo( int seconds )
+    {
+      sleepTime = seconds * 1000;
+    }
+
+   public static synchronized void pass()
+    {
+      Sysout.println( "The test passed." );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //first check if this is executing in main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //Still in the main thread, so set the flag just for kicks,
+         // and throw a test passed exception which will be caught
+         // and end the test.
+         theTestPassed = true;
+         throw new TestPassedException();
+       }
+      //pass was called from a different thread, so set the flag and interrupt
+      // the main thead.
+      theTestPassed = true;
+      testGeneratedInterrupt = true;
+      mainThread.interrupt();
+    }//pass()
+
+   public static synchronized void fail()
+    {
+      //test writer didn't specify why test failed, s     fail( "it just plain failed! :-)" );
+    }
+
+   public static synchronized void fail( String whyFailed )
+    {
+      Sysout.println( "The test failed: " + whyFailed );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //check if this called from main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //If main thread, fail now 'cause not sleeping
+         throw new RuntimeException( whyFailed );
+       }
+      theTestPassed = false;
+      testGeneratedInterrupt = true;
+      failureMessage = whyFailed;
+      mainThread.interrupt();
+    }//fail()
+
+}// class CustomFont
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+ {
+ }
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog implements ActionListener {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+   Panel  buttonP = new Panel();
+   Button passB = new Button( "pass" );
+   Button failB = new Button( "fail" );
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      passB = new Button( "pass" );
+      passB.setActionCommand( "pass" );
+      passB.addActionListener( this );
+      buttonP.add( "East", passB );
+
+      failB = new Button( "fail" );
+      failB.setActionCommand( "fail" );
+      failB.addActionListener( this );
+      buttonP.add( "West", failB );
+
+      add( "South", buttonP );
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+   //catch presses of the passed and failed buttons.
+   //simply call the standard pass() or fail() static methods of
+   //CustomFont
+   public void actionPerformed( ActionEvent e )
+    {
+      if( e.getActionCommand() == "pass" )
+       {
+         CustomFont.pass();
+       }
+      else
+       {
+         CustomFont.fail();
+       }
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/DeviceScale.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test 1.2 02/05/15
+   @bug 4810363 4924441
+   @run main DeviceScale
+   @summary check the peek scale is the same as the device scale, and that the
+   clips are also the same
+*/
+import java.io.*;
+import java.net.*;
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class DeviceScale implements Printable {
+
+    boolean firstTime = true;
+    double sx, sy;
+    Shape clip, firstClip;
+
+    public int print(Graphics g, PageFormat pf, int pageIndex)  {
+        Graphics2D g2 = (Graphics2D)g;
+        if (pageIndex>=1) {
+                return Printable.NO_SUCH_PAGE;
+        }
+        AffineTransform at = g2.getTransform();
+        System.out.println(at);
+        clip = g2.getClip();
+        System.out.println(clip);
+        if (firstTime)  {
+            firstTime = false;
+            sx = Math.abs(at.getScaleX());
+            sy = Math.abs(at.getScaleY());
+            firstClip = clip;
+        } else {
+            double newSx = Math.abs(at.getScaleX());
+            double newSy = Math.abs(at.getScaleY());
+            if (Math.abs(sx - newSx) > 0.1 ||
+                Math.abs(sy - newSy) > 0.1) {
+                throw new RuntimeException("different scale, was "+
+                                           sx+","+sy+" now " +
+                                           newSx+","+ newSy);
+            }
+            if (!clip.equals(firstClip)) {
+                throw new RuntimeException("different clip, was "+ firstClip +
+                                           " now "+ clip);
+            }
+        }
+        return Printable.PAGE_EXISTS;
+    }
+
+    public static void doit(OrientationRequested o) throws Exception {
+        PrinterJob  pj = PrinterJob.getPrinterJob();
+        if (pj.getPrintService() == null) {
+          System.out.println("No print service found.");
+          return;
+        }
+        pj.setPrintable(new DeviceScale());
+        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+        aset.add(o);
+        String fileName = "out.prn";
+        File f = new File(fileName);
+        f.deleteOnExit();
+        URI dest = f.toURI();
+        aset.add(new Destination(dest));
+        pj.print(aset);
+    }
+
+
+    public static void main(String arg[]) throws Exception {
+
+        doit(OrientationRequested.PORTRAIT);
+        doit(OrientationRequested.LANDSCAPE);
+        doit(OrientationRequested.REVERSE_LANDSCAPE);
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/DrawImage.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4329866
+ * @summary Confirm that no printing exception is generated.
+ * @author jgodinez
+ * @run main/manual DrawImage
+ */
+
+import java.util.*;
+import java.text.*;
+import java.io.*;
+import java.net.*;
+import java.awt.*;
+import java.awt.font.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import java.awt.event.*;
+import java.awt.image.*;
+import java.awt.image.renderable.*;
+import javax.swing.*;
+import javax.swing.text.*;
+import javax.swing.border.*;
+import javax.swing.event.*;
+
+public class DrawImage
+{
+    protected static final double _hwBorder = 72 / 4;       // 1/4 inch
+    protected static final double _border = 72 / 4;         // 1/4 inch
+    protected static final int _objectBorder = 15;
+    protected static final int _verticalGap = 20;
+    protected static final int _textIndent = 150;
+
+    protected BufferedImage _image;
+
+    protected PageFormat  _pageFormat;
+
+    public DrawImage(BufferedImage image) {
+        _image = image;
+        PrinterJob pj = PrinterJob.getPrinterJob();
+        _pageFormat = pj.defaultPage();
+
+ }
+
+
+    protected int printImage(Graphics g, PageFormat pf, BufferedImage image) {
+        Graphics2D g2D = (Graphics2D)g;
+        g2D.transform(new AffineTransform(_pageFormat.getMatrix()));
+
+        int paperW = (int)pf.getImageableWidth(), paperH =
+            (int)pf.getImageableHeight();
+
+        int x = (int)pf.getImageableX(), y = (int)pf.getImageableY();
+        g2D.setClip(x, y, paperW, paperH);
+
+        // print images
+        if (image != null ) {
+            int imageH = image.getHeight(), imageW = image.getWidth();
+            // make slightly smaller (25) than max possible width
+            float scaleFactor = ((float)((paperW - 25) - _objectBorder -
+                                         _objectBorder) / (float)(imageW));
+            int scaledW = (int)(imageW * scaleFactor),
+                scaledH = (int)(imageH *scaleFactor);
+            BufferedImageOp scaleOp = new RescaleOp(scaleFactor, 0, null);
+            g2D.drawImage(image, scaleOp, x + _objectBorder, y + _objectBorder);
+            y += _objectBorder + scaledH + _objectBorder;
+            return Printable.PAGE_EXISTS;
+        }
+        else {
+            return Printable.NO_SUCH_PAGE;
+        }
+    }
+
+    public void print() {
+        try {
+            final PrinterJob pj = PrinterJob.getPrinterJob();
+            pj.setJobName("Print Image");
+            pj.setPrintable(new Printable() {
+                public int print(Graphics g, PageFormat pf, int pageIndex) {
+                    int result = NO_SUCH_PAGE;
+                    if (pageIndex == 0) {
+                        result = printImage(g, _pageFormat, _image);
+                    }
+                    return result;
+                }
+            });
+            if (pj.printDialog()) {
+                try { pj.print(); }
+                catch (PrinterException e) {
+                    System.out.println(e);
+                }
+            }
+
+        }
+        catch (Exception e) {
+            e.printStackTrace(System.out);
+        }
+    }
+
+    public static void main(String[] args) {
+                                String[] instructions =
+           {
+            "You must have a printer available to perform this test.",
+            "The test passes if you get a printout of a gray rectangle",
+                                                "with white text without any exception."
+          };
+
+         Sysout.createDialog( );
+         Sysout.printInstructions( instructions );
+
+        BufferedImage image = prepareFrontImage();
+        DrawImage pt = new DrawImage(image);
+        pt.print();
+        //      System.exit(0);
+    }
+
+
+
+    public static BufferedImage prepareFrontImage() {
+        // build my own test images
+        BufferedImage result = new BufferedImage(400, 200,
+                                                 BufferedImage.TYPE_BYTE_GRAY);
+
+        Graphics2D g2D = (Graphics2D)result.getGraphics();
+        g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                             RenderingHints.VALUE_ANTIALIAS_OFF);
+        int w = result.getWidth(), h = result.getHeight();
+
+        g2D.setColor(Color.gray);
+        g2D.fill(new Rectangle(0, 0, w, h));
+
+        g2D.setColor(Color.white);
+
+        AffineTransform original = g2D.getTransform();
+        AffineTransform originXform = AffineTransform.getTranslateInstance(w /
+5, h / 5);
+        g2D.transform(originXform);
+
+
+        g2D.drawString("Front Side", 20, h / 2);
+
+        return result;
+    }
+
+
+}
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/DrawStringMethods.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4185019
+ * @summary Confirm that all of the drawString methods on Graphics2D
+ *          work for printer graphics objects.
+ * @run main/manual DrawStringMethods
+ */
+
+import java.awt.*;
+import java.text.*;
+import java.awt.font.*;
+import java.awt.print.*;
+
+public class DrawStringMethods implements Printable {
+
+    public static void main(String args[]) {
+        String[] instructions =
+        {
+            "Confirm that the methods are printed.",
+            " For Graphics: drawString, drawString, drawChars, drawBytes",
+            " For Graphics2D: drawString, drawString, drawGlyphVector"
+        };
+        Sysout.createDialogWithInstructions( instructions );
+
+
+        PrinterJob pjob = PrinterJob.getPrinterJob();
+        PageFormat pf = pjob.defaultPage();
+        Book book = new Book();
+
+        book.append(new DrawStringMethods(), pf);
+        pjob.setPageable(book);
+
+        try {
+            pjob.print();
+        } catch (PrinterException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    public static AttributedCharacterIterator getIterator(String s) {
+        return new AttributedString(s).getIterator();
+    }
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+        int ix = (int) pf.getImageableX();
+        int iy = (int) pf.getImageableY();
+        String s;
+
+        g.setColor(Color.black);
+
+        iy += 50;
+        s = "--- Graphics methods: ---";
+        g.drawString(s, ix, iy);
+
+        iy += 30;
+        s = "drawString(String str, int x, int y)";
+        g.drawLine(ix, iy, ix+10, iy);
+        g.drawString(s, ix+20, iy);
+
+        iy += 30;
+        s = "drawString(AttributedCharacterIterator iterator, int x, int y)";
+        g.drawLine(ix, iy, ix+10, iy);
+        g.drawString(getIterator(s), ix+20, iy);
+
+        iy += 30;
+        s = "drawChars(char data[], int offset, int length, int x, int y)";
+        g.drawLine(ix, iy, ix+10, iy);
+        g.drawChars(s.toCharArray(), 0, s.length(), ix+20, iy);
+
+        iy += 30;
+        s = "drawBytes(byte data[], int offset, int length, int x, int y)";
+        byte data[] = new byte[s.length()];
+        for (int i = 0; i < data.length; i++) {
+            data[i] = (byte) s.charAt(i);
+        }
+        g.drawLine(ix, iy, ix+10, iy);
+        g.drawBytes(data, 0, data.length, ix+20, iy);
+
+        iy += 50;
+        s = "--- Graphics2D methods: ---";
+        g.drawString(s, ix, iy);
+
+        if (g instanceof Graphics2D) {
+            Graphics2D g2d = (Graphics2D) g;
+            Font f = g2d.getFont();
+            FontRenderContext frc = g2d.getFontRenderContext();
+
+            iy += 30;
+            s = "drawString(String s, float x, float y)";
+            g.drawLine(ix, iy, ix+10, iy);
+            g2d.drawString(s, (float) ix+20, (float) iy);
+
+            iy += 30;
+            s = "drawString(AttributedCharacterIterator iterator, "+
+                           "float x, float y)";
+            g.drawLine(ix, iy, ix+10, iy);
+            g2d.drawString(getIterator(s), (float) ix+20, (float) iy);
+
+            iy += 30;
+            s = "drawGlyphVector(GlyphVector g, float x, float y)";
+            g.drawLine(ix, iy, ix+10, iy);
+            g2d.drawGlyphVector(f.createGlyphVector(frc, s), ix+20, iy);
+        } else {
+            iy += 30;
+            s = "Graphics object does not support Graphics2D methods";
+            g.drawString(s, ix+20, iy);
+        }
+
+        return PAGE_EXISTS;
+    }
+}
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("South", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+     //chop up each into pieces maxSringLength long
+     remainingStr = instructions[ i ];
+     while( remainingStr.length() > 0 )
+      {
+        //if longer than max then chop off first max chars to print
+        if( remainingStr.length() >= maxStringLength )
+         {
+           //Try to chop on a word boundary
+           int posOfSpace = remainingStr.
+          lastIndexOf( ' ', maxStringLength - 1 );
+
+           if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+           printStr = remainingStr.substring( 0, posOfSpace + 1 );
+           remainingStr = remainingStr.substring( posOfSpace + 1 );
+         }
+        //else just print
+        else
+         {
+           printStr = remainingStr;
+           remainingStr = "";
+         }
+
+            instructionsText.append( printStr + "\n" );
+
+      }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/EmptyFill.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4509958
+ * @summary Tests that the empty areas aren't drawn.
+ * @run main EmptyFill
+ */
+
+import java.io.*;
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import javax.print.*;
+import javax.print.attribute.*;
+
+public class EmptyFill implements Printable {
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+
+        if (pageIndex > 0) {
+            return Printable.NO_SUCH_PAGE;
+        }
+
+        g.setColor(Color.black);
+
+        int[] xq = { 75, 125, 75 };
+        int[] yq = { 140, 140, 140};
+
+        g.fillPolygon( xq, yq, 3 );
+
+        return Printable.PAGE_EXISTS;
+    }
+
+    public static void main(String arg[]) throws Exception {
+
+       DocFlavor psFlavor = new DocFlavor("application/postscript",
+                                          "java.io.OutputStream");
+
+       StreamPrintServiceFactory[] spfs =
+              PrinterJob.lookupStreamPrintServices("application/postscript");
+
+       if (spfs.length == 0) {
+           return;
+       }
+       ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
+       StreamPrintService svc = spfs[0].getPrintService(baos);
+
+       PrinterJob pj = PrinterJob.getPrinterJob();
+       if (svc == null) {
+           return;
+       }
+       pj.setPrintService(svc);
+       pj.setPrintable(new EmptyFill());
+       pj.print();
+
+       String outStr = baos.toString("ISO-8859-1");
+       if (outStr.indexOf("\nfill\n") > 0) {
+           throw new Exception("Expected no fills");
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/GlyphPositions.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6186840 6324057
+ * @summary Tests that explicitly positioned glyphs print correctly.
+ * @run main GlyphPositions
+ */
+
+import java.io.*;
+import java.awt.*;
+import java.awt.font.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import javax.print.*;
+import javax.print.attribute.*;
+
+public class GlyphPositions implements Printable {
+
+    static String testString = "0123456789";
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+
+        if (pageIndex > 0) {
+            return Printable.NO_SUCH_PAGE;
+        }
+
+        g.setColor(Color.black);
+        float x = (float)pf.getImageableX() + 20f,
+              y = (float)pf.getImageableY() + 30f;
+
+        Graphics2D g2 = (Graphics2D)g;
+        Font font = new Font("SansSerif", Font.PLAIN, 20);
+        FontRenderContext frc = g2.getFontRenderContext();
+        GlyphVector v = font.createGlyphVector(frc, testString);
+
+        for(int i = 0; i <= v.getNumGlyphs(); i++)
+        {
+            Point2D.Float p = new Point2D.Float();
+            p.x = i * 40f;
+            p.y = 0;
+            v.setGlyphPosition(i, p);
+        }
+
+        g2.drawGlyphVector(v, x, y);
+
+        return Printable.PAGE_EXISTS;
+    }
+
+    public static void main(String arg[]) throws Exception {
+
+       DocFlavor psFlavor = new DocFlavor("application/postscript",
+                                          "java.io.OutputStream");
+
+       StreamPrintServiceFactory[] spfs =
+              PrinterJob.lookupStreamPrintServices("application/postscript");
+
+       if (spfs.length == 0) {
+           return;
+       }
+       ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
+       StreamPrintService svc = spfs[0].getPrintService(baos);
+
+       PrinterJob pj = PrinterJob.getPrinterJob();
+       if (svc == null) {
+           return;
+       }
+       pj.setPrintService(svc);
+       pj.setPrintable(new GlyphPositions());
+       pj.print();
+
+       /* Expect to see that the 10 glyphs are drawn individually which
+        * because of their positions.
+        * This test will need to be updated if the postscript generation
+        * changes.
+        */
+       String outStr = baos.toString("ISO-8859-1");
+       String ls = System.getProperty("line.separator");
+       int indexCount = 0;
+       int index = 0;
+       while (index >= 0) {
+           index = outStr.indexOf("20.0 12 F"+ls, index+1);
+           if (index > 0) indexCount++;
+       }
+       if (indexCount < testString.length()) {
+           throw new Exception("Positions not used");
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/HeadlessPrintingTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4936867
+ * @summary Printing crashes in headless mode.
+ * @run main/othervm HeadlessPrintingTest
+ */
+
+
+import java.awt.*;
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+import java.awt.print.*;
+import java.io.*;
+
+public class HeadlessPrintingTest {
+
+    public static void main(String[] args) {
+        System.setProperty("java.awt.headless", "true");
+        PrinterJob pj = PrinterJob.getPrinterJob();
+        pj.setPrintable(new Printable() {
+            public int print(Graphics g, PageFormat pg, int pageIndex) {
+                Graphics2D g2d = (Graphics2D)g;
+                if (pageIndex > 2) {
+                    return Printable.NO_SUCH_PAGE;
+                } else {
+                    g2d.translate(pg.getImageableX(), pg.getImageableY());
+                    g2d.setColor(Color.RED);
+                    g2d.drawString("page " + pageIndex, 100, 100);
+                    return Printable.PAGE_EXISTS;
+                }
+            }
+        });
+
+        try {
+            HashPrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
+            File f = File.createTempFile("out", "ps");
+            f.deleteOnExit();
+            Destination dest = new Destination(f.toURI());
+            attr.add(dest);
+            pj.print(attr);
+        } catch (Exception e) {
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/InitToBlack.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @bug 4184565
+ * @summary Confirm that the default foreground color on a printer
+ *          graphics object is black so that rendering will appear
+ *          without having to execute setColor first.
+ * @run applet/manual=yesno InitToBlack.html
+ */
+
+import java.awt.*;
+import java.awt.print.*;
+import java.applet.Applet;
+
+public class InitToBlack extends Applet implements Printable {
+
+    public void init() {
+        PrinterJob pjob = PrinterJob.getPrinterJob();
+
+        Book book = new Book();
+        book.append(this, pjob.defaultPage());
+        pjob.setPageable(book);
+
+        try {
+            pjob.print();
+        } catch (PrinterException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+        Graphics2D g2d = (Graphics2D) g;
+        g2d.translate(pf.getImageableX(), pf.getImageableY());
+
+        g.drawString("Test Passes", 200, 200);
+
+        return PAGE_EXISTS;
+    }
+
+    public static void main(String[] args) {
+        new InitToBlack().init();
+        System.exit(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/InvalidPage.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test InvalidPage.java
+ * @bug 4671634 6506286
+ * @summary Invalid page format can crash win32 JRE
+ * @author prr
+ * @run main/manual InvalidPage
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+
+public class InvalidPage extends Frame implements Printable {
+
+  PrinterJob pJob;
+  PageFormat pf;
+
+  public InvalidPage() {
+    super ("Validate Page Test");
+    pJob = PrinterJob.getPrinterJob();
+    pf = pJob.defaultPage();
+    Paper p = pf.getPaper();
+    p.setImageableArea(0,0,p.getWidth(), p.getHeight());
+    pf.setPaper(p);
+    setLayout(new FlowLayout());
+    Panel panel = new Panel();
+    Button printButton = new Button ("Print");
+    printButton.addActionListener(new ActionListener() {
+                public void actionPerformed (ActionEvent e) {
+                    try {
+                         if (pJob.printDialog()) {
+                             pJob.setPrintable(InvalidPage.this, pf);
+                             pJob.print();
+                    }
+                    } catch (PrinterException pe ) {
+                    }
+                }
+    });
+    panel.add (printButton);
+    add(panel);
+
+    addWindowListener (new WindowAdapter() {
+         public void windowClosing (WindowEvent e) {
+            dispose();
+            System.exit (0);
+         }
+
+      });
+      setSize (200, 200);
+      setVisible (true);
+  }
+
+  public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
+
+     if (pageIndex > 1) {
+        return Printable.NO_SUCH_PAGE;
+     }
+
+     Graphics2D g2d = (Graphics2D)graphics;
+
+     g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
+     g2d.drawString("ORIGIN", 30, 30);
+     g2d.drawString("X THIS WAY", 200, 50);
+     g2d.drawString("Y THIS WAY", 60 , 200);
+     g2d.drawRect(0,0,(int)pageFormat.getImageableWidth(),
+                      (int)pageFormat.getImageableHeight());
+     if (pageIndex == 0) {
+        g2d.setColor(Color.black);
+     } else {
+        g2d.setColor(new Color(0,0,0,128));
+     }
+     g2d.drawRect(1,1,(int)pageFormat.getImageableWidth()-2,
+                      (int)pageFormat.getImageableHeight()-2);
+
+     g2d.drawLine(0,0,
+                  (int)pageFormat.getImageableWidth(),
+                  (int)pageFormat.getImageableHeight());
+     g2d.drawLine((int)pageFormat.getImageableWidth(),0,
+                   0,(int)pageFormat.getImageableHeight());
+     return  Printable.PAGE_EXISTS;
+  }
+
+  public static void main( String[] args) {
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "Press the print button, which brings up a print dialog and",
+         "in the dialog select a printer and press the print button",
+         "in the dialog. Repeat for as many printers as you have installed",
+         "On solaris and linux just one printer is sufficient",
+         "Collect the output and examine it, each print job has two pages",
+         "of very similar output, except that the 2nd page of the job may",
+         "appear in a different colour, and the output near the edge of",
+         "the page may be clipped. This is OK. Hold up both pieces of paper",
+         "to the light and confirm that the lines and text (where present)",
+         "are positioned identically on both pages",
+         "The test fails if the JRE crashes, or if the output from the two",
+         "pages of a job is aligned differently"
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+     new InvalidPage();
+  }
+
+}
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/JobName/PrinterJobName.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4205601
+ * @summary setJobName should be used by PrinterJob
+ * @author prr
+ * @run main/manual PrinterJobName
+ */
+
+import java.awt.*;
+import java.awt.print.*;
+
+public class PrinterJobName implements Printable {
+
+
+  static String theName = "Testing the Jobname setting";
+
+  public static void main(String[] args) {
+
+       String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "This test prints a page with a banner/job name of",
+          theName
+       };
+
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+      PrinterJob job = PrinterJob.getPrinterJob();
+      job.setJobName(theName);
+      job.setPrintable(new PrinterJobName());
+      try {
+          job.print();
+          System.out.println("PRINTING DONE.");
+      }
+      catch (Exception exc) {
+          System.out.println("Printer Exception");
+      }
+  }
+
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+      if (pgIndex > 0 ) {
+          return Printable.NO_SUCH_PAGE;
+      }
+
+      double iw = pgFmt.getImageableWidth();
+      double ih = pgFmt.getImageableHeight();
+      Graphics2D g2d = (Graphics2D)g;
+      g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+      g2d.drawString("Name is: "+theName,20,20 );
+      return Printable.PAGE_EXISTS;
+    }
+
+}
+
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/Legal/PrintTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4886069 8023045
+ * @summary Confirm that printer recognizes the Legal selection either by
+ *          prompting the user to put Legal paper or automatically selecting
+ *          the tray containing Legal Paper.  The printout image should not
+ *          be shifted up by about 3".
+ * @run main/manual PrintTest
+ *
+ */
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.border.*;
+
+import java.awt.print.*;
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+import java.io.*;
+
+
+public class PrintTest extends JFrame {
+  private JPanel contentPane;
+  private JMenuBar jMenuBar1 = new JMenuBar();
+  private JMenu jMenuFile = new JMenu();
+  private JMenuItem jMenuItem1 = new JMenuItem();
+  private BorderLayout borderLayout1 = new BorderLayout();
+  private JPanel jPanel1 = new JPanel();
+  private BorderLayout borderLayout2 = new BorderLayout();
+  private JScrollPane jScrollPane1 = new JScrollPane();
+  private JTextArea jTextArea1 = new JTextArea();
+  private Border border1;
+
+  //Construct the frame
+  public PrintTest() {
+    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
+    try {
+      jbInit();
+
+    }
+    catch(Exception e) {
+      e.printStackTrace();
+    }
+  }
+  private void jbInit() throws Exception  {
+    contentPane = (JPanel) this.getContentPane();
+    border1 = BorderFactory.createLineBorder(Color.black,1);
+    contentPane.setLayout(borderLayout1);
+    this.setTitle("Print Test");
+    jMenuFile.setText("File");
+    jMenuItem1.setText("Print");
+    jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(80, java.awt.event.KeyEvent.CTRL_MASK, false));
+    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(ActionEvent e) {
+        jMenuItem1_actionPerformed(e);
+      }
+    });
+    jPanel1.setLayout(borderLayout2);
+    jTextArea1.setBorder(border1);
+    jTextArea1.setText("1. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "2. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "3. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "4. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "5. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "6. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "7. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "8. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "9. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "10. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "11. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "12. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "13. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "14. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "15. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "16. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "17. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "18. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "19. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "20. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "21. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "22. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "23. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "24. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "25. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "26. This is a printer test designed to illustrate a bug in the java printing API.\n\n"+
+                       "27. This is a printer test designed to illustrate a bug in the java printing API.");
+    jMenuFile.add(jMenuItem1);
+    contentPane.add(jPanel1, BorderLayout.CENTER);
+    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
+    jScrollPane1.getViewport().add(jTextArea1, null);
+    jScrollPane1.setPreferredSize(new Dimension(468,648));
+    jTextArea1.setPreferredSize(new Dimension(468,864));
+    jMenuBar1.add(jMenuFile);
+    this.setJMenuBar(jMenuBar1);
+  }
+
+  protected void processWindowEvent(WindowEvent e) {
+    super.processWindowEvent(e);
+    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
+      System.exit(0);
+    }
+  }
+
+  void jMenuItem1_actionPerformed(ActionEvent e) {
+    PrintUtils.printComponent(jTextArea1);
+  }
+
+
+
+
+  public static class PrintUtils implements Printable {
+    private JComponent componentToBePrinted;
+    protected double scale =1.0;
+    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
+
+
+    public static void printComponent(JComponent c) {
+      new PrintUtils(c).print();
+    }
+
+    public PrintUtils(JComponent componentToBePrinted) {
+      this.componentToBePrinted = componentToBePrinted;
+
+    }
+
+    void print() {
+      DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
+          pras.add(MediaSizeName.NA_LEGAL);
+
+      PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor,pras);
+      PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
+      if ((defaultService == null) || (printService.length == 0)) {
+          System.out.println("No default print service found. Test aborted.");
+          return;
+      }
+
+      PrintService service = ServiceUI.printDialog(null,100,100,printService,defaultService,flavor,pras);
+
+      if(service != null) {
+        DocPrintJob job = service.createPrintJob();
+        DocAttributeSet das = new HashDocAttributeSet();
+
+        Doc doc = new SimpleDoc(this,flavor,das);
+
+        try {
+          job.print(doc,pras);
+
+        } catch(PrintException pe) {
+          pe.printStackTrace();
+        }
+      }
+
+    }
+
+
+    public int print(Graphics g, PageFormat pageFormat, int pageIndex)
+    {
+
+      double h=componentToBePrinted.getHeight();
+      double pageHeight=pageFormat.getImageableHeight();
+
+      if (pageIndex * pageHeight > h * scale) {
+        return(NO_SUCH_PAGE);
+      } else {
+
+        Graphics2D g2d = (Graphics2D)g;
+
+        //move past unprintable area
+        double xOffset=pageFormat.getImageableX();
+        double yOffset=pageFormat.getImageableY();
+        g2d.translate(xOffset,yOffset);
+
+
+        //move to correct page taking into account the scaling
+        double newx=0;
+        double newy=pageHeight*(-pageIndex);
+        g2d.translate(newx / 1.0,newy / 1.0 );
+
+        //print
+
+        componentToBePrinted.print(g2d);
+        return(PAGE_EXISTS);
+        }
+    }
+
+    public static void disableDoubleBuffering(Component c) {
+      RepaintManager currentManager = RepaintManager.currentManager(c);
+      currentManager.setDoubleBufferingEnabled(false);
+    }
+
+    /** Re-enables double buffering globally. */
+
+    public static void enableDoubleBuffering(Component c) {
+      RepaintManager currentManager = RepaintManager.currentManager(c);
+      currentManager.setDoubleBufferingEnabled(true);
+    }
+}
+
+  public static void main(String[] args) {
+    try {
+      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+    }
+    catch(Exception e) {
+      e.printStackTrace();
+    }
+    PrintTest frame = new PrintTest();
+    frame.pack();
+
+    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+    Dimension frameSize = frame.getSize();
+    if (frameSize.height > screenSize.height) {
+      frameSize.height = screenSize.height;
+    }
+    if (frameSize.width > screenSize.width) {
+      frameSize.width = screenSize.width;
+    }
+    frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
+    frame.setVisible(true);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/MultiThread/MultiThreadTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4922036
+ * @summary Confirm that no Exception is thrown and 2 identical output is produced.
+ * @run main/manual MultiThreadTest
+ */
+import java.io.*;
+import javax.print.*;
+
+
+public class MultiThreadTest extends Thread {
+
+    private PrintService service = PrintServiceLookup.lookupDefaultPrintService();
+    private Doc doc = null;
+
+    public MultiThreadTest(Doc docObject) {
+        this.doc = docObject;
+    }
+
+    public void print() {
+        try {
+            DocPrintJob job = null;
+
+            job = this.service.createPrintJob();
+            if (job == null) {
+                System.out.println("Fail: DocPrintJob is null...");
+                return;
+            }
+            System.out.println("About to print image...");
+
+            job.print(this.doc, null);
+            System.out.println("Image printed.");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void run() {
+        this.print();
+    }
+
+    public static void main(String args[]) {
+        if (args.length <= 0) {
+            System.out.println("Usage: java MultiThreadTest <img file>");
+            return;
+        }
+        Object printData = null;
+
+        try {
+            File file = new File(args[0]);
+
+            printData = new byte[(int) file.length()];
+            FileInputStream in = new FileInputStream(file);
+
+            in.read((byte[]) printData);
+            in.close();
+        } catch (FileNotFoundException fe) {
+            System.out.println("ByteDoc: FileNotFoundException: "
+                    + fe.toString());
+
+        } catch (IOException ie) {
+            System.out.println("ByteDoc: IOException: " + ie.toString());
+        }
+        Doc doc1 = new ByteDoc(printData, DocFlavor.BYTE_ARRAY.GIF);
+        Doc doc2 = new ByteDoc(printData, DocFlavor.BYTE_ARRAY.GIF);
+
+        Thread thread1 = new MultiThreadTest(doc1);
+        Thread thread2 = new MultiThreadTest(doc2);
+
+        thread1.start();
+        thread2.start();
+    }
+}
+
+
+class ByteDoc implements Doc {
+
+    protected DocFlavor flavor = null;
+    protected Object printData = null;
+    protected InputStream instream = null;
+    protected FileReader reader = null;
+
+    // constructor takes the resource file and the document flavor.
+    public ByteDoc(Object printdata, DocFlavor docFlavor) {
+        this.printData = printdata;
+        this.flavor = docFlavor;
+    }
+
+    public javax.print.attribute.DocAttributeSet getAttributes() {
+        return null;
+    }
+
+    public DocFlavor getDocFlavor() {
+        return this.flavor;
+    }
+
+    public Object getPrintData() {
+        return this.printData;
+    }
+
+    public Reader getReaderForText() {
+        // Document says that if MIME type is non-text and representation class is input stream
+        // then return null;
+        return null;
+    }
+
+    public InputStream getStreamForBytes() {
+        synchronized (this) {
+            if ((this.instream == null) && (this.printData instanceof byte[])) {
+                // its a byte array so create a ByteArrayInputStream.
+                System.out.println("creating ByteArrayInputStream...");
+                this.instream = new ByteArrayInputStream((byte[]) printData);
+            }
+        }
+        return this.instream;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/NullGetName.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 6397684
+  @summary PASS if no VM crash.
+  @run main NullGetName
+*/
+
+
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.event.*;
+import java.awt.print.*;
+
+
+public class NullGetName {
+
+    public static void main(String[] args) {
+        PrinterJob printerJob = PrinterJob.getPrinterJob();
+                try {
+                printerJob.setPrintService(new ImagePrintService());
+                } catch (PrinterException e) {
+                }
+    }
+}
+
+
+class ImagePrintService implements PrintService {
+
+
+    public Class[] getSupportedAttributeCategories() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isAttributeCategorySupported(Class category) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public String getName() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public DocFlavor[] getSupportedDocFlavors() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+    public boolean isDocFlavorSupported(DocFlavor flavor) {
+        if(DocFlavor.SERVICE_FORMATTED.PAGEABLE.equals(flavor))
+            return true;
+        if(DocFlavor.SERVICE_FORMATTED.PRINTABLE.equals(flavor))
+            return true;
+        return false;
+    }
+
+    public DocPrintJob createPrintJob() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ServiceUIFactory getServiceUIFactory() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+    public PrintServiceAttributeSet getAttributes() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void addPrintServiceAttributeListener(
+            PrintServiceAttributeListener listener) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void removePrintServiceAttributeListener(
+            PrintServiceAttributeListener listener) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public Object getDefaultAttributeValue(Class category) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+        public <T extends PrintServiceAttribute> T
+        getAttribute(Class<T> category) {
+            // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isAttributeValueSupported(Attribute attrval,
+            DocFlavor flavor, AttributeSet attributes) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
+            AttributeSet attributes) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object getSupportedAttributeValues(Class category, DocFlavor flavor,
+            AttributeSet attributes) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/NumCopies.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4258003
+ * @summary Checks the right number of copies are printed
+ * @author prr
+ * @run main/manual NumCopies
+ */
+
+import java.awt.*;
+import java.awt.print.*;
+
+public class NumCopies implements Printable {
+
+
+  public static void main(String[] args) {
+
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "This test should print a total of four pages which are two",
+         " copies of each of two pages which consist of the text :-",
+         "'This is page number N', where N is 0 and 1.",
+         "The pages should be uncollated."
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+    PrinterJob job = PrinterJob.getPrinterJob();
+    job.setCopies(2);
+    job.setPrintable(new NumCopies());
+    try {
+        job.print();
+    }
+    catch (Exception exc) {
+        System.out.println("Printer Exception");
+    }
+  }
+
+  public int print(Graphics g, PageFormat pf, int pageIndex)
+                   throws PrinterException {
+
+    if (pageIndex > 1) {
+         return NO_SUCH_PAGE;
+    }
+    g.translate((int)pf.getImageableX(), (int)pf.getImageableY());
+    g.setColor(Color.black);
+    g.drawString("This is page number " + Integer.toString(pageIndex), 50, 50);
+    return PAGE_EXISTS ;
+   }
+
+}
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PSQuestionMark.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6217355 6324057
+ * @summary Tests that '?' prints with postscript fonts
+ * @run main PSQuestionMark
+ */
+
+import java.io.*;
+import java.awt.*;
+import java.awt.print.*;
+import javax.print.*;
+import javax.print.attribute.*;
+
+public class PSQuestionMark implements Printable {
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+
+        if (pageIndex > 0) {
+            return Printable.NO_SUCH_PAGE;
+        }
+
+        g.setColor(Color.black);
+        g.setFont(new Font("Serif", Font.PLAIN, 12));
+        g.drawString("?", 100, 150);
+
+        return Printable.PAGE_EXISTS;
+    }
+
+    public static void main(String arg[]) throws Exception {
+
+       DocFlavor psFlavor = new DocFlavor("application/postscript",
+                                          "java.io.OutputStream");
+
+       StreamPrintServiceFactory[] spfs =
+              PrinterJob.lookupStreamPrintServices("application/postscript");
+
+       if (spfs.length == 0) {
+           return;
+       }
+       ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
+       //FileOutputStream baos = new FileOutputStream("q.ps");
+       StreamPrintService svc = spfs[0].getPrintService(baos);
+
+       PrinterJob pj = PrinterJob.getPrinterJob();
+       if (svc == null) {
+           return;
+       }
+       pj.setPrintService(svc);
+       pj.setPrintable(new PSQuestionMark());
+       pj.print();
+       //baos.close();
+
+       /* Expect to see the PS we generate for setting 12 pt Times Roman
+        * and the hex value of '?'
+        * "12.0 12 F"
+        * "<3f> 6.72 100.0 150.0 S"
+        * This test will need to be updated if the postscript generation
+        * changes.
+        */
+       String outStr = baos.toString("ISO-8859-1");
+       String ls = System.getProperty("line.separator");
+       if (outStr.indexOf("12.0 32 F"+ls+"<3f>") < 0) {
+           throw new Exception("PS font not used");
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PSWindingRule.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4423489
+ * @summary Tests that the postscript renders using the appropriate
+ * winding rule. Runs as "main" as can't run in sandbox.
+ * @run main PSWindingRule
+ */
+
+import java.io.*;
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import javax.print.*;
+import javax.print.attribute.*;
+
+public class PSWindingRule implements Printable {
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+
+        if (pageIndex > 0) {
+            return Printable.NO_SUCH_PAGE;
+        }
+
+        Graphics2D g2 = (Graphics2D)g;
+
+        GeneralPath path1 = new GeneralPath(PathIterator.WIND_EVEN_ODD);
+        GeneralPath path2 = new GeneralPath(PathIterator.WIND_EVEN_ODD);
+        GeneralPath path3 = new GeneralPath(PathIterator.WIND_EVEN_ODD);
+        path1.append(new Ellipse2D.Double(100, 100, 100, 100), false);
+        path1.append(new Ellipse2D.Double(120, 120, 60, 60), false);
+        path1.append(new Ellipse2D.Double(140, 140, 20, 20), false);
+
+        path2.append(new Ellipse2D.Double(150, 100, 100, 100), false);
+        path2.append(new Ellipse2D.Double(170, 120, 60, 60), false);
+        path2.append(new Ellipse2D.Double(190, 140, 20, 20), false);
+
+        path3.append(new Ellipse2D.Double(-50, -50, 100, 100), false);
+        path3.append(new Ellipse2D.Double(-30, -30, 60, 60), false);
+        path3.append(new Ellipse2D.Double(-10, -10, 20, 20), false);
+
+        Rectangle clip = new Rectangle();
+        g2.getClipBounds(clip);
+
+        g2.setColor(Color.white);
+        g2.fillRect(clip.x, clip.y, clip.width, clip.height);
+
+        g2.setColor(Color.red);
+        g2.fill(path1);
+
+        g2.setColor(Color.black);
+        g2.fill(path2);
+
+        g2.translate(150, 400);
+        g2.setColor(Color.red);
+        g2.fill(path3);
+
+        g2.translate(50, 0);
+        g2.setColor(Color.black);
+        g2.fill(path3);
+
+        return Printable.PAGE_EXISTS;
+    }
+
+    public static void main(String arg[]) throws Exception {
+
+       DocFlavor psFlavor = new DocFlavor("application/postscript",
+                                          "java.io.OutputStream");
+
+       StreamPrintServiceFactory[] spfs =
+              PrinterJob.lookupStreamPrintServices("application/postscript");
+
+       if (spfs.length == 0) {
+           return;
+       }
+       ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
+       StreamPrintService svc = spfs[0].getPrintService(baos);
+
+       PrinterJob pj = PrinterJob.getPrinterJob();
+       if (svc == null) {
+           return;
+       }
+       pj.setPrintService(svc);
+       pj.setPrintable(new PSWindingRule());
+       pj.print();
+
+       String outStr = baos.toString("ISO-8859-1");
+       int eofillCnt = 0;
+       int index = 0;
+       String ls = System.getProperty ("line.separator");
+
+       while (index >= 0) {
+           index = outStr.indexOf(ls+"EF"+ls, index+1);
+           if (index >=0 ) {
+               eofillCnt++;
+           }
+       }
+       if (eofillCnt != 4) {
+           throw new Exception("Expected 4 eofill's, got: " + eofillCnt);
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PageDialogTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 6302514
+   @run main/manual=yesno PageDialogTest
+   @summary A toolkit modal dialog should not be blocked by Page/Print dialog.
+*/
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+
+import javax.swing.*;
+
+public class PageDialogTest {
+
+    public static void main(String[] args) {
+        String[] instructions =
+        {
+            "The test shows a Toolkit modal dialog. ",
+            "Click the 'Open' button. It opens a page dialog.",
+            "The test fails if the page dialog blocks the toolkit",
+            "modal dialog, otherwise it passes."
+        };
+
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        Dialog td = new Dialog((Frame) null, "Toolkit modal dialog",
+                               Dialog.ModalityType.TOOLKIT_MODAL);
+        td.setLayout(new FlowLayout());
+        td.add(new Button("Dummy"));
+        Button tdb = new Button("Open");
+        tdb.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                PrinterJob.getPrinterJob().pageDialog(new PageFormat());
+            }
+        });
+        td.add(tdb);
+        td.setSize(250, 150);
+        td.setVisible(true);
+    }
+}
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PageDlgPrnButton.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4956397
+ * @run main/manual PageDlgPrnButton
+ */
+
+import java.awt.print.PrinterJob;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.* ;
+
+public class PageDlgPrnButton implements Printable
+{
+    public static void main ( String args[] ) {
+
+        String[] instructions =
+           {"For non-windows OS, this test PASSes.",
+            "You must have at least 2 printers available to perform this test.",
+            "This test brings up a native Windows page dialog.",
+            "Click on the Printer... button and change the selected printer. ",
+            "Test passes if the printout comes from the new selected printer.",
+         };
+
+         Sysout.createDialog( );
+         Sysout.printInstructions( instructions );
+
+        PageDlgPrnButton pdpb = new PageDlgPrnButton() ;
+    }
+
+    public PageDlgPrnButton()
+    {
+        try
+        {
+            pageDialogExample();
+        }
+        catch(Exception e)
+        {e.printStackTrace(System.err);}
+    }
+
+
+    // This example just displays the page dialog - you cannot change
+    // the printer (press the "Printer..." button and choose one if you like).
+    public void pageDialogExample() throws PrinterException
+    {
+        PrinterJob job = PrinterJob.getPrinterJob();
+        PageFormat originalPageFormat = job.defaultPage();
+        PageFormat pageFormat = job.pageDialog(originalPageFormat);
+
+        if(originalPageFormat == pageFormat) return;
+
+        job.setPrintable(this,pageFormat);
+        job.print();
+    }
+
+
+
+    public int print(Graphics g, PageFormat pageFormat, int pageIndex)
+    {
+        final int boxWidth = 100;
+        final int boxHeight = 100;
+        final Rectangle rect = new Rectangle(0,0,boxWidth,boxHeight);
+        final double pageH = pageFormat.getImageableHeight();
+        final double pageW = pageFormat.getImageableWidth();
+
+        if (pageIndex > 0) return (NO_SUCH_PAGE);
+
+        final Graphics2D g2d = (Graphics2D)g;
+
+        // Move the (x,y) origin to account for the left-hand and top margins
+        g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
+
+        // Draw the page bounding box
+        g2d.drawRect(0,0,(int)pageW,(int)pageH);
+
+        // Select the smaller scaling factor so that the figure
+        // fits on the page in both dimensions
+        final double scale = Math.min( (pageW/boxWidth), (pageH/boxHeight) );
+
+        if(scale < 1.0) g2d.scale(scale, scale);
+
+        // Paint the scaled component on the printer
+        g2d.fillRect(rect.x, rect.y, rect.width, rect.height);
+
+        return(PAGE_EXISTS);
+    }
+}
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PaintText.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6498340
+ * @summary No exception when printing text with a paint.
+ * @run main PaintText
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.text.*;
+import java.util.*;
+import java.awt.font.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import javax.swing.*;
+
+public class PaintText extends Component implements Printable {
+
+    static int preferredSize;
+    static int NUMTABS = 6;
+    int tabNumber;
+
+    public static void main(String args[]) {
+
+        PrinterJob pjob = PrinterJob.getPrinterJob();
+        if (pjob.getPrintService() == null) {
+            System.out.println("No printers: cannot continue");
+            return;
+        }
+
+        PageFormat pf = pjob.defaultPage();
+        preferredSize = (int)pf.getImageableWidth();
+
+        Book book = new Book();
+
+        JTabbedPane p = new JTabbedPane();
+
+        for (int id=1; id <= NUMTABS; id++) {
+            String name = "Tab " + new Integer(id);
+            PaintText ptt = new PaintText(id);
+            p.add(name, ptt);
+            book.append(ptt, pf);
+        }
+        pjob.setPageable(book);
+
+        JFrame f = new JFrame();
+        f.add(BorderLayout.CENTER, p);
+        f.addWindowListener(new WindowAdapter() {
+            public void windowClosing(WindowEvent e) {System.exit(0);}
+        });
+        f.pack();
+        f.show();
+
+        /* Non-jtreg execution will display the dialog */
+        if (System.getProperty("test.java") == null) {
+             if (!pjob.printDialog()) {
+                return;
+            }
+        }
+        try {
+            pjob.print();
+        } catch (PrinterException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    public PaintText(int id) {
+        tabNumber = id;
+    }
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+        System.out.println(""+pageIndex);
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.translate(pf.getImageableX(),  pf.getImageableY());
+        g.drawString("ID="+tabNumber,100,20);
+        g.translate(0, 25);
+        paint(g);
+        return PAGE_EXISTS;
+    }
+
+    public Dimension getMinimumSize() {
+        return getPreferredSize();
+    }
+
+    public Dimension getPreferredSize() {
+        return new Dimension(preferredSize, preferredSize);
+    }
+
+    public void paint(Graphics g) {
+
+        /* fill with white before any transformation is applied */
+        g.setColor(Color.white);
+        g.fillRect(0, 0, getSize().width, getSize().height);
+
+        Graphics2D g2d = (Graphics2D)g;
+
+        Font f = new Font("Lucida Sans", Font.PLAIN, 40);
+        Color c = new Color(0,0,255,96);
+        Paint p = new GradientPaint(0f, 0f, Color.green,
+                                    10f, 10f, Color.red,
+                                    true);
+        String s = "Sample Text To Paint";
+        float x = 20, y= 50;
+
+        switch (tabNumber) {
+        case 1:
+            g2d.setFont(f);
+            g2d.setColor(c);
+            g2d.drawString(s, x, y);
+            break;
+
+        case 2:
+            g2d.setFont(f);
+            g2d.setPaint(p);
+            g2d.drawString(s, x, y);
+            break;
+
+        case 3:
+            AttributedString as = new AttributedString(s);
+            as.addAttribute(TextAttribute.FONT, f);
+            as.addAttribute(TextAttribute.FOREGROUND, c);
+            g2d.drawString(as.getIterator(), x, y);
+            break;
+
+        case 4:
+            as = new AttributedString(s);
+            as.addAttribute(TextAttribute.FONT, f);
+            as.addAttribute(TextAttribute.FOREGROUND, p);
+            g2d.drawString(as.getIterator(), x, y);
+            break;
+
+        case 5:
+            as = new AttributedString(s);
+            as.addAttribute(TextAttribute.FONT, f);
+            as.addAttribute(TextAttribute.FOREGROUND, c);
+            FontRenderContext frc = g2d.getFontRenderContext();
+            TextLayout tl = new TextLayout(as.getIterator(), frc);
+            tl.draw(g2d, x, y);
+            break;
+
+        case 6:
+            as = new AttributedString(s);
+            as.addAttribute(TextAttribute.FONT, f);
+            as.addAttribute(TextAttribute.FOREGROUND, p);
+            frc = g2d.getFontRenderContext();
+            tl = new TextLayout(as.getIterator(), frc);
+            tl.draw(g2d, x, y);
+            break;
+
+        default:
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintAllFonts.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ *
+ * @bug 4884389 7183516
+ * @summary Font specified with face name loses style on printing
+ * @run main/manual PrintRotatedText
+ */
+
+import java.awt.*;
+import java.awt.print.*;
+import java.awt.GraphicsEnvironment;
+
+public class PrintAllFonts implements Printable {
+
+    static Font[] allFonts;
+    int fontNum = 0;
+    int startNum = 0;
+    int lineHeight = 18;
+    boolean done = false;
+    int thisPage = 0;
+
+
+    public static void main(String[] args) throws Exception {
+
+        String[] instructions =
+        {
+            "You must have a printer available to perform this test and should use Win 98.",
+            "This bug is system dependent and is not always reproducible.",
+            " ",
+            "A passing test will have all text printed with correct font style.",
+        };
+
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        GraphicsEnvironment ge =
+            GraphicsEnvironment.getLocalGraphicsEnvironment();
+        allFonts = ge.getAllFonts();
+
+        PrinterJob pj = PrinterJob.getPrinterJob();
+        pj.setPrintable(new PrintAllFonts());
+        if (pj.printDialog()) {
+           pj.print();
+        }
+    }
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+
+        if (fontNum >= allFonts.length && pageIndex > thisPage) {
+            return NO_SUCH_PAGE;
+        }
+        if (pageIndex > thisPage) {
+            startNum = fontNum;
+            thisPage = pageIndex;
+        } else {
+            fontNum = startNum;
+        }
+        g.setColor(Color.black);
+
+        int hgt = (int)pf.getImageableHeight();
+        int fontsPerPage = hgt/lineHeight;
+        int x = (int)pf.getImageableX()+10;
+        int y = (int)pf.getImageableY()+lineHeight;
+
+        for (int n = 0; n < fontsPerPage; n++) {
+            Font f = allFonts[fontNum].deriveFont(Font.PLAIN, 16);
+            g.setFont(f);
+            g.drawString(f.getFontName(), x, y);
+            y+= lineHeight;
+            fontNum++;
+            if (fontNum >= allFonts.length) {
+                break;
+            }
+        }
+        return PAGE_EXISTS;
+    }
+}
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintBadImage.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4398853
+ * @summary Printing shouldn't hang on bad images
+ * @author prr
+ * @run main/manual PrintBadImage
+ */
+
+import java.awt.*;
+import java.awt.print.*;
+
+
+public class PrintBadImage implements Printable {
+
+    public static void main(String args[]) {
+
+      PrintBadImage pbi = new PrintBadImage();
+      PrinterJob pj = PrinterJob.getPrinterJob();
+      if (pj != null) {
+          pj.setPrintable(pbi);
+          try {
+               pj.print();
+         } catch (PrinterException pe) {
+         } finally {
+            System.err.println("PRINT RETURNED");
+         }
+      }
+    }
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+      if (pgIndex > 0)
+         return Printable.NO_SUCH_PAGE;
+
+      Graphics2D g2d = (Graphics2D)g;
+      g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+      Image imgJava = Toolkit.getDefaultToolkit().getImage("img.bad");
+      g2d.drawImage(imgJava, 0, 0, null);
+
+      return Printable.PAGE_EXISTS;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintCompoundString.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4396835
+ * @summary Compound font string not printing.
+ * @author prr
+ * @run main/manual PrintCompoundString
+ */
+
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import java.text.*;
+
+public class PrintCompoundString extends Frame implements ActionListener {
+
+ private TextCanvas c;
+
+ public static void main(String args[]) {
+
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "This test should print a page which contains the same",
+         "text message as in the test window on the screen",
+         "You should also monitor the command line to see if any exceptions",
+         "were thrown",
+         "If an exception is thrown, or the page doesn't print properly",
+         "then the test fails",
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+    PrintCompoundString f = new PrintCompoundString();
+    f.show();
+ }
+
+ public PrintCompoundString() {
+    super("JDK 1.2 drawString Printing");
+
+    c = new TextCanvas();
+    add("Center", c);
+
+    Button printButton = new Button("Print");
+    printButton.addActionListener(this);
+    add("South", printButton);
+
+    addWindowListener(new WindowAdapter() {
+       public void windowClosing(WindowEvent e) {
+             System.exit(0);
+            }
+    });
+
+    pack();
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+   PrinterJob pj = PrinterJob.getPrinterJob();
+
+   if (pj != null && pj.printDialog()) {
+
+       pj.setPrintable(c);
+       try {
+            pj.print();
+      } catch (PrinterException pe) {
+      } finally {
+         System.err.println("PRINT RETURNED");
+      }
+   }
+ }
+
+ class TextCanvas extends Panel implements Printable {
+
+    String nullStr = null;
+    String emptyStr = new String();
+    AttributedString nullAttStr = null;
+    AttributedString emptyAttStr = new AttributedString(emptyStr);
+    AttributedCharacterIterator nullIterator = null;
+    AttributedCharacterIterator emptyIterator = emptyAttStr.getIterator();
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+
+      if (pgIndex > 0)
+         return Printable.NO_SUCH_PAGE;
+
+      Graphics2D g2d = (Graphics2D)g;
+      g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+
+      paint(g);
+
+      return Printable.PAGE_EXISTS;
+    }
+
+    public void paint(Graphics g1) {
+        Graphics2D g = (Graphics2D)g1;
+
+          String str = "Test string compound printing \u2203\u2200\u2211";
+          g.drawString(str, 20, 40);
+
+    }
+
+     public Dimension getPreferredSize() {
+        return new Dimension(450, 250);
+    }
+ }
+
+}
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintDialog.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,390 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test PrintDialog.java
+  @bug 4257903
+  @summary  Confirm that the you see the print dialog.
+  @author prr: area=PrinterJob
+  @run main/manual PrintDialog
+*/
+
+
+//*** global search and replace PrintDialog with name of the test ***
+
+/**
+ * PrintDialog.java
+ *
+ * summary:
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+
+// This test is a "main" test as applets would need Runtime permission
+// "queuePrintJob".
+
+public class PrintDialog {
+
+
+   private static void init()
+    {
+      //*** Create instructions for the user here ***
+
+      String[] instructions =
+       {
+         "Visual inspection of the dialog is needed. It should be",
+         "a Printer Job Setup Dialog",
+         "You may cancel or OK the dialog."
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+      PrinterJob pjob = PrinterJob.getPrinterJob();
+      pjob.printDialog();
+
+    }//End  init()
+
+
+   /*****************************************************
+     Standard Test Machinery Section
+      DO NOT modify anything in this section -- it's a
+      standard chunk of code which has all of the
+      synchronisation necessary for the test harness.
+      By keeping it the same in all tests, it is easier
+      to read and understand someone else's test, as
+      well as insuring that all tests behave correctly
+      with the test harness.
+     There is a section following this for test-defined
+      classes
+   ******************************************************/
+   private static boolean theTestPassed = false;
+   private static boolean testGeneratedInterrupt = false;
+   private static String failureMessage = "";
+
+   private static Thread mainThread = null;
+
+   private static int sleepTime = 300000;
+
+   public static void main( String args[] ) throws InterruptedException
+    {
+      mainThread = Thread.currentThread();
+      try
+       {
+         init();
+       }
+      catch( TestPassedException e )
+       {
+         //The test passed, so just return from main and harness will
+         // interepret this return as a pass
+         return;
+       }
+      //At this point, neither test passed nor test failed has been
+      // called -- either would have thrown an exception and ended the
+      // test, so we know we have multiple threads.
+
+      //Test involves other threads, so sleep and wait for them to
+      // called pass() or fail()
+      try
+       {
+         Thread.sleep( sleepTime );
+         //Timed out, so fail the test
+         throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+       }
+      catch (InterruptedException e)
+       {
+         if( ! testGeneratedInterrupt ) throw e;
+
+         //reset flag in case hit this code more than once for some reason (just safety)
+         testGeneratedInterrupt = false;
+         if ( theTestPassed == false )
+          {
+            throw new RuntimeException( failureMessage );
+          }
+       }
+
+    }//main
+
+   public static synchronized void setTimeoutTo( int seconds )
+    {
+      sleepTime = seconds * 1000;
+    }
+
+   public static synchronized void pass()
+    {
+      Sysout.println( "The test passed." );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //first check if this is executing in main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //Still in the main thread, so set the flag just for kicks,
+         // and throw a test passed exception which will be caught
+         // and end the test.
+         theTestPassed = true;
+         throw new TestPassedException();
+       }
+      //pass was called from a different thread, so set the flag and interrupt
+      // the main thead.
+      theTestPassed = true;
+      testGeneratedInterrupt = true;
+      mainThread.interrupt();
+    }//pass()
+
+   public static synchronized void fail()
+    {
+      //test writer didn't specify why test failed, so give generic
+      fail( "it just plain failed! :-)" );
+    }
+
+   public static synchronized void fail( String whyFailed )
+    {
+      Sysout.println( "The test failed: " + whyFailed );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //check if this called from main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //If main thread, fail now 'cause not sleeping
+         throw new RuntimeException( whyFailed );
+       }
+      theTestPassed = false;
+      testGeneratedInterrupt = true;
+      failureMessage = whyFailed;
+      mainThread.interrupt();
+    }//fail()
+
+ }// class PrintDialog
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+ {
+ }
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// make listeners in a class defined here, and instantiate them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+   static int newVar = 0;
+
+   public void eventDispatched(AWTEvent e)
+    {
+      //Counting events to see if we get enough
+      eventCount++;
+
+      if( eventCount == 20 )
+       {
+         //got enough events, so pass
+
+         PrintDialog.pass();
+       }
+      else if( tries == 20 )
+       {
+         //tried too many times without getting enough events so fail
+
+         PrintDialog.fail();
+       }
+
+    }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog implements ActionListener
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+   Panel  buttonP = new Panel();
+   Button passB = new Button( "pass" );
+   Button failB = new Button( "fail" );
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      passB = new Button( "pass" );
+      passB.setActionCommand( "pass" );
+      passB.addActionListener( this );
+      buttonP.add( "East", passB );
+
+      failB = new Button( "fail" );
+      failB.setActionCommand( "fail" );
+      failB.addActionListener( this );
+      buttonP.add( "West", failB );
+
+      add( "South", buttonP );
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+   //catch presses of the passed and failed buttons.
+   //simply call the standard pass() or fail() static methods of
+   //PrintDialog
+   public void actionPerformed( ActionEvent e )
+    {
+      if( e.getActionCommand() == "pass" )
+       {
+         PrintDialog.pass();
+       }
+      else
+       {
+         PrintDialog.fail();
+       }
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintDialogCancel.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,394 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 4398231
+  @summary  Confirm that the print dialog returns false when cancelled.
+  @author prr: area=PrinterJob
+  @run main/manual PrintDialogCancel
+*/
+
+
+//*** global search and replace PrintDialogCancel with name of the test ***
+
+/**
+ * PrintDialogCancel.java
+ *
+ * summary:
+ */
+
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+
+// This test is a "main" test as applets would need Runtime permission
+// "queuePrintJob".
+
+public class PrintDialogCancel {
+
+
+   private static void init()
+    {
+      //*** Create instructions for the user here ***
+
+      String[] instructions =
+       {
+         "Visual inspection of the dialog is needed. It should be",
+         "a Printer Job Setup Dialog",
+         "Do nothing except Cancel",
+         "You must NOT press OK",
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+      PrinterJob pjob = PrinterJob.getPrinterJob();
+      boolean rv = pjob.printDialog(new HashPrintRequestAttributeSet());
+      if (rv) {
+          throw new RuntimeException("User pressed cancel, but true returned");
+      }
+    }//End  init()
+
+
+   /*****************************************************
+     Standard Test Machinery Section
+      DO NOT modify anything in this section -- it's a
+      standard chunk of code which has all of the
+      synchronisation necessary for the test harness.
+      By keeping it the same in all tests, it is easier
+      to read and understand someone else's test, as
+      well as insuring that all tests behave correctly
+      with the test harness.
+     There is a section following this for test-defined
+      classes
+   ******************************************************/
+   private static boolean theTestPassed = false;
+   private static boolean testGeneratedInterrupt = false;
+   private static String failureMessage = "";
+
+   private static Thread mainThread = null;
+
+   private static int sleepTime = 300000;
+
+   public static void main( String args[] ) throws InterruptedException
+    {
+      mainThread = Thread.currentThread();
+      try
+       {
+         init();
+       }
+      catch( TestPassedException e )
+       {
+         //The test passed, so just return from main and harness will
+         // interepret this return as a pass
+         return;
+       }
+      //At this point, neither test passed nor test failed has been
+      // called -- either would have thrown an exception and ended the
+      // test, so we know we have multiple threads.
+
+      //Test involves other threads, so sleep and wait for them to
+      // called pass() or fail()
+      try
+       {
+         Thread.sleep( sleepTime );
+         //Timed out, so fail the test
+         throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+       }
+      catch (InterruptedException e)
+       {
+         if( ! testGeneratedInterrupt ) throw e;
+
+         //reset flag in case hit this code more than once for some reason (just safety)
+         testGeneratedInterrupt = false;
+         if ( theTestPassed == false )
+          {
+            throw new RuntimeException( failureMessage );
+          }
+       }
+
+    }//main
+
+   public static synchronized void setTimeoutTo( int seconds )
+    {
+      sleepTime = seconds * 1000;
+    }
+
+   public static synchronized void pass()
+    {
+      Sysout.println( "The test passed." );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //first check if this is executing in main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //Still in the main thread, so set the flag just for kicks,
+         // and throw a test passed exception which will be caught
+         // and end the test.
+         theTestPassed = true;
+         throw new TestPassedException();
+       }
+      //pass was called from a different thread, so set the flag and interrupt
+      // the main thead.
+      theTestPassed = true;
+      testGeneratedInterrupt = true;
+      mainThread.interrupt();
+    }//pass()
+
+   public static synchronized void fail()
+    {
+      //test writer didn't specify why test failed, so give generic
+      fail( "it just plain failed! :-)" );
+    }
+
+   public static synchronized void fail( String whyFailed )
+    {
+      Sysout.println( "The test failed: " + whyFailed );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //check if this called from main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //If main thread, fail now 'cause not sleeping
+         throw new RuntimeException( whyFailed );
+       }
+      theTestPassed = false;
+      testGeneratedInterrupt = true;
+      failureMessage = whyFailed;
+      mainThread.interrupt();
+    }//fail()
+
+ }// class PrintDialogCancel
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+ {
+ }
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// make listeners in a class defined here, and instantiate them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+   static int newVar = 0;
+
+   public void eventDispatched(AWTEvent e)
+    {
+      //Counting events to see if we get enough
+      eventCount++;
+
+      if( eventCount == 20 )
+       {
+         //got enough events, so pass
+
+         PrintDialogCancel.pass();
+       }
+      else if( tries == 20 )
+       {
+         //tried too many times without getting enough events so fail
+
+         PrintDialogCancel.fail();
+       }
+
+    }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog implements ActionListener
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+   Panel  buttonP = new Panel();
+   Button passB = new Button( "pass" );
+   Button failB = new Button( "fail" );
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      passB = new Button( "pass" );
+      passB.setActionCommand( "pass" );
+      passB.addActionListener( this );
+      buttonP.add( "East", passB );
+
+      failB = new Button( "fail" );
+      failB.setActionCommand( "fail" );
+      failB.addActionListener( this );
+      buttonP.add( "West", failB );
+
+      add( "South", buttonP );
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+   //catch presses of the passed and failed buttons.
+   //simply call the standard pass() or fail() static methods of
+   //PrintDialogCancel
+   public void actionPerformed( ActionEvent e )
+    {
+      if( e.getActionCommand() == "pass" )
+       {
+         PrintDialogCancel.pass();
+       }
+      else
+       {
+         PrintDialogCancel.fail();
+       }
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintFontStyle.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.print.*;
+import java.awt.GraphicsEnvironment;
+
+public class PrintFontStyle {
+    public static void main(String[] args) {
+
+        String[] instructions =
+        {
+            "You must have a printer available to perform this test and should use Win 98.",
+            "This bug is system dependent and is not always reproducible.",
+            " ",
+            "A passing test will have all text printed with correct font style.",
+        };
+
+        Sysout.createDialog( );
+        Sysout.printInstructions( instructions );
+
+        PrinterJob pj=PrinterJob.getPrinterJob();
+        pj.setPrintable(new FontPrintable());
+        if (pj.printDialog())
+            {
+                try { pj.print(); }
+                catch (PrinterException e) {
+                    System.out.println(e);
+                }
+            }
+    }
+}
+
+class FontPrintable
+    implements Printable {
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+        if (pageIndex != 0) return NO_SUCH_PAGE;
+        Graphics2D g2= (Graphics2D)g;
+
+        g2.setPaint(Color.black);
+
+        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+        String[] fontList = ge.getAvailableFontFamilyNames();
+        g2.setFont (new Font ("Arial", Font.PLAIN, 20));
+        g2.drawString("Arial - Plain", 144, 120);
+        g2.setFont (new Font ("Arial", Font.BOLD, 20));
+        g2.drawString("Arial - Bold", 144, 145);
+        g2.setFont (new Font ("Arial", Font.ITALIC, 20));
+        g2.drawString("Arial - Italic", 144, 170);
+        g2.setFont (new Font ("Times New Roman", Font.PLAIN, 20));
+        g2.drawString("Times New Roman - Plain", 144, 195);
+        g2.setFont (new Font ("Times New Roman", Font.BOLD, 20));
+        g2.drawString("Times New Roman - Bold", 144, 220);
+        g2.setFont (new Font ("Times New Roman", Font.ITALIC, 20));
+        g2.drawString("Times New Roman - Italic", 144, 245);
+
+        return PAGE_EXISTS;
+    }
+}
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintImage.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test %I %W
+ * @bug 4298489
+ * @summary Confirm that output is same as screen.
+ * @author jgodinez
+ * @run main/manual PrintImage
+ */
+import java.awt.*;
+import java.awt.print.*;
+import java.awt.event.*;
+
+public class PrintImage extends Frame implements ActionListener {
+
+        private PrintImageCanvas                printImageCanvas;
+
+        private MenuItem        print1Menu = new MenuItem("PrintTest1");
+        private MenuItem        print2Menu = new MenuItem("PrintTest2");
+        private MenuItem        exitMenu = new MenuItem("Exit");
+
+        public static void main(String[] argv) {
+        String[] instructions =
+           { "You must have a printer available to perform this test,",
+             "prefererably Canon LaserShot A309GII.",
+             "Printing must be done in Win 98 Japanese 2nd Edition.",
+             "",
+             "Passing test : Output of text image for PrintTest1 and PrintTest2 should be same as that on the screen.",
+           };
+
+        Sysout.createDialog( );
+         Sysout.printInstructions( instructions );
+
+                new PrintImage();
+        }
+
+        public PrintImage() {
+                super("PrintImage");
+                initPrintImage();
+        }
+
+        public void initPrintImage() {
+
+                printImageCanvas = new PrintImageCanvas(this);
+
+                initMenu();
+
+                addWindowListener(new WindowAdapter() {
+                        public void windowClosing(WindowEvent ev) {
+                                dispose();
+                        }
+                        public void windowClosed(WindowEvent ev) {
+                                System.exit(0);
+                        }
+                });
+
+                setLayout(new BorderLayout());
+                add(printImageCanvas, BorderLayout.CENTER);
+                pack();
+
+                setSize(500,500);
+                setVisible(true);
+        }
+
+        private void initMenu() {
+                MenuBar         mb = new MenuBar();
+                Menu            me = new Menu("File");
+                me.add(print1Menu);
+                me.add(print2Menu);
+                me.add("-");
+                me.add(exitMenu);
+                mb.add(me);
+                this.setMenuBar(mb);
+
+                print1Menu.addActionListener(this);
+                print2Menu.addActionListener(this);
+                exitMenu.addActionListener(this);
+        }
+
+        public void actionPerformed(ActionEvent e) {
+                Object target = e.getSource();
+                if( target.equals(print1Menu) ) {
+                        printMain1();
+                }
+                else if( target.equals(print2Menu) ) {
+                        printMain2();
+                }
+                else if( target.equals(exitMenu) ) {
+                        dispose();
+                }
+        }
+
+        private void printMain1(){
+
+                PrinterJob printerJob = PrinterJob.getPrinterJob();
+                PageFormat pageFormat = printerJob.defaultPage();
+
+                printerJob.setPrintable((Printable)printImageCanvas, pageFormat);
+
+                if(printerJob.printDialog()){
+                        try {
+                                printerJob.print();
+                        }
+                        catch(PrinterException p){
+                        }
+                }
+                else
+                        printerJob.cancel();
+        }
+
+        private void printMain2(){
+
+                PrinterJob printerJob = PrinterJob.getPrinterJob();
+                PageFormat pageFormat = printerJob.pageDialog(printerJob.defaultPage());
+
+                printerJob.setPrintable((Printable)printImageCanvas, pageFormat);
+
+                if(printerJob.printDialog()){
+                        try {
+                                printerJob.print();
+                        }
+                        catch(PrinterException p){
+                        }
+                }
+                else
+                        printerJob.cancel();
+        }
+
+}
+
+class PrintImageCanvas extends Canvas implements Printable {
+
+        private PrintImage pdsFrame;
+
+        public PrintImageCanvas(PrintImage pds) {
+                pdsFrame = pds;
+        }
+
+        public void paint(Graphics g) {
+                Font drawFont = new Font("MS Mincho",Font.ITALIC,50);
+                g.setFont(drawFont);
+                g.drawString("PrintSample!",100,150);
+        }
+
+        public int print(Graphics g, PageFormat pf, int pi)
+                throws PrinterException {
+
+                if(pi>=1)
+                        return NO_SUCH_PAGE;
+                else{
+                        Graphics2D g2 = (Graphics2D)g;
+                        g.setColor(new Color(0,0,0,200));
+
+                        Font drawFont = new Font("MS Mincho",Font.ITALIC,50);
+                        g.setFont(drawFont);
+                        g.drawString("PrintSample!",100,150);
+                        return PAGE_EXISTS;
+                }
+        }
+}
+
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintNullString.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,328 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4223328
+ * @summary Printer graphics must behave the same as screen graphics
+ * @author prr
+ * @run main/manual PrintNullString
+ */
+
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import java.text.*;
+
+public class PrintNullString extends Frame implements ActionListener {
+
+ private TextCanvas c;
+
+ public static void main(String args[]) {
+
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "This test should print a page which contains the same",
+         "text messages as in the test window on the screen",
+         "The messages should contain only 'OK' and 'expected' messages",
+         "There should be no FAILURE messages.",
+         "You should also monitor the command line to see if any exceptions",
+         "were thrown",
+         "If the page fails to print, but there were no exceptions",
+         "then the problem is likely elsewhere (ie your printer)"
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+    PrintNullString f = new PrintNullString();
+    f.show();
+ }
+
+ public PrintNullString() {
+    super("JDK 1.2 drawString Printing");
+
+    c = new TextCanvas();
+    add("Center", c);
+
+    Button printButton = new Button("Print");
+    printButton.addActionListener(this);
+    add("South", printButton);
+
+    addWindowListener(new WindowAdapter() {
+       public void windowClosing(WindowEvent e) {
+             System.exit(0);
+            }
+    });
+
+    pack();
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+   PrinterJob pj = PrinterJob.getPrinterJob();
+
+   if (pj != null && pj.printDialog()) {
+
+       pj.setPrintable(c);
+       try {
+            pj.print();
+      } catch (PrinterException pe) {
+      } finally {
+         System.err.println("PRINT RETURNED");
+      }
+   }
+ }
+
+ class TextCanvas extends Panel implements Printable {
+
+    String nullStr = null;
+    String emptyStr = new String();
+    AttributedString nullAttStr = null;
+    AttributedString emptyAttStr = new AttributedString(emptyStr);
+    AttributedCharacterIterator nullIterator = null;
+    AttributedCharacterIterator emptyIterator = emptyAttStr.getIterator();
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+
+      if (pgIndex > 0)
+         return Printable.NO_SUCH_PAGE;
+
+      Graphics2D g2d = (Graphics2D)g;
+      g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+
+      paint(g);
+
+      return Printable.PAGE_EXISTS;
+    }
+
+    public void paint(Graphics g1) {
+        Graphics2D g = (Graphics2D)g1;
+
+        // API 1: null & empty drawString(String, int, int);
+        try {
+             g.drawString(nullStr, 20, 40);
+             g.drawString("FAILURE: No NPE for null String, int", 20, 40);
+        } catch (NullPointerException e) {
+          g.drawString("caught expected NPE for null String, int", 20, 40);
+        }/* catch (Exception e) {
+          g.drawString("FAILURE: unexpected exception for null String, int",
+                        20, 40);
+        }*/
+
+        //try {
+             g.drawString(emptyStr, 20, 60);
+             g.drawString("OK for empty String, int", 20, 60);
+        /*} catch (Exception e) {
+          g.drawString("FAILURE: unexpected exception for empty String, int",
+                        20, 60);
+        }*/
+
+
+        // API 2: null & empty drawString(String, float, float);
+        try {
+             g.drawString(nullStr, 20.0f, 80.0f);
+             g.drawString("FAILURE: No NPE for null String, float", 20, 80);
+        } catch (NullPointerException e) {
+          g.drawString("caught expected NPE for null String, float", 20, 80);
+        } /*catch (Exception e) {
+          g.drawString("FAILURE: unexpected exception for null String, float",
+                        20, 80);
+        }*/
+        //try {
+             g.drawString(emptyStr, 20.0f, 100.0f);
+             g.drawString("OK for empty String, float", 20.0f, 100.f);
+        /* } catch (Exception e) {
+          g.drawString("FAILURE: unexpected exception for empty String, float",
+                        20, 100);
+        }*/
+
+        // API 3: null & empty drawString(Iterator, int, int);
+        try {
+             g.drawString(nullIterator, 20, 120);
+             g.drawString("FAILURE: No NPE for null iterator, float", 20, 120);
+        } catch (NullPointerException e) {
+          g.drawString("caught expected NPE for null iterator, int", 20, 120);
+        } /*catch (Exception e) {
+          g.drawString("FAILURE: unexpected exception for null iterator, int",
+                       20, 120);
+        } */
+        try {
+             g.drawString(emptyIterator, 20, 140);
+             g.drawString("FAILURE: No IAE for empty iterator, int",
+                           20, 140);
+        } catch (IllegalArgumentException e) {
+          g.drawString("caught expected IAE for empty iterator, int",
+                        20, 140);
+        } /*catch (Exception e) {
+          g.drawString("FAILURE: unexpected exception for empty iterator, int",
+                       20, 140);
+        } */
+
+
+        // API 4: null & empty drawString(Iterator, float, int);
+        try {
+             g.drawString(nullIterator, 20.0f, 160.0f);
+             g.drawString("FAILURE: No NPE for null iterator, float", 20, 160);
+        } catch (NullPointerException e) {
+          g.drawString("caught expected NPE for null iterator, float", 20, 160);
+        } /*catch (Exception e) {
+          g.drawString("FAILURE: unexpected exception for null iterator, float",
+                        20, 160);
+        } */
+
+        try {
+             g.drawString(emptyIterator, 20, 180);
+             g.drawString("FAILURE: No IAE for empty iterator, float",
+                           20, 180);
+        } catch (IllegalArgumentException e) {
+          g.drawString("caught expected IAE for empty iterator, float",
+                        20, 180);
+        } /*catch (Exception e) {
+          g.drawString("FAILURE: unexpected exception for empty iterator, float",
+                       20, 180);
+        } */
+    }
+
+     public Dimension getPreferredSize() {
+        return new Dimension(450, 250);
+    }
+ }
+
+}
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintParenString.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4399442
+ * @summary Brackets should be quoted in Postscript output
+ * @author prr
+ * @run main/manual PrintParenString
+ */
+
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import java.text.*;
+
+public class PrintParenString extends Frame implements ActionListener {
+
+ private TextCanvas c;
+
+ public static void main(String args[]) {
+
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "This test should print a page which contains the same",
+         "text message as in the test window on the screen",
+         "You should also monitor the command line to see if any exceptions",
+         "were thrown",
+         "If an exception is thrown, or the page doesn't print properly",
+         "then the test fails",
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+    PrintParenString f = new PrintParenString();
+    f.show();
+ }
+
+ public PrintParenString() {
+    super("JDK 1.2 drawString Printing");
+
+    c = new TextCanvas();
+    add("Center", c);
+
+    Button printButton = new Button("Print");
+    printButton.addActionListener(this);
+    add("South", printButton);
+
+    addWindowListener(new WindowAdapter() {
+       public void windowClosing(WindowEvent e) {
+             System.exit(0);
+            }
+    });
+
+    pack();
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+   PrinterJob pj = PrinterJob.getPrinterJob();
+
+   if (pj != null && pj.printDialog()) {
+
+       pj.setPrintable(c);
+       try {
+            pj.print();
+      } catch (PrinterException pe) {
+      } finally {
+         System.err.println("PRINT RETURNED");
+      }
+   }
+ }
+
+ class TextCanvas extends Panel implements Printable {
+
+    String nullStr = null;
+    String emptyStr = new String();
+    AttributedString nullAttStr = null;
+    AttributedString emptyAttStr = new AttributedString(emptyStr);
+    AttributedCharacterIterator nullIterator = null;
+    AttributedCharacterIterator emptyIterator = emptyAttStr.getIterator();
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+
+      if (pgIndex > 0)
+         return Printable.NO_SUCH_PAGE;
+
+      Graphics2D g2d = (Graphics2D)g;
+      g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+
+      paint(g);
+
+      return Printable.PAGE_EXISTS;
+    }
+
+    public void paint(Graphics g1) {
+        Graphics2D g = (Graphics2D)g1;
+
+          String str = "String containing unclosed parenthesis (.";
+          g.drawString(str, 20, 40);
+
+    }
+
+     public Dimension getPreferredSize() {
+        return new Dimension(450, 250);
+    }
+ }
+
+}
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintRotatedText.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4271596
+ * @bug 4460699
+ * @summary Rotated text printing
+ * @author prr
+ * @run main/manual PrintRotatedText
+ */
+
+/* Text is drawn as spokes of a wheel with both a uniform scale and
+ * a non-uniform scale.
+ * The test is checking whether the implementation properly handles this
+ * and in particular that asking win32 GDI to draw text rotated works
+ * properly.
+ *
+ */
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.font.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+
+public class PrintRotatedText extends Frame implements ActionListener {
+ static String fontname="Lucida Sans Regular"; // our font
+ private TextCanvas c;
+
+ public static void main(String args[]) {
+
+    PrintRotatedText f = new PrintRotatedText();
+    f.show();
+ }
+
+ public PrintRotatedText() {
+    super("JDK 1.2 Text Printing");
+
+    String []fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
+    for (int i=0;i<fonts.length;i++) {
+       if (fonts[i].equals("Times New Roman")) {
+         fontname = "Times New Roman";
+       }
+    }
+    c = new TextCanvas();
+    add("Center", c);
+
+    Button printButton = new Button("Print");
+    printButton.addActionListener(this);
+    add("South", printButton);
+
+    addWindowListener(new WindowAdapter() {
+       public void windowClosing(WindowEvent e) {
+             System.exit(0);
+            }
+    });
+
+    pack();
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+   PrinterJob pj = PrinterJob.getPrinterJob();
+
+   if (pj != null && pj.printDialog()) {
+
+       pj.setPageable(c);
+       try {
+            pj.print();
+      } catch (PrinterException pe) {
+      } finally {
+         System.err.println("PRINT RETURNED");
+      }
+   }
+ }
+
+ class TextCanvas extends Panel implements Pageable, Printable {
+
+    public static final int MAXPAGE = 8;
+    // public static final String extra ="\u0391A\u2200B\u2702C\u2778D";
+    public static final String extra ="\u0394\u03A9ABCD";
+    public String estr=extra;
+
+    public int getNumberOfPages() {
+        return MAXPAGE;
+    }
+
+    public PageFormat getPageFormat(int pageIndex) {
+       if (pageIndex > MAXPAGE) throw new IndexOutOfBoundsException();
+       PageFormat pf = new PageFormat();
+       Paper p = pf.getPaper();
+       p.setImageableArea(36, 36, p.getWidth()-72, p.getHeight()-72);
+       pf.setPaper(p);
+
+/*
+       if (pageIndex==1)
+         pf.setOrientation(PageFormat.LANDSCAPE);
+       else if (pageIndex==2)
+         pf.setOrientation(PageFormat.REVERSE_LANDSCAPE);
+*/
+
+       return pf;
+    }
+
+    public Printable getPrintable(int pageIndex) {
+       if (pageIndex > MAXPAGE) throw new IndexOutOfBoundsException();
+       return this;
+    }
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+System.out.println("****"+pgIndex);
+        double iw = pgFmt.getImageableWidth();
+        double ih = pgFmt.getImageableHeight();
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+        //g2d.drawString("top left of page format",20,20 );
+        int modulo = pgIndex % 4;
+        int divvy = pgIndex / 4;
+        if (divvy != 0 ) {
+           g2d.setFont(new Font(fontname,Font.PLAIN, 18));
+           estr = "";
+        } else {
+           estr = extra;
+        }
+
+        int xs = 1;
+        int ys = 1;
+
+        if (modulo == 1) {
+            xs = -1;
+        }
+        if (modulo == 2) {
+            ys = -1;
+        }
+        if (modulo == 3) {
+            xs = -1;
+            ys = -1;
+        }
+
+        g2d.translate(iw*0.25, ih*0.2);
+        drawTheText((Graphics2D)g2d.create(), xs*1.0,ys* 1.0);
+        g2d.translate(iw*0.25, ih*0.2);
+        drawTheText((Graphics2D)g2d.create(), xs*1.0,ys* 1.5);
+        g2d.translate(-iw*0.2, ih*0.3);
+        drawTheText((Graphics2D)g2d.create(), xs*1.5, ys*1.0);
+
+        return Printable.PAGE_EXISTS;
+    }
+
+   private void drawTheText(Graphics2D g2d, double sx, double sy) {
+      double mat[]= new double[6];
+
+      g2d.drawOval(-75,-75,150,150);
+      int degrees = 30;
+      for (int i=0;i<360;i=i+degrees) {
+          AffineTransform saveXfm = g2d.getTransform();
+          g2d.scale(sx, sy);
+          int ttype = g2d.getTransform().getType();
+          String s = "ANGLE="+i;
+          s +=estr;
+          g2d.drawString(s, 20, 0);
+          FontRenderContext frc = g2d.getFontRenderContext();
+          Font f = g2d.getFont();
+          Rectangle2D r2d = f.getStringBounds(s, frc);
+          g2d.drawLine(20, 1, 20+(int)r2d.getWidth(), 1);
+          g2d.scale(1.0/sx, 1.0/sy);
+          g2d.setTransform(saveXfm);
+
+          g2d.rotate(Math.toRadians(degrees));
+      }
+   }
+
+    public void paint(Graphics g) {
+      g.translate(200,200);
+      g.setFont(new Font("serif", Font.PLAIN, 12));
+      drawTheText((Graphics2D)g, 1.0, 1.5);
+    }
+
+     public Dimension getPreferredSize() {
+        return new Dimension(400, 400);
+    }
+ }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintTextLayout.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4480930
+ * @summary TextLayout prints as filled shapes
+ * @author prr
+ * @run main/manual PrintTextLayout
+ */
+
+/* This is a MANUAL test and must be run on a system with a printer
+ * configured.
+ */
+
+import java.io.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.font.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class PrintTextLayout implements Printable {
+    static String[] fontnames = {
+        "Lucida Sans",
+        "Lucida Bright",
+        "Lucida Sans Typewriter",
+        "SansSerif",
+        "Serif",
+        "Monospaced",
+     };
+
+    static String text =
+    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890";
+
+    public static void main(String args[]) {
+        PrinterJob pj = PrinterJob.getPrinterJob();
+
+        if (pj != null) {
+            PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+            aset.add(new Destination((new File("./out.ps")).toURI()));
+            PageFormat pf = pj.defaultPage();
+            Paper p = pf.getPaper();
+            // Extend imageable width to reduce likelihood end of text
+            // is clipped as we'd like to see the end of the line.
+            p.setImageableArea(p.getImageableX(), p.getImageableY(),
+                               p.getWidth()-p.getImageableX(),
+                               p.getImageableHeight());
+            pf.setPaper(p);
+            pj.setPrintable( new PrintTextLayout(), pf);
+            try {
+                pj.print(aset);
+            } catch (PrinterException pe) {
+                pe.printStackTrace();
+            } finally {
+            }
+        }
+    }
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+        if (pgIndex > 0) return Printable.NO_SUCH_PAGE;
+
+        double iw = pgFmt.getImageableWidth();
+        double ih = pgFmt.getImageableHeight();
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY()+50);
+
+        float ypos = 20f;
+        for (int f=0; f< fontnames.length; f++) {
+            for (int s=0;s<4;s++) {
+                Font font = new Font(fontnames[f], s, 12);
+                ypos = drawText(g2d, font, ypos);
+            }
+        }
+        return Printable.PAGE_EXISTS;
+    }
+
+    float drawText(Graphics2D g2d, Font font, float ypos) {
+        int x = 10;
+        /* Set the graphics font to something odd before using TL so
+         * can be sure it picks up the font from the TL, not the graphics */
+        Font f1 = new Font("serif", Font.ITALIC, 1);
+        g2d.setFont(f1);
+        FontRenderContext frc = new FontRenderContext(null, false, false);
+        TextLayout tl = new TextLayout(text ,font, frc);
+        float ascent = tl.getAscent();
+        int dpos = (int)(ypos+ascent);
+        tl.draw(g2d, x, dpos);
+        int dpos2 = (int)(ypos+ascent+tl.getDescent());
+        g2d.drawLine(x, dpos2, x+(int)tl.getAdvance(), dpos2);
+        float tlHeight = tl.getAscent()+tl.getDescent()+tl.getLeading();
+        return ypos+tlHeight;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintTextPane.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test PrintTextPane.java
+  @bug 6452415 6570471
+  @summary Test that swing text prints using GDI printer fonts.
+  @author prr: area=PrinterJob
+  @run main PrintTextPane
+
+ */
+import java.io.*;
+import java.net.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+import javax.swing.*;
+import javax.swing.text.*;
+import java.awt.print.*;
+
+public class PrintTextPane extends JTextPane implements Printable {
+
+   static String text = "Twinkle twinkle little star, \n" +
+                        "How I wonder what you are. \n" +
+                        "Up above the world so high, \n" +
+                        "Like a diamond in the sky. \n" +
+                        "Twinkle, twinkle, little star, \n" +
+                        "How I wonder what you are!\n";
+
+    public int print(Graphics g, PageFormat pf, int page)
+                                 throws PrinterException {
+        if (page > 0) {
+            return NO_SUCH_PAGE;
+        }
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.translate(pf.getImageableX(), pf.getImageableY());
+        printAll(g);
+        return PAGE_EXISTS;
+    }
+
+    public void printPane(PrintRequestAttributeSet aset) {
+        try {
+             print(null, null, false, null, aset, false);
+         } catch (PrinterException ex) {
+               throw new RuntimeException(ex);
+         }
+    }
+
+    public void printPaneJob(PrintRequestAttributeSet aset) {
+         PrinterJob job = PrinterJob.getPrinterJob();
+         job.setPrintable(this);
+         try {
+             job.print(aset);
+         } catch (PrinterException ex) {
+             throw new RuntimeException(ex);
+         }
+    }
+
+    public PrintTextPane(String fontFamily) {
+        super();
+        SimpleAttributeSet aset = new SimpleAttributeSet();
+        StyleConstants.setFontFamily(aset, fontFamily);
+        setCharacterAttributes(aset, false);
+        setText(text+text+text+text+text+text+text+text);
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        String os = System.getProperty("os.name");
+
+        if (!os.startsWith("Windows")) {
+             return;
+        }
+
+        PrinterJob job = PrinterJob.getPrinterJob();
+        if (job.getPrintService() == null) {
+            System.err.println("Warning: no printers, skipping test");
+            return;
+        }
+        JFrame f = new JFrame("Print Text Pane1");
+        f.addWindowListener(new WindowAdapter() {
+           public void windowClosing(WindowEvent e) {System.exit(0);}
+        });
+        PrintTextPane monoPane = new PrintTextPane("Monospaced");
+        f.add("East", monoPane);
+        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+        PrintTextPane courPane = new PrintTextPane("Courier New");
+        f.add("West", courPane);
+        f.pack();
+        f.setVisible(true);
+
+        File spoolFile = File.createTempFile("CourText", ".prn");
+        System.out.println(spoolFile);
+        Destination dest = new Destination(spoolFile.toURI());
+        aset.add(dest);
+        courPane.printPane(aset);
+        long courLen = spoolFile.length();
+        System.out.println("CourText="+spoolFile.length());
+        spoolFile.delete();
+
+        spoolFile = File.createTempFile("MonoText", ".prn");
+        System.out.println(spoolFile);
+        dest = new Destination(spoolFile.toURI());
+        aset.add(dest);
+        monoPane.printPane(aset);
+        long monoLen = spoolFile.length();
+        System.out.println("MonoText="+spoolFile.length());
+        spoolFile.delete();
+
+        if (courLen > 2 * monoLen) {
+            throw new RuntimeException("Shapes being printed?");
+        }
+
+        spoolFile = File.createTempFile("CourJob", ".prn");
+        System.out.println(spoolFile);
+        dest = new Destination(spoolFile.toURI());
+        aset.add(dest);
+        courPane.printPaneJob(aset);
+        courLen = spoolFile.length();
+        System.out.println("CourJob="+spoolFile.length());
+        spoolFile.delete();
+
+        spoolFile = File.createTempFile("MonoJob", ".prn");
+        System.out.println(spoolFile);
+        dest = new Destination(spoolFile.toURI());
+        aset.add(dest);
+        monoPane.printPaneJob(aset);
+        monoLen = spoolFile.length();
+        System.out.println("MonoJob="+spoolFile.length());
+        spoolFile.delete();
+
+        if (courLen > 2 * monoLen) {
+            throw new RuntimeException("Shapes being printed?");
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintTextTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,477 @@
+/*
+ * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6425068 7157659
+ * @summary Confirm that text prints where we expect to the length we expect.
+ * @run main/manual=yesno PrintTextTest
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.text.*;
+import java.util.*;
+import java.awt.font.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import javax.swing.*;
+
+public class PrintTextTest extends Component implements Printable {
+
+    static int preferredSize;
+    Font textFont;
+    AffineTransform gxTx;
+    String page;
+    boolean useFM;
+
+    public static void main(String args[]) {
+        String[] instructions =
+        {
+            "This tests that printed text renders similarly to on-screen",
+            "under a variety of APIs and graphics and font transforms",
+            "Print to your preferred printer. Collect the output.",
+            "Refer to the onscreen buttons to cycle through the on-screen",
+            "content",
+            "For each page, confirm that the printed content corresponds to",
+            "the on-screen rendering for that *same* page.",
+            "Some cases may look odd but its intentional. Verify",
+            "it looks the same on screen and on the printer.",
+            "Note that text does not scale linearly from screen to printer",
+            "so some differences are normal and not a bug.",
+            "The easiest way to spot real problems is to check that",
+            "any underlines are the same length as the underlined text",
+            "and that any rotations are the same in each case.",
+            "Note that each on-screen page is printed in both portrait",
+            "and landscape mode",
+            "So for example, Page 1/Portrait, and Page 1/Landscape when",
+            "rotated to view properly, should both match Page 1 on screen.",
+        };
+        Sysout.createDialogWithInstructions(instructions);
+
+
+        PrinterJob pjob = PrinterJob.getPrinterJob();
+        PageFormat portrait = pjob.defaultPage();
+        portrait.setOrientation(PageFormat.PORTRAIT);
+        preferredSize = (int)portrait.getImageableWidth();
+
+        PageFormat landscape = pjob.defaultPage();
+        landscape.setOrientation(PageFormat.LANDSCAPE);
+
+        Book book = new Book();
+
+        JTabbedPane p = new JTabbedPane();
+
+        int page = 1;
+        Font font = new Font("Dialog", Font.PLAIN, 18);
+        String name = "Page " + new Integer(page++);
+        PrintTextTest ptt = new PrintTextTest(name, font, null, false);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Dialog", Font.PLAIN, 18);
+        name = "Page " + new Integer(page++);
+        ptt = new PrintTextTest(name, font, null, true);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Lucida Sans", Font.PLAIN, 18);
+        name = "Page " + new Integer(page++);
+        ptt = new PrintTextTest(name, font, null, false);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = new Font("Lucida Sans", Font.PLAIN, 18);
+        AffineTransform rotTx = AffineTransform.getRotateInstance(0.15);
+        rotTx.translate(60,0);
+        name = "Page " + new Integer(page++);
+        ptt = new PrintTextTest(name, font, rotTx, false);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        font = font.deriveFont(rotTx);
+        name = "Page " + new Integer(page++);
+        ptt = new PrintTextTest(name, font, null, false);
+        p.add(ptt, BorderLayout.CENTER);
+        p.add(name, ptt);
+        book.append(ptt, portrait);
+        book.append(ptt, landscape);
+
+        if (System.getProperty("os.name").startsWith("Windows")) {
+            font = new Font("MS Gothic", Font.PLAIN, 12);
+            name = "Page " + new Integer(page++);
+            ptt = new PrintJAText(name, font, null, true);
+            p.add(ptt, BorderLayout.CENTER);
+            p.add(name, ptt);
+            book.append(ptt, portrait);
+            book.append(ptt, landscape);
+
+            font = new Font("MS Gothic", Font.PLAIN, 12);
+            name = "Page " + new Integer(page++);
+            rotTx = AffineTransform.getRotateInstance(0.15);
+            ptt = new PrintJAText(name, font, rotTx, true);
+            p.add(ptt, BorderLayout.CENTER);
+            p.add(name, ptt);
+            book.append(ptt, portrait);
+            book.append(ptt, landscape);
+        }
+
+        pjob.setPageable(book);
+
+        JFrame f = new JFrame();
+        f.add(BorderLayout.CENTER, p);
+        f.addWindowListener(new WindowAdapter() {
+            public void windowClosing(WindowEvent e) {System.exit(0);}
+        });
+        f.pack();
+        f.show();
+
+        try {
+            if (pjob.printDialog()) {
+                pjob.print();
+            }
+        } catch (PrinterException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    public PrintTextTest(String page, Font font, AffineTransform gxTx,
+                         boolean fm) {
+        this.page = page;
+        textFont = font;
+        this.gxTx = gxTx;
+        this.useFM = fm;
+        setBackground(Color.white);
+    }
+
+    public static AttributedCharacterIterator getIterator(String s) {
+        return new AttributedString(s).getIterator();
+    }
+
+    static String orient(PageFormat pf) {
+        if (pf.getOrientation() == PageFormat.PORTRAIT) {
+            return "Portrait";
+        } else {
+            return "Landscape";
+        }
+    }
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.translate(pf.getImageableX(),  pf.getImageableY());
+        g.drawString(page+" "+orient(pf),50,20);
+        g.translate(0, 25);
+        paint(g);
+        return PAGE_EXISTS;
+    }
+
+    public Dimension getMinimumSize() {
+        return getPreferredSize();
+    }
+
+    public Dimension getPreferredSize() {
+        return new Dimension(preferredSize, preferredSize);
+    }
+
+    public void paint(Graphics g) {
+
+        /* fill with white before any transformation is applied */
+        g.setColor(Color.white);
+        g.fillRect(0, 0, getSize().width, getSize().height);
+
+
+        Graphics2D g2d = (Graphics2D) g;
+        if (gxTx != null) {
+            g2d.transform(gxTx);
+        }
+        if (useFM) {
+            g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        }
+
+        g.setFont(textFont);
+        FontMetrics fm = g.getFontMetrics();
+
+        String s;
+        int LS = 30;
+        int ix=10, iy=LS+10;
+        g.setColor(Color.black);
+
+        s = "drawString(String str, int x, int y)";
+        g.drawString(s, ix, iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+        }
+
+        iy += LS;
+        s = "drawString(AttributedCharacterIterator iterator, int x, int y)";
+        g.drawString(getIterator(s), ix, iy);
+
+        iy += LS;
+        s = "\tdrawChars(\t\r\nchar[], int off, int len, int x, int y\t)";
+        g.drawChars(s.toCharArray(), 0, s.length(), ix, iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+        }
+
+        iy += LS;
+        s = "drawBytes(byte[], int off, int len, int x, int y)";
+        byte data[] = new byte[s.length()];
+        for (int i = 0; i < data.length; i++) {
+            data[i] = (byte) s.charAt(i);
+        }
+        g.drawBytes(data, 0, data.length, ix, iy);
+
+        Font f = g2d.getFont();
+        FontRenderContext frc = g2d.getFontRenderContext();
+
+        iy += LS;
+        s = "drawString(String s, float x, float y)";
+        g2d.drawString(s, (float) ix, (float) iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+        }
+
+        iy += LS;
+        s = "drawString(AttributedCharacterIterator iterator, "+
+            "float x, float y)";
+        g2d.drawString(getIterator(s), (float) ix, (float) iy);
+
+        iy += LS;
+        s = "drawGlyphVector(GlyphVector g, float x, float y)";
+        GlyphVector gv = f.createGlyphVector(frc, s);
+        g2d.drawGlyphVector(gv, ix, iy);
+        Point2D adv = gv.getGlyphPosition(gv.getNumGlyphs());
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+(int)adv.getX(), iy+1);
+        }
+
+        iy += LS;
+        s = "GlyphVector with position adjustments";
+
+        gv = f.createGlyphVector(frc, s);
+        int ng = gv.getNumGlyphs();
+        adv = gv.getGlyphPosition(ng);
+        for (int i=0; i<ng; i++) {
+            Point2D gp = gv.getGlyphPosition(i);
+            double gx = gp.getX();
+            double gy = gp.getY();
+            if (i % 2 == 0) {
+                gy+=5;
+            } else {
+                gy-=5;
+            }
+            gp.setLocation(gx, gy);
+            gv.setGlyphPosition(i, gp);
+        }
+        g2d.drawGlyphVector(gv, ix, iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+(int)adv.getX(), iy+1);
+        }
+
+        iy +=LS;
+        s = "drawString: \u0924\u094d\u0930 \u0915\u0948\u0930\u0947 End.";
+        g.drawString(s, ix, iy);
+        if (!textFont.isTransformed()) {
+            g.drawLine(ix, iy+1, ix+fm.stringWidth(s), iy+1);
+        }
+
+        iy += LS;
+        s = "TextLayout 1: \u0924\u094d\u0930 \u0915\u0948\u0930\u0947 End.";
+        TextLayout tl = new TextLayout(s, new HashMap(), frc);
+        tl.draw(g2d,  ix, iy);
+
+        iy += LS;
+        s = "TextLayout 2: \u0924\u094d\u0930 \u0915\u0948\u0930\u0947 End.";
+        tl = new TextLayout(s, f, frc);
+        tl.draw(g2d,  ix, iy);
+    }
+}
+
+class PrintJAText extends PrintTextTest {
+
+
+    public PrintJAText(String page, Font font, AffineTransform gxTx,
+                         boolean fm) {
+        super(page, font, gxTx, fm);
+    }
+
+    private static final String TEXT =
+        "\u3042\u3044\u3046\u3048\u304a\u30a4\u30ed\u30cf" +
+        "\u30cb\u30db\u30d8\u30c8\u4e00\u4e01\u4e02\u4e05\uff08";
+
+
+    public void paint(Graphics g) {
+
+        /* fill with white before any transformation is applied */
+        g.setColor(Color.white);
+        g.fillRect(0, 0, getSize().width, getSize().height);
+
+
+        Graphics2D g2d = (Graphics2D) g;
+        if (gxTx != null) {
+            g2d.transform(gxTx);
+        }
+        if (useFM) {
+            g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        }
+
+        String text = TEXT + TEXT + TEXT;
+        g.setColor(Color.black);
+        int y = 20;
+        float origSize = 7f;
+        for (int i=0;i<11;i++) {
+            float size = origSize+(i*0.1f);
+            g2d.translate(0, size+6);
+            Font f = textFont.deriveFont(size);
+            g2d.setFont(f);
+            FontMetrics fontMetrics = g2d.getFontMetrics();
+            int stringWidth = fontMetrics.stringWidth(text);
+            g.drawLine(0, y+1, stringWidth, y+1);
+            g.drawString(text, 0, y);
+            y +=10;
+        }
+    }
+}
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 20, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("South", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+     //chop up each into pieces maxSringLength long
+     remainingStr = instructions[ i ];
+     while( remainingStr.length() > 0 )
+      {
+        //if longer than max then chop off first max chars to print
+        if( remainingStr.length() >= maxStringLength )
+         {
+           //Try to chop on a word boundary
+           int posOfSpace = remainingStr.
+          lastIndexOf( ' ', maxStringLength - 1 );
+
+           if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+           printStr = remainingStr.substring( 0, posOfSpace + 1 );
+           remainingStr = remainingStr.substring( posOfSpace + 1 );
+         }
+        //else just print
+        else
+         {
+           printStr = remainingStr;
+           remainingStr = "";
+         }
+
+            instructionsText.append( printStr + "\n" );
+
+      }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintTranslatedFont.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6359734
+ * @summary Test that fonts with a translation print where they should.
+ * @author prr
+ * @run main/manual PrintTranslatedFont
+ */
+
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import java.text.*;
+
+public class PrintTranslatedFont extends Frame implements ActionListener {
+
+ private TextCanvas c;
+
+ public static void main(String args[]) {
+
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "This test should print a page which contains the same",
+         "content as the test window on the screen, in particular the lines",
+         "should be immediately under the text",
+         "You should also monitor the command line to see if any exceptions",
+         "were thrown",
+         "If an exception is thrown, or the page doesn't print properly",
+         "then the test fails",
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+    PrintTranslatedFont f = new PrintTranslatedFont();
+    f.show();
+ }
+
+ public PrintTranslatedFont() {
+    super("JDK 1.2 drawString Printing");
+
+    c = new TextCanvas();
+    add("Center", c);
+
+    Button printButton = new Button("Print");
+    printButton.addActionListener(this);
+    add("South", printButton);
+
+    addWindowListener(new WindowAdapter() {
+       public void windowClosing(WindowEvent e) {
+             System.exit(0);
+            }
+    });
+
+    pack();
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+   PrinterJob pj = PrinterJob.getPrinterJob();
+
+   if (pj != null && pj.printDialog()) {
+
+       pj.setPrintable(c);
+       try {
+            pj.print();
+      } catch (PrinterException pe) {
+      } finally {
+         System.err.println("PRINT RETURNED");
+      }
+   }
+ }
+
+ class TextCanvas extends Panel implements Printable {
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+
+      if (pgIndex > 0)
+         return Printable.NO_SUCH_PAGE;
+
+      Graphics2D g2d = (Graphics2D)g;
+      g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+
+      paint(g);
+
+      return Printable.PAGE_EXISTS;
+    }
+
+    public void paint(Graphics g1) {
+        Graphics2D g = (Graphics2D)g1;
+
+          Font f = new Font("Dialog", Font.PLAIN, 20);
+          int tx = 20;
+          int ty = 20;
+          AffineTransform at = AffineTransform.getTranslateInstance(tx, ty);
+          f = f.deriveFont(at);
+          g.setFont(f);
+
+          FontMetrics fm = g.getFontMetrics();
+          String str = "Basic ascii string";
+          int sw = fm.stringWidth(str);
+          int posx = 20, posy = 40;
+          g.drawString(str, posx, posy);
+          g.drawLine(posx+tx, posy+ty+2, posx+tx+sw, posy+ty+2);
+
+          posx = 20; posy = 70;
+          str = "Test string compound printing \u2203\u2200";
+          sw = fm.stringWidth(str);
+          g.drawString(str, posx, posy);
+          g.drawLine(posx+tx, posy+ty+2, posx+tx+sw, posy+ty+2);
+    }
+
+     public Dimension getPreferredSize() {
+        return new Dimension(450, 250);
+    }
+ }
+
+}
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrintVolatileImage.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4511023
+ * @summary Image should be sent to printer, no exceptions thrown
+ * @author prr
+ * @run main/manual PrintVolatileImage
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.*;
+import java.awt.print.*;
+
+public class PrintVolatileImage extends Component
+                            implements ActionListener, Printable {
+
+    VolatileImage vimg = null;
+
+    public static void main(String args[]) {
+       Frame f = new Frame();
+       PrintVolatileImage pvi = new PrintVolatileImage();
+       f.add("Center", pvi);
+       Button b = new Button("Print");
+       b.addActionListener(pvi);
+       f.add("South", b);
+       f.pack();
+       f.show();
+    }
+
+    public PrintVolatileImage() {
+    }
+
+    public Dimension getPreferredSize() {
+       return new Dimension(100,100);
+    }
+
+    public void paint(Graphics g) {
+       if (vimg == null) {
+           vimg = createVolatileImage(100,100);
+           Graphics ig = vimg.getGraphics();
+           ig.setColor(Color.white);
+           ig.fillRect(0,0,100,100);
+           ig.setColor(Color.black);
+           ig.drawLine(0,0,100,100);
+           ig.drawLine(100,0,0,100);
+        }
+        g.drawImage(vimg, 0,0, null);
+    }
+
+   public void actionPerformed(ActionEvent e) {
+
+       PrinterJob pj = PrinterJob.getPrinterJob();
+
+       if (pj != null && pj.printDialog()) {
+           pj.setPrintable(this);
+           try {
+               pj.print();
+           } catch (PrinterException pe) {
+           } finally {
+               System.err.println("PRINT RETURNED");
+           }
+       }
+   }
+
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+      if (pgIndex > 0)
+         return Printable.NO_SUCH_PAGE;
+
+      Graphics2D g2d = (Graphics2D)g;
+      g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+      paint(g);
+      return Printable.PAGE_EXISTS;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrinterDevice.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ *
+ * @bug 4276227
+ * @summary Checks that the PrinterGraphics is for a Printer GraphicsDevice.
+ * Test doesn't run unless there's a printer on the system.
+ * @author prr
+ * @run main/othervm PrinterDevice
+ */
+
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.print.*;
+import java.io.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class PrinterDevice implements Printable {
+
+    public static void main(String args[]) throws PrinterException {
+        System.setProperty("java.awt.headless", "true");
+
+        PrinterJob pj = PrinterJob.getPrinterJob();
+        if (pj.getPrintService() == null) {
+            return; /* Need a printer to run this test */
+        }
+
+        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+        File f = new File("./out.prn");
+        f.deleteOnExit();
+        aset.add(new Destination(f.toURI()));
+        aset.add(OrientationRequested.LANDSCAPE);
+        pj.setPrintable(new PrinterDevice());
+        pj.print(aset);
+    }
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+         if (pageIndex > 0 ) {
+             return Printable.NO_SUCH_PAGE;
+         }
+
+         /* Make sure calls to get DeviceConfig, its transforms,
+          * etc all work without exceptions and as expected */
+         Graphics2D g2 = (Graphics2D)g;
+         GraphicsConfiguration gConfig = g2.getDeviceConfiguration();
+         AffineTransform dt = gConfig.getDefaultTransform();
+         AffineTransform nt = gConfig.getNormalizingTransform();
+         AffineTransform gt = g2.getTransform();
+
+         System.out.println("Graphics2D transform = " + gt);
+         System.out.println("Default transform = " + dt);
+         System.out.println("Normalizing transform = " + nt);
+
+         Rectangle bounds = gConfig.getBounds();
+         System.out.println("Bounds = " + bounds);
+         if (!nt.isIdentity()) {
+             throw new RuntimeException("Expected Identity transdform");
+         }
+
+         /* Make sure that device really is TYPE_PRINTER */
+         GraphicsDevice gd = gConfig.getDevice();
+         System.out.println("Printer Device ID = " + gd.getIDstring());
+         if (!(gd.getType() == GraphicsDevice.TYPE_PRINTER)) {
+             throw new RuntimeException("Expected printer device");
+         }
+         System.out.println(" *** ");
+         System.out.println("");
+         return Printable.PAGE_EXISTS;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrinterDialogsModalityTest/PrinterDialogsModalityTest.html	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<!--  
+  @test
+  @bug 4784285 4785920
+  @summary check whether Print- and Page- dialogs are modal and correct window activated after their closing
+  @author Your Name: area=PrinterJob.modality
+  @run applet/manual=yesno PrinterDialogsModalityTest.html
+  -->
+<head>
+<title> PrinterDialogsModalityTest </title>
+</head>
+<body>
+
+<h1>PrinterDialogsModalityTest<br>Bug ID: 4784285 4785920</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="PrinterDialogsModalityTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrinterDialogsModalityTest/PrinterDialogsModalityTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  test
+  @bug 4784285 4785920
+  @summary check whether Print- and Page- dialogs are modal and correct window activated after their closing
+  @author son@sparc.spb.su: area=PrinterJob.modality
+  @run applet/manual=yesno PrinterDialogsModalityTest.html
+*/
+
+/**
+ * PrinterDialogsModalityTest.java
+ *
+ * summary: check whether Print- and Page- dialogs are modal and correct window activated after their closing
+ */
+
+import java.applet.Applet;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Dialog;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.TextArea;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import java.awt.print.PageFormat;
+import java.awt.print.PrinterJob;
+
+public class PrinterDialogsModalityTest extends Applet
+{
+    //Declare things used in the test, like buttons and labels here
+
+    public void init()
+    {
+        //Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+        this.setLayout (new BorderLayout ());
+
+        String[] instructions =
+        {
+            "This is a Windows only test, for other platforms consider it passed",
+            "After test start you will see frame titled \"test Frame\"",
+            "with two buttons - \"Page Dialog\" and \"Print Dialog\"",
+            "1. make the frame active by clicking on title",
+            "2. press \"Page Dialog\" button, page dailog should popup",
+            "3. make sure page dialog is modal (if not test is failed)",
+            "4. close the dialog (either cancel it or press ok)",
+            "5. make sure the frame is still active (if not test is failed)",
+            "6. press \"Print Dialog\" button, print dialog should popup",
+            "7. repeat steps 3.-5.",
+            "",
+            "If you are able to execute all steps successfully then test is passed, else failed."
+        };
+        Sysout.createDialogWithInstructions( instructions );
+
+    }//End  init()
+
+    public void start ()
+    {
+        //Get things going.  Request focus, set size, et cetera
+        setSize (200,200);
+        setVisible(true);
+        validate();
+
+        Button page = new Button("Page Dialog");
+        page.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    PrinterJob prnJob = PrinterJob.getPrinterJob();
+                    prnJob.pageDialog(new PageFormat());
+                }
+            });
+        Button print = new Button("Print Dialog");
+        print.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    PrinterJob prnJob = PrinterJob.getPrinterJob();
+                    prnJob.printDialog();
+                }
+            });
+        Frame frame = new Frame("Test Frame");
+        frame.setLayout(new FlowLayout());
+        frame.add(page);
+        frame.add(print);
+        frame.setLocation(200, 200);
+        frame.pack();
+        frame.setVisible(true);
+
+    }// start()
+
+    //The rest of this class is the actions which perform the test...
+
+    //Use Sysout.println to communicate with the user NOT System.out!!
+    //Sysout.println ("Something Happened!");
+
+}// class PrinterDialogsModalityTest
+
+/* Place other classes related to the test after this line */
+
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrinterJobDialogBugDemo.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4775862
+ * @run main/manual PrinterJobDialogBugDemo
+ */
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.SwingConstants;
+
+public class PrinterJobDialogBugDemo extends JFrame implements Printable {
+
+  public static void main(String[] args) {
+    new PrinterJobDialogBugDemo();
+  }
+
+  private PrinterJobDialogBugDemo() {
+    super("Printer Job Dialog Bug Demo");
+
+    setDefaultCloseOperation(EXIT_ON_CLOSE);
+    setSize(700,700);
+
+    JButton btnPrint = new JButton("Print...");
+    btnPrint.addActionListener(new ActionListener()
+      {
+        public void actionPerformed(ActionEvent ae) {
+          showPrintDialog();
+        }
+      });
+
+    Container contentPane = getContentPane();
+    contentPane.add(
+      new JLabel("<html>This is the main Application Window. " +
+                 "To demonstrate the problem:" +
+                 "<ol>" +
+                 "<li>Click the Print button at the bottom of this window. " +
+                 "The Print dialog will appear." +
+                 "<li>Select another application window." +
+                 "<li>On the Windows taskbar, click the coffee-cup icon for " +
+                 "this demo application.  This brings this window to the " +
+                 "front but the Print dialog remains hidden. " +
+                 "Since this window " +
+                 "is no longer selectable, it can't be moved aside to expose "
++
+                 "the Print dialog that is now behind it." +
+                 "</ol>",
+                 SwingConstants.CENTER),
+      BorderLayout.NORTH);
+    contentPane.add(btnPrint, BorderLayout.SOUTH);
+    setVisible(true);
+  }
+
+  private void showPrintDialog() {
+    PrinterJob printJob = PrinterJob.getPrinterJob();
+    printJob.setPrintable(this);
+    PrintRequestAttributeSet printRequestAttrSet =
+      new HashPrintRequestAttributeSet();
+    printJob.printDialog(printRequestAttrSet);
+  }
+
+  public int print(java.awt.Graphics g, java.awt.print.PageFormat pageFormat,
+int pageIndex) {
+    if (pageIndex == 0) {
+      return(PAGE_EXISTS);
+    } else {
+      return(NO_SUCH_PAGE);
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/RemoveListener.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test 1.1 01/05/17
+ * @bug 4459889
+ * @summary No NullPointerException should occur.
+ * @run main RemoveListener
+*/
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.event.*;
+import javax.print.attribute.standard.*;
+
+public class RemoveListener {
+    public static void main(String[] args){
+        PrintService[] pservices = PrintServiceLookup.lookupPrintServices(null, null);
+        if (pservices.length == 0){
+            return;
+        }
+        DocPrintJob pj = pservices[0].createPrintJob();
+        PrintJobAttributeSet aset = new HashPrintJobAttributeSet();
+        aset.add(JobState.PROCESSING);
+        PrintJobAttributeListener listener = new PJAListener();
+        pj.addPrintJobAttributeListener(listener, aset);
+        pj.removePrintJobAttributeListener(listener);
+        return;
+    }
+}
+
+class PJAListener implements PrintJobAttributeListener {
+    public void attributeUpdate(PrintJobAttributeEvent pjae){
+        return;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/ScaledText/ScaledText.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,438 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 4291373
+  @summary  Printing of scaled text is wrong / disappearing
+  @author prr: area=PrinterJob
+  @run main/manual ScaledText
+*/
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+
+
+public class ScaledText implements Printable {
+
+   private Image opaqueimg,transimg;
+
+   private static void init() {
+
+        //*** Create instructions for the user here ***
+
+        String[] instructions = {
+         "On-screen inspection is not possible for this printing-specific",
+         "test therefore its only output is two printed pages.",
+         "To be able to run this test it is required to have a default",
+         "printer configured in your user environment.",
+         "",
+         "Visual inspection of the printed pages is needed. A passing",
+         "test will print a page on which 6 lines of text will be",
+         "printed, all of the same size. The test fails only if the sizes",
+         "are different, or not all of the sizes labelled 1.0, 2.0, 4.0",
+         "8.0, 16.0, 32.0 appear."
+       };
+
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+        PrinterJob pjob = PrinterJob.getPrinterJob();
+
+        Book book = new Book();
+
+        PageFormat portrait = pjob.defaultPage();
+        book.append(new ScaledText(),portrait);
+
+        pjob.setPageable(book);
+
+        if (pjob.printDialog()) {
+            try {
+                pjob.print();
+            } catch (PrinterException e) {
+                System.err.println(e);
+                e.printStackTrace();
+            }
+        }
+        System.out.println("Done Printing");
+
+    }//End  init()
+
+
+  public ScaledText() {
+  }
+
+  public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+
+       Graphics2D g2D = (Graphics2D) g;
+       g2D.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+
+       g2D.setColor(Color.black);
+       Font font = new Font("serif", Font.PLAIN, 1);
+
+       float scale;
+       float x;
+       float y;
+
+       scale = 1.0f;
+       x     = 3.0f;
+       y     = 3.0f;
+       printScale(g2D, font, scale, x, y);
+
+       scale = 2.0f;
+       x     = 3.0f;
+       y     = 3.5f;
+       printScale(g2D, font, scale, x, y);
+
+       scale = 4.0f;
+       x     = 3.0f;
+       y     = 4.0f;
+       printScale(g2D, font, scale, x, y);
+
+       scale = 8.0f;
+       x     = 3.0f;
+       y     = 4.5f;
+       printScale(g2D, font, scale, x, y);
+
+       scale = 16.0f;
+       x     = 3.0f;
+       y     = 5.0f;
+       printScale(g2D, font, scale, x, y);
+
+       scale = 32.0f;
+       x     = 3.0f;
+       y     = 5.5f;
+       printScale(g2D, font, scale, x, y);
+
+       return Printable.PAGE_EXISTS;
+  }
+
+  /**
+   * The graphics is scaled and the font and the positions
+   * are reduced in respect to the scaling, so that all
+   * printing should be the same.
+   *
+   * @param g2D     graphics2D to paint on
+   * @param font    font to paint
+   * @param scale   scale for the painting
+   * @param x       x position
+   * @param y       y position
+   */
+  private void printScale(Graphics2D g2D, Font font,
+                           float scale, float x, float y) {
+
+    int RES = 72;
+
+    g2D.scale(scale, scale);
+
+    g2D.setFont   (font.deriveFont(10.0f / scale));
+    g2D.drawString("This text is scaled by a factor of " + scale,
+                   x * RES / scale, y * RES / scale);
+
+    g2D.scale(1/scale, 1/scale);
+
+}
+
+   /*****************************************************
+     Standard Test Machinery Section
+      DO NOT modify anything in this section -- it's a
+      standard chunk of code which has all of the
+      synchronisation necessary for the test harness.
+      By keeping it the same in all tests, it is easier
+      to read and understand someone else's test, as
+      well as insuring that all tests behave correctly
+      with the test harness.
+     There is a section following this for test-defined
+      classes
+   ******************************************************/
+   private static boolean theTestPassed = false;
+   private static boolean testGeneratedInterrupt = false;
+   private static String failureMessage = "";
+
+   private static Thread mainThread = null;
+
+   private static int sleepTime = 300000;
+
+   public static void main( String args[] ) throws InterruptedException
+    {
+      mainThread = Thread.currentThread();
+      try
+       {
+         init();
+       }
+      catch( TestPassedException e )
+       {
+         //The test passed, so just return from main and harness will
+         // interepret this return as a pass
+         return;
+       }
+      //At this point, neither test passed nor test failed has been
+      // called -- either would have thrown an exception and ended the
+      // test, so we know we have multiple threads.
+
+      //Test involves other threads, so sleep and wait for them to
+      // called pass() or fail()
+      try
+       {
+         Thread.sleep( sleepTime );
+         //Timed out, so fail the test
+         throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+       }
+      catch (InterruptedException e)
+       {
+         if( ! testGeneratedInterrupt ) throw e;
+
+         //reset flag in case hit this code more than once for some reason (just safety)
+         testGeneratedInterrupt = false;
+         if ( theTestPassed == false )
+          {
+            throw new RuntimeException( failureMessage );
+          }
+       }
+
+    }//main
+
+   public static synchronized void setTimeoutTo( int seconds )
+    {
+      sleepTime = seconds * 1000;
+    }
+
+   public static synchronized void pass()
+    {
+      Sysout.println( "The test passed." );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //first check if this is executing in main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //Still in the main thread, so set the flag just for kicks,
+         // and throw a test passed exception which will be caught
+         // and end the test.
+         theTestPassed = true;
+         throw new TestPassedException();
+       }
+      //pass was called from a different thread, so set the flag and interrupt
+      // the main thead.
+      theTestPassed = true;
+      testGeneratedInterrupt = true;
+      mainThread.interrupt();
+    }//pass()
+
+   public static synchronized void fail()
+    {
+      //test writer didn't specify why test failed, s     fail( "it just plain failed! :-)" );
+    }
+
+   public static synchronized void fail( String whyFailed )
+    {
+      Sysout.println( "The test failed: " + whyFailed );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //check if this called from main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //If main thread, fail now 'cause not sleeping
+         throw new RuntimeException( whyFailed );
+       }
+      theTestPassed = false;
+      testGeneratedInterrupt = true;
+      failureMessage = whyFailed;
+      mainThread.interrupt();
+    }//fail()
+
+}// class ScaledText
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+ {
+ }
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog implements ActionListener {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+   Panel  buttonP = new Panel();
+   Button passB = new Button( "pass" );
+   Button failB = new Button( "fail" );
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      passB = new Button( "pass" );
+      passB.setActionCommand( "pass" );
+      passB.addActionListener( this );
+      buttonP.add( "East", passB );
+
+      failB = new Button( "fail" );
+      failB.setActionCommand( "fail" );
+      failB.addActionListener( this );
+      buttonP.add( "West", failB );
+
+      add( "South", buttonP );
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+   //catch presses of the passed and failed buttons.
+   //simply call the standard pass() or fail() static methods of
+   //ScaledText
+   public void actionPerformed( ActionEvent e )
+    {
+      if( e.getActionCommand() == "pass" )
+       {
+         ScaledText.pass();
+       }
+      else
+       {
+         ScaledText.fail();
+       }
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/SecurityDialogTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4937672 5100706 6252456
+ * @run main/manual SecurityDialogTest
+ */
+
+import java.awt.* ;
+import java.awt.print.* ;
+import java.io.*;
+import java.security.*;
+import javax.print.*;
+import javax.print.attribute.*;
+
+public class SecurityDialogTest {
+
+
+    public static void main ( String args[] ) {
+
+        String[] instructions =
+           {
+            "You must have a printer available to perform this test.",
+            "This test brings up a native and cross-platform page and",
+            "print dialogs.",
+            "The dialogs should be displayed even when ",
+            "there is no queuePrintJob permission.",
+            "If the dialog has an option to save to file, the option ought",
+            "to be disabled if there is no read/write file permission.",
+            "You should test this by trying different policy files."
+          };
+
+         Sysout.createDialog( );
+         Sysout.printInstructions( instructions );
+
+        SecurityDialogTest pjc = new SecurityDialogTest() ;
+    }
+
+
+  public SecurityDialogTest() {
+
+      PrinterJob pj = PrinterJob.getPrinterJob() ;
+
+      // Install a security manager which does not allow reading and
+      // writing of files.
+      //PrintTestSecurityManager ptsm = new PrintTestSecurityManager();
+      SecurityManager ptsm = new SecurityManager();
+
+      try {
+          System.setSecurityManager(ptsm);
+      } catch (SecurityException e) {
+          System.out.println("Could not run test - security exception");
+      }
+
+      try {
+          PrintJob pjob = Toolkit.getDefaultToolkit().getPrintJob(new Frame(), "Printing", null, null);
+          Sysout.println("If the value of pjob is null, the test fails.\n");
+          Sysout.println("        pjob = "+pjob);
+      } catch (SecurityException e) {
+      }
+
+      PrintService[] services = PrinterJob.lookupPrintServices();
+      for (int i=0; i<services.length; i++) {
+          System.out.println("SecurityDialogTest service "+i+" : "+services[i]);
+      }
+
+      PrintService defservice = pj.getPrintService();
+      System.out.println("SecurityDialogTest default service : "+defservice);
+
+      System.out.println("SecurityDialogTest native PageDialog ");
+      PageFormat pf1 = pj.pageDialog(new PageFormat());
+
+      System.out.println("SecurityDialogTest swing PageDialog ");
+      PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
+      PageFormat pf2 = pj.pageDialog(attributes);
+
+      // With the security manager installed, save to file should now
+      // be denied.
+      System.out.println("SecurityDialogTest native printDialog ");
+      pj.printDialog();
+
+      System.out.println("SecurityDialogTest swing printDialog ");
+      pj.printDialog(attributes);
+  }
+
+
+    class PrintTestSecurityManager extends SecurityManager {
+        public void checkPackageAccess(String pkg) {
+        }
+        public void checkPropertyAccess(String key) {
+        }
+
+    }
+
+}
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/SetCopies/Test.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4694495
+ * @summary Check that the dialog shows copies = 3.
+ * @run main/manual Test
+ */
+import java.awt.print.*;
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class Test {
+        static public void main(String args[]) {
+                DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
+                PrintRequestAttributeSet aSet
+                    = new HashPrintRequestAttributeSet();
+                PrintService[] services
+                    = PrintServiceLookup.lookupPrintServices(flavor, aSet);
+
+                PrinterJob pj = PrinterJob.getPrinterJob();
+
+                for (int i=0; i<services.length; i++)
+                    System.out.println(services[i].getName());
+                try { pj.setPrintService(services[services.length-1]); }
+                catch (Exception e) { e.printStackTrace(); }
+                pj.setCopies(3);
+                pj.printDialog();
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/SwingUIText.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6488219 6560738 7158350 8017469
+ * @summary Test that text printed in Swing UI measures and looks OK.
+ * @run main/manual=yesno PrintTextTest
+ */
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.print.*;
+
+public class SwingUIText implements Printable {
+
+    static String[] instructions = {
+        "This tests that when a Swing UI is printed, that the text",
+        "in each component properly matches the length of the component",
+        "as seen on-screen, and that the spacing of the text is of",
+        "reasonable even-ness. This latter part is very subjective and",
+        "the comparison has to be with JDK1.5 GA, or JDK 1.6 GA",
+    };
+
+    static JFrame frame;
+
+    public static void main(String args[]) {
+        SwingUtilities.invokeLater(new Runnable() {
+          public void run() {
+              createUI();
+          }
+      });
+    }
+
+    public static void createUI() {
+
+        Sysout.createDialogWithInstructions(instructions);
+
+        JPanel panel = new JPanel();
+        panel.setLayout(new GridLayout(4,1));
+
+        String text = "marvelous suspicious solving";
+        displayText(panel, text);
+
+        String itext = "\u0641\u0642\u0643 \u0644\u0627\u064b";
+        itext = itext+itext+itext+itext+itext+itext+itext;
+        displayText(panel, itext);
+
+        String itext2 = "\u0641"+text;
+        displayText(panel, itext2);
+
+        JEditorPane editor = new JEditorPane();
+        editor.setContentType("text/html");
+        String CELL = "<TD align=\"center\"><font style=\"font-size: 18;\">Text</font></TD>";
+        String TABLE_BEGIN = "<TABLE BORDER=1 cellpadding=1 cellspacing=0 width=100%>";
+        String TABLE_END = "</TABLE>";
+        StringBuffer buffer = new StringBuffer();
+        buffer.append("<html><body>").append(TABLE_BEGIN);
+        for (int j = 0; j < 15; j++) {
+            buffer.append(CELL);
+        }
+        buffer.append("</tr>");
+        buffer.append(TABLE_END).append("</body></html>");
+        editor.setText(buffer.toString());
+
+        panel.add(editor);
+
+        frame = new JFrame("Swing UI Text Printing Test");
+        frame.getContentPane().add(panel);
+        frame.pack();
+        frame.setVisible(true);
+
+        PrinterJob job = PrinterJob.getPrinterJob();
+        PageFormat pf = job.defaultPage();
+        job.setPrintable(new SwingUIText(), pf);
+        if (job.printDialog()) {
+            try { job.print(); }
+            catch (Exception e) {
+              e.printStackTrace();
+              throw new RuntimeException(e);
+            }
+        }
+    }
+
+
+    static void displayText(JPanel p, String text) {
+        JPanel panel = new JPanel();
+        panel.setLayout(new GridLayout(2,1));
+        JPanel row = new JPanel();
+        Font font = new Font("Dialog", Font.PLAIN, 12);
+
+        JLabel label = new JLabel(text);
+        label.setFont(font);
+        row.add(label);
+
+        JButton button = new JButton("Print "+text);
+        button.setMnemonic('P');
+        button.setFont(font);
+        row.add(button);
+
+        panel.add(row);
+
+        row = new JPanel();
+        JTextField textField = new JTextField(text);
+        row.add(textField);
+
+        JTextArea textArea = new JTextArea();
+        textArea.setText(text);
+        row.add(textArea);
+
+        panel.add(row);
+        p.add(panel);
+    }
+
+    public int print(Graphics g, PageFormat pf, int pageIndex)
+        throws PrinterException {
+
+        if (pageIndex >= 1) {
+            return Printable.NO_SUCH_PAGE;
+        }
+        g.translate((int)pf.getImageableX(), (int)pf.getImageableY());
+        frame.printAll(g);
+
+        return Printable.PAGE_EXISTS;
+    }
+
+}
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 10, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("South", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+     //chop up each into pieces maxSringLength long
+     remainingStr = instructions[ i ];
+     while( remainingStr.length() > 0 )
+      {
+        //if longer than max then chop off first max chars to print
+        if( remainingStr.length() >= maxStringLength )
+         {
+           //Try to chop on a word boundary
+           int posOfSpace = remainingStr.
+          lastIndexOf( ' ', maxStringLength - 1 );
+
+           if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+           printStr = remainingStr.substring( 0, posOfSpace + 1 );
+           remainingStr = remainingStr.substring( posOfSpace + 1 );
+         }
+        //else just print
+        else
+         {
+           printStr = remainingStr;
+           remainingStr = "";
+         }
+
+            instructionsText.append( printStr + "\n" );
+
+      }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/ThinLines.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,429 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 4190081
+  @summary  Confirm that the you see "Z" shapes on the printed page.
+  @author prr/rbi: area=PrinterJob
+  @run main/manual ThinLines
+*/
+
+
+//*** global search and replace ThinLines with name of the test ***
+
+/**
+ * ThinLines.java
+ *
+ * summary:
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+
+// This test is a "main" test as applets would need Runtime permission
+// "queuePrintJob".
+
+public class ThinLines implements Printable {
+
+   private static final int INCH = 72;
+
+   private static void init()
+    {
+      //*** Create instructions for the user here ***
+
+      String[] instructions =
+       {
+         "On-screen inspection is not possible for this printing-specific",
+         "test therefore its only output is a printed page.",
+         "To be able to run this test it is required to have a default",
+         "printer configured in your user environment.",
+         "",
+         "Visual inspection of the printed page is needed. A passing",
+         "test will print a large \"Z\" shape which is repeated 6 times.",
+         "The top-most and diagonal lines of each \"Z\" are thin lines.",
+         "The bottom line of each \"Z\" is a thicker line.",
+         "In a failing test, the thin lines do not appear."
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+      PrinterJob pjob = PrinterJob.getPrinterJob();
+      PageFormat pf = pjob.defaultPage();
+      Book book = new Book();
+
+      book.append(new ThinLines(), pf);
+      pjob.setPageable(book);
+
+      try {
+          pjob.print();
+      } catch (PrinterException e) {
+          e.printStackTrace();
+      }
+
+    }//End  init()
+
+    public int print(Graphics g, PageFormat pf, int pageIndex) {
+        Graphics2D g2d = (Graphics2D) g;
+        g2d.translate(pf.getImageableX(), pf.getImageableY());
+
+        g2d.setColor(Color.black);
+        Stroke thinLine = new BasicStroke(0.01f);
+        Stroke thickLine = new BasicStroke(1.0f);
+
+
+        for (int y = 100; y < 900; y += 100) {
+            g2d.setStroke(thinLine);
+            g2d.drawLine(INCH, y, INCH * 3, y);
+            g2d.drawLine(INCH * 3, y, INCH, y + INCH/2);
+            g2d.setStroke(thickLine);
+            g2d.drawLine(INCH, y + INCH/2, INCH * 3, y + INCH/2);
+        }
+
+        return PAGE_EXISTS;
+    }
+
+
+
+   /*****************************************************
+     Standard Test Machinery Section
+      DO NOT modify anything in this section -- it's a
+      standard chunk of code which has all of the
+      synchronisation necessary for the test harness.
+      By keeping it the same in all tests, it is easier
+      to read and understand someone else's test, as
+      well as insuring that all tests behave correctly
+      with the test harness.
+     There is a section following this for test-defined
+      classes
+   ******************************************************/
+   private static boolean theTestPassed = false;
+   private static boolean testGeneratedInterrupt = false;
+   private static String failureMessage = "";
+
+   private static Thread mainThread = null;
+
+   private static int sleepTime = 300000;
+
+   public static void main( String args[] ) throws InterruptedException
+    {
+      mainThread = Thread.currentThread();
+      try
+       {
+         init();
+       }
+      catch( TestPassedException e )
+       {
+         //The test passed, so just return from main and harness will
+         // interepret this return as a pass
+         return;
+       }
+      //At this point, neither test passed nor test failed has been
+      // called -- either would have thrown an exception and ended the
+      // test, so we know we have multiple threads.
+
+      //Test involves other threads, so sleep and wait for them to
+      // called pass() or fail()
+      try
+       {
+         Thread.sleep( sleepTime );
+         //Timed out, so fail the test
+         throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+       }
+      catch (InterruptedException e)
+       {
+         if( ! testGeneratedInterrupt ) throw e;
+
+         //reset flag in case hit this code more than once for some reason (just safety)
+         testGeneratedInterrupt = false;
+         if ( theTestPassed == false )
+          {
+            throw new RuntimeException( failureMessage );
+          }
+       }
+
+    }//main
+
+   public static synchronized void setTimeoutTo( int seconds )
+    {
+      sleepTime = seconds * 1000;
+    }
+
+   public static synchronized void pass()
+    {
+      Sysout.println( "The test passed." );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //first check if this is executing in main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //Still in the main thread, so set the flag just for kicks,
+         // and throw a test passed exception which will be caught
+         // and end the test.
+         theTestPassed = true;
+         throw new TestPassedException();
+       }
+      //pass was called from a different thread, so set the flag and interrupt
+      // the main thead.
+      theTestPassed = true;
+      testGeneratedInterrupt = true;
+      mainThread.interrupt();
+    }//pass()
+
+   public static synchronized void fail()
+    {
+      //test writer didn't specify why test failed, so give generic
+      fail( "it just plain failed! :-)" );
+    }
+
+   public static synchronized void fail( String whyFailed )
+    {
+      Sysout.println( "The test failed: " + whyFailed );
+      Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
+      //check if this called from main thread
+      if ( mainThread == Thread.currentThread() )
+       {
+         //If main thread, fail now 'cause not sleeping
+         throw new RuntimeException( whyFailed );
+       }
+      theTestPassed = false;
+      testGeneratedInterrupt = true;
+      failureMessage = whyFailed;
+      mainThread.interrupt();
+    }//fail()
+
+ }// class ThinLines
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+ {
+ }
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// make listeners in a class defined here, and instantiate them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+   static int newVar = 0;
+
+   public void eventDispatched(AWTEvent e)
+    {
+      //Counting events to see if we get enough
+      eventCount++;
+
+      if( eventCount == 20 )
+       {
+         //got enough events, so pass
+
+         ThinLines.pass();
+       }
+      else if( tries == 20 )
+       {
+         //tried too many times without getting enough events so fail
+
+         ThinLines.fail();
+       }
+
+    }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog implements ActionListener
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+   Panel  buttonP = new Panel();
+   Button passB = new Button( "pass" );
+   Button failB = new Button( "fail" );
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      passB = new Button( "pass" );
+      passB.setActionCommand( "pass" );
+      passB.addActionListener( this );
+      buttonP.add( "East", passB );
+
+      failB = new Button( "fail" );
+      failB.setActionCommand( "fail" );
+      failB.addActionListener( this );
+      buttonP.add( "West", failB );
+
+      add( "South", buttonP );
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+   //catch presses of the passed and failed buttons.
+   //simply call the standard pass() or fail() static methods of
+   //ThinLines
+   public void actionPerformed( ActionEvent e )
+    {
+      if( e.getActionCommand() == "pass" )
+       {
+         ThinLines.pass();
+       }
+      else
+       {
+         ThinLines.fail();
+       }
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/XparColor.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @bug 4179262
+ * @summary Confirm that transparent colors are printed correctly. The
+ * printout should show transparent rings with increasing darkness toward
+ * the center.
+ *@run applet/manual=yesno XparColor.html
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.print.*;
+import java.awt.event.*;
+import java.awt.geom.Ellipse2D;
+
+
+/**
+ * Creating colors with an alpha value.
+ */
+public class XparColor extends Applet implements Printable {
+
+   public void init() {
+        String[] instructions =
+        {
+            "This test verify that the BullsEye rings are printed correctly. The printout should show transparent rings with increasing darkness toward the center"
+        };
+        Sysout.createDialogWithInstructions( instructions );
+   }
+
+    public XparColor() {
+        PrinterJob printJob = PrinterJob.getPrinterJob();
+        printJob.setPrintable(this);
+        if (printJob.printDialog()) {
+            try {
+                printJob.print();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
+    }
+
+
+    public static void main(String s[]) {
+        XparColor xc = new XparColor();
+        PrinterJob printJob = PrinterJob.getPrinterJob();
+        printJob.setPrintable(xc);
+        if (printJob.printDialog()) {
+            try {
+                printJob.print();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
+    }
+
+    public int print(Graphics g, PageFormat pf, int pi)
+        throws PrinterException {
+        if (pi >= 1) {
+            return Printable.NO_SUCH_PAGE;
+        }
+
+        Graphics2D g2d = (Graphics2D) g;
+        g2d.translate(pf.getImageableX(), pf.getImageableY());
+        g2d.translate(pf.getImageableWidth() / 2,
+                      pf.getImageableHeight() / 2);
+
+        Dimension d = new Dimension(400, 400);
+
+        double scale = Math.min(pf.getImageableWidth() / d.width,
+                                pf.getImageableHeight() / d.height);
+        if (scale < 1.0) {
+            g2d.scale(scale, scale);
+        }
+
+        g2d.translate(-d.width / 2.0, -d.height / 2.0);
+
+        Graphics2D g2 = (Graphics2D)g;
+        drawDemo(d.width, d.height, g2);
+        g2.dispose();
+
+        return Printable.PAGE_EXISTS;
+    }
+
+    public void drawDemo(int w, int h, Graphics2D g2) {
+
+        Color reds[] = { Color.red.darker(), Color.red };
+        for (int N = 0; N < 18; N++) {
+            float i = (N + 2) / 2.0f;
+            float x = (float) (5+i*(w/2/10));
+            float y = (float) (5+i*(h/2/10));
+            float ew = (w-10)-(i*w/10);
+            float eh = (h-10)-(i*h/10);
+            float alpha = (N == 0) ? 0.1f : 1.0f / (19.0f - N);
+            if ( N >= 16 )
+                g2.setColor(reds[N-16]);
+            else
+                g2.setColor(new Color(0f, 0f, 0f, alpha));
+            g2.fill(new Ellipse2D.Float(x,y,ew,eh));
+        }
+    }
+}
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("South", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/raster/RasterTest.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4242639
+ * @summary Printing quality problem on Canon and NEC
+ * @author prr
+ * @run main/manual RasterTest
+ */
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import java.awt.Toolkit;
+import java.awt.image.BufferedImage;
+
+
+public class RasterTest extends Frame implements ActionListener {
+
+ private RasterCanvas c;
+
+ public static void main(String args[]) {
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "This test uses rendering operations which force the implementation",
+         "to print the page as a raster",
+         "You should see two square images, the 1st containing overlapping",
+         "composited squares, the lower image shows a gradient paint.",
+         "The printed output should match the on-screen display, although",
+         "only colour printers will be able to accurately reproduce the",
+         "subtle color changes."
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+    RasterTest f = new RasterTest();
+    f.show();
+ }
+
+ public RasterTest() {
+        super("Java 2D Raster Printing");
+
+    c = new RasterCanvas();
+    add("Center", c);
+
+    Button printButton = new Button("Print");
+    printButton.addActionListener(this);
+    add("South", printButton);
+
+    addWindowListener(new WindowAdapter() {
+       public void windowClosing(WindowEvent e) {
+             System.exit(0);
+            }
+    });
+
+    pack();
+
+        setBackground(Color.white);
+
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+   PrinterJob pj = PrinterJob.getPrinterJob();
+
+   if (pj != null && pj.printDialog()) {
+       pj.setPrintable(c);
+       try {
+            pj.print();
+      } catch (PrinterException pe) {
+      } finally {
+         System.err.println("PRINT RETURNED");
+      }
+   }
+}
+
+
+ class RasterCanvas extends Canvas implements Printable {
+
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+      if (pgIndex > 0)
+         return Printable.NO_SUCH_PAGE;
+
+         Graphics2D g2d= (Graphics2D)g;
+         g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+         doPaint(g2d);
+      return Printable.PAGE_EXISTS;
+    }
+
+    public void paint(Graphics g) {
+       doPaint(g);
+    }
+
+    public void paintComponent(Graphics g) {
+       doPaint(g);
+    }
+
+    public void doPaint(Graphics g) {
+        Graphics2D g2 = (Graphics2D)g;
+
+        g2.setColor(Color.black);
+
+        BufferedImage bimg = new BufferedImage(200, 200,
+                                                 BufferedImage.TYPE_INT_ARGB);
+        Graphics ig = bimg.getGraphics();
+        Color alphared = new Color(255, 0, 0, 128);
+        Color alphagreen = new Color(0, 255, 0, 128);
+        Color alphablue = new Color(0, 0, 255, 128);
+        ig.setColor(alphared);
+        ig.fillRect(0,0,200,200);
+        ig.setColor(alphagreen);
+        ig.fillRect(25,25,150,150);
+        ig.setColor(alphablue);
+        ig.fillRect(75,75,125,125);
+        g.drawImage(bimg, 10, 25, this);
+
+        GradientPaint gp =
+         new GradientPaint(10.0f, 10.0f, alphablue, 210.0f, 210.0f, alphared, true);
+        g2.setPaint(gp);
+        g2.fillRect(10, 240, 200, 200);
+
+     }
+
+    public Dimension getPreferredSize() {
+        return new Dimension(500, 500);
+    }
+
+ }
+
+}
+
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/Test8039776.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.Set;
+import java.util.SortedSet;
+
+import static java.beans.Introspector.getBeanInfo;
+
+/*
+ * @test
+ * @bug 8039776
+ * @summary Tests that Introspector does not throw NPE
+ * @author Sergey Malenkov
+ */
+
+public class Test8039776 {
+    public static void main(String[] args) throws Exception {
+        getBeanInfo(Base.class, Object.class);
+        getBeanInfo(Child.class, Base.class);
+        getBeanInfo(Child.class, Object.class);
+    }
+
+    public static class Base {
+        private SortedSet<Object> value;
+
+        public Set<Object> getValue() {
+            return this.value;
+        }
+
+        public void setValue(SortedSet<Object> value) {
+            this.value = value;
+        }
+    }
+
+    public static class Child extends Base {
+        public Set<Object> getValue() {
+            return super.getValue();
+        }
+
+        public void setValue(SortedSet<Object> items) {
+            super.setValue(items);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/TestCacheRecursion.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import com.sun.beans.util.Cache;
+
+/*
+ * @test
+ * @bug 8039137
+ * @summary Tests Cache recursion
+ * @author Sergey Malenkov
+ * @compile -XDignore.symbol.file TestCacheRecursion.java
+ * @run main TestCacheRecursion
+ */
+
+public class TestCacheRecursion {
+    private static boolean ERROR;
+    private static final Cache<Class<?>,Boolean> CACHE
+            = new Cache<Class<?>,Boolean>(Cache.Kind.WEAK, Cache.Kind.STRONG) {
+        @Override
+        public Boolean create(Class<?> type) {
+            if (ERROR) {
+                throw new Error("not initialized");
+            }
+            type = type.getSuperclass();
+            return (type != null) && get(type);
+        }
+    };
+
+    public static void main(String[] args) {
+        CACHE.get(Z.class);
+        ERROR = true;
+        for (Class<?> type = Z.class; type != null; type = type.getSuperclass()) {
+            CACHE.get(type);
+        }
+    }
+
+    private class A {}
+    private class B extends A {}
+    private class C extends B {}
+    private class D extends C {}
+    private class E extends D {}
+    private class F extends E {}
+    private class G extends F {}
+    private class H extends G {}
+    private class I extends H {}
+    private class J extends I {}
+    private class K extends J {}
+    private class L extends K {}
+    private class M extends L {}
+    private class N extends M {}
+    private class O extends N {}
+    private class P extends O {}
+    private class Q extends P {}
+    private class R extends Q {}
+    private class S extends R {}
+    private class T extends S {}
+    private class U extends T {}
+    private class V extends U {}
+    private class W extends V {}
+    private class X extends W {}
+    private class Y extends X {}
+    private class Z extends Y {}
+}
--- a/test/java/math/BigInteger/BitLengthOverflow.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/java/math/BigInteger/BitLengthOverflow.java	Thu May 01 14:21:29 2014 -0700
@@ -41,6 +41,10 @@
         } catch (ArithmeticException e) {
             // expected
             System.out.println("Overflow is reported by ArithmeticException, as expected");
+        } catch (OutOfMemoryError e) {
+            // possible
+            System.err.println("BitLengthOverflow skipped: OutOfMemoryError");
+            System.err.println("Run jtreg with -javaoption:-Xmx8g");
         }
     }
 }
--- a/test/java/math/BigInteger/DoubleValueOverflow.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/java/math/BigInteger/DoubleValueOverflow.java	Thu May 01 14:21:29 2014 -0700
@@ -41,6 +41,10 @@
         } catch (ArithmeticException e) {
             // expected
             System.out.println("Overflow is reported by ArithmeticException, as expected");
+        } catch (OutOfMemoryError e) {
+            // possible
+            System.err.println("DoubleValueOverflow skipped: OutOfMemoryError");
+            System.err.println("Run jtreg with -javaoption:-Xmx8g");
         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/net/Inet4Address/DummyNameService.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * A simple name service which throws an exception when invoked
+ */
+
+import java.net.UnknownHostException;
+import java.net.InetAddress;
+import sun.net.spi.nameservice.*;
+import java.util.*;
+
+public final class DummyNameService implements NameService {
+
+    public DummyNameService() throws Exception {
+    }
+
+    public InetAddress[] lookupAllHostAddr(String host) throws UnknownHostException {
+        throw new UnknownHostException("Dummy name service");
+    }
+
+    public String getHostByAddr(byte[] addr) throws UnknownHostException {
+        throw new UnknownHostException("Dummy name service");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/net/Inet4Address/DummyNameServiceDescriptor.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Descriptor for the dummy name service
+ */
+
+import sun.net.spi.nameservice.*;
+
+public final class DummyNameServiceDescriptor implements NameServiceDescriptor {
+
+    /**
+     * Create a new instance of the corresponding name service.
+     */
+    public NameService createNameService() throws Exception {
+        return new DummyNameService();
+    }
+
+    /**
+     * Returns this service provider's name
+     *
+     */
+    public String getProviderName() {
+        return "oracle";
+    }
+
+    /**
+     * Returns this name service type
+     * "dns" "nis" etc
+     */
+    public String getType() {
+        return "dummy";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/net/Inet4Address/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,22 @@
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+
+DummyNameServiceDescriptor    # name service provider descriptor
--- a/test/java/net/Inet4Address/textToNumericFormat.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/java/net/Inet4Address/textToNumericFormat.java	Thu May 01 14:21:29 2014 -0700
@@ -25,8 +25,18 @@
  * @test
  * @bug 4749938
  * @summary Bug in the parsing IPv4 literal addresses
+ * @compile -XDignore.symbol.file=true DummyNameService.java DummyNameServiceDescriptor.java
+ * @run main/othervm -Dsun.net.spi.nameservice.provider.1=dummy,oracle textToNumericFormat
 */
 
+/**
+ * We use a dummy name service which throws UHE any time it is called.
+ * We do this because the "good" tests here should parse correctly
+ * without needing to call the name service, and the bad tests will
+ * not parse and then invoke the name service, where we expect
+ * the exception.
+ */
+
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.*;
--- a/test/java/util/Arrays/Correct.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/java/util/Arrays/Correct.java	Thu May 01 14:21:29 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,44 +23,49 @@
 
 /*
  * @test
- * @bug 4726380
+ * @bug 4726380 8037097
  * @summary Check that different sorts give equivalent results.
+ * @run testng Correct
  */
 
 import java.util.*;
 
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+import static org.testng.Assert.fail;
+import static org.testng.Assert.assertEquals;
+
 public class Correct {
 
-    static Random rnd = new Random();
+    static final Random rnd = new Random();
     static final int ITERATIONS = 1000;
     static final int TEST_SIZE = 1000;
 
-    public static void main(String[] args) throws Exception {
-        Object[] array1 = null;
-        Object[] array2 = null;
-
+    @Test
+    public void testDefaultSort() {
         for (int i=0; i<ITERATIONS; i++) {
             int size = rnd.nextInt(TEST_SIZE) + 1;
-            array1 = (Object[])getIntegerArray(size);
-            array2 = (Object[])array1.clone();
+            Integer[] array1 = getIntegerArray(size);
+            Integer[] array2 = Arrays.copyOf(array1, array1.length);
             Arrays.sort(array1, array1.length/3, array1.length/2);
             stupidSort(array2, array2.length/3, array2.length/2);
-            if(!Arrays.equals(array1, array2))
-                throw new RuntimeException("failed!");
-        }
-
-        for (int i=0; i<ITERATIONS; i++) {
-            int size = rnd.nextInt(TEST_SIZE) + 1;
-            array1 = (Object[])getIntegerArray(size);
-            array2 = (Object[])array1.clone();
-            Arrays.sort(array1, array1.length/3, array1.length/2, TEST_ORDER);
-            stupidSort(array2, array2.length/3, array2.length/2);
-            if(!Arrays.equals(array1, array2))
-                throw new RuntimeException("failed!");
+            assertEquals(array1, array2, "Arrays did not match. size=" + size);
         }
     }
 
-    static Integer[] getIntegerArray(int size) throws Exception {
+    @Test(dataProvider = "Comparators")
+    public void testComparatorSort(Comparator<Integer> comparator) {
+        for (int i=0; i<ITERATIONS; i++) {
+            int size = rnd.nextInt(TEST_SIZE) + 1;
+            Integer[] array1 = getIntegerArray(size);
+            Integer[] array2 = Arrays.copyOf(array1, array1.length);
+            Arrays.sort(array1, array1.length/3, array1.length/2, comparator);
+            stupidSort(array2, array2.length/3, array2.length/2, comparator);
+            assertEquals(array1, array2, "Arrays did not match. size=" + size);
+        }
+    }
+
+    static Integer[] getIntegerArray(int size) {
         Integer[] blah = new Integer[size];
         for (int x=0; x<size; x++) {
             blah[x] = new Integer(rnd.nextInt());
@@ -68,11 +73,14 @@
         return blah;
     }
 
-    static void stupidSort(Object[] a1, int from, int to) throws Exception {
+    static void stupidSort(Integer[] a1, int from, int to) {
+        if (from > to - 1 )
+          return;
+
         for (int x=from; x<to; x++) {
-            Object lowest = new Integer(Integer.MAX_VALUE);
-            int lowestIndex = 0;
-            for (int y=x; y<to; y++) {
+            Integer lowest = a1[x];
+            int lowestIndex = x;
+            for (int y=x + 1; y<to; y++) {
                 if (((Comparable)a1[y]).compareTo((Comparable)lowest) < 0) {
                     lowest = a1[y];
                     lowestIndex = y;
@@ -84,19 +92,55 @@
         }
     }
 
-    static void swap(Object x[], int a, int b) {
-        Object t = x[a];
+    static void stupidSort(Integer[] a1, int from, int to, Comparator<Integer> comparator) {
+        if (from > to - 1 )
+          return;
+
+        for (int x=from; x<to; x++) {
+            Integer lowest = a1[x];
+            int lowestIndex = x;
+            for (int y=x + 1; y<to; y++) {
+                if (comparator.compare(a1[y], lowest) < 0) {
+                    lowest = a1[y];
+                    lowestIndex = y;
+                }
+            }
+            if (lowestIndex != x) {
+                swap(a1, x, lowestIndex);
+            }
+        }
+    }
+
+    static <T> void swap(T[] x, int a, int b) {
+        T t = x[a];
         x[a] = x[b];
         x[b] = t;
     }
 
-    private static final Comparator TEST_ORDER = new IntegerComparator();
+    @DataProvider(name = "Comparators", parallel = true)
+    public static Iterator<Object[]> comparators() {
+        Object[][] comparators = new Object[][] {
+            new Object[] { Comparator.naturalOrder() },
+            new Object[] { Comparator.<Integer>naturalOrder().reversed() },
+            new Object[] { STANDARD_ORDER },
+            new Object[] { STANDARD_ORDER.reversed() },
+            new Object[] { REVERSE_ORDER },
+            new Object[] { REVERSE_ORDER.reversed() },
+            new Object[] { Comparator.comparingInt(Integer::intValue) }
+        };
 
-    private static class IntegerComparator implements Comparator {
-        public int compare(Object o1, Object o2) {
-            Comparable c1 = (Comparable)o1;
-            Comparable c2 = (Comparable)o2;
-            return  c1.compareTo(c2);
+        return Arrays.asList(comparators).iterator();
+    }
+
+    private static final Comparator<Integer> STANDARD_ORDER = new Comparator<Integer>() {
+        public int compare(Integer o1, Integer o2) {
+            return  o1.compareTo(o2);
         }
-    }
+    };
+
+    private static final Comparator<Integer> REVERSE_ORDER = new Comparator<Integer>() {
+        public int compare(Integer o1, Integer o2) {
+            return - o1.compareTo(o2);
+        }
+    };
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JCheckBox/8032667/bug8032667.html	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,36 @@
+<!--
+ Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<body>
+
+Verify that scaled components are rendered smoothly to image.
+
+1. Run the test.
+2. Check that Selected and Deselected JCheckBox icons are drawn smoothly.
+If so, press PASS, else press FAIL.
+
+<applet  code="bug8032667.class" width=400 height=400></applet>
+
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JCheckBox/8032667/bug8032667.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.awt.BorderLayout;
+import java.awt.Canvas;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import javax.swing.JApplet;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+
+/* @test
+ * @bug 8032667
+ * @summary [macosx] Components cannot be rendered in HiDPI to BufferedImage
+ * @run applet/manual=yesno bug8032667.html
+ */
+public class bug8032667 extends JApplet {
+
+    static final int scale = 2;
+    static final int width = 130;
+    static final int height = 50;
+    static final int scaledWidth = scale * width;
+    static final int scaledHeight = scale * height;
+
+    @Override
+    public void init() {
+        SwingUtilities.invokeLater(new Runnable() {
+
+            @Override
+            public void run() {
+
+                final Image image1 = getImage(getCheckBox("Deselected", false));
+                final Image image2 = getImage(getCheckBox("Selected", true));
+
+                Canvas canvas = new Canvas() {
+
+                    @Override
+                    public void paint(Graphics g) {
+                        super.paint(g);
+                        g.drawImage(image1, 0, 0, scaledWidth, scaledHeight, this);
+                        g.drawImage(image2, 0, scaledHeight + 5,
+                                scaledWidth, scaledHeight, this);
+                    }
+                };
+
+                getContentPane().add(canvas, BorderLayout.CENTER);
+            }
+        });
+    }
+
+    static JCheckBox getCheckBox(String text, boolean selected) {
+        JCheckBox checkBox = new JCheckBox(text);
+        checkBox.setSelected(selected);
+        checkBox.setSize(new Dimension(width, height));
+        return checkBox;
+    }
+
+    static Image getImage(JComponent component) {
+        final BufferedImage image = new BufferedImage(
+                scaledWidth, scaledHeight, BufferedImage.TYPE_INT_ARGB);
+        final Graphics g = image.getGraphics();
+        ((Graphics2D) g).scale(scale, scale);
+        component.paint(g);
+        g.dispose();
+
+        return image;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JCheckBox/8032667/bug8032667_image_diff.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import sun.awt.OSInfo;
+
+/* @test
+ * @bug 8032667
+ * @summary [macosx] Components cannot be rendered in HiDPI to BufferedImage
+ * @run main bug8032667_image_diff
+ */
+public class bug8032667_image_diff {
+
+    static final int IMAGE_WIDTH = 130;
+    static final int IMAGE_HEIGHT = 50;
+
+    public static void main(String[] args) throws Exception {
+
+        if(!OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())){
+            return;
+        }
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+
+                JCheckBox checkBox = new JCheckBox();
+                checkBox.setSelected(true);
+                checkBox.setSize(new Dimension(IMAGE_WIDTH, IMAGE_HEIGHT));
+
+                final BufferedImage image1 = getHiDPIImage(checkBox);
+                final BufferedImage image2 = getScaledImage(checkBox);
+
+                if(equal(image1, image2)){
+                    throw new RuntimeException("2x image equals to non smooth image");
+                }
+            }
+        });
+    }
+
+    static boolean equal(BufferedImage image1, BufferedImage image2) {
+
+        int w = image1.getWidth();
+        int h = image1.getHeight();
+
+        if (w != image2.getWidth() || h != image2.getHeight()) {
+            return false;
+        }
+
+        for (int i = 0; i < w; i++) {
+            for (int j = 0; j < h; j++) {
+                int color1 = image1.getRGB(i, j);
+                int color2 = image2.getRGB(i, j);
+
+                if (color1 != color2) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    static BufferedImage getHiDPIImage(JComponent component) {
+        return getImage(component, 2, IMAGE_WIDTH, IMAGE_HEIGHT);
+    }
+
+    static BufferedImage getScaledImage(JComponent component) {
+        Image image1x = getImage(component, 1, IMAGE_WIDTH, IMAGE_HEIGHT);
+        final BufferedImage image2x = new BufferedImage(
+                2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT, BufferedImage.TYPE_INT_ARGB);
+        final Graphics g = image2x.getGraphics();
+        ((Graphics2D) g).scale(2, 2);
+        g.drawImage(image1x, 0, 0, null);
+        g.dispose();
+        return image2x;
+    }
+
+    static BufferedImage getImage(JComponent component, int scale, int width, int height) {
+        final BufferedImage image = new BufferedImage(
+                scale * width, scale * height, BufferedImage.TYPE_INT_ARGB);
+        final Graphics g = image.getGraphics();
+        ((Graphics2D) g).scale(scale, scale);
+        component.paint(g);
+        g.dispose();
+        return image;
+    }
+}
--- a/test/javax/swing/JTable/8031971/bug8031971.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/javax/swing/JTable/8031971/bug8031971.java	Thu May 01 14:21:29 2014 -0700
@@ -29,7 +29,7 @@
 
 /**
  * @test
- * @bug 8031971
+ * @bug 8031971 8039750
  * @author Alexander Scherbatiy
  * @summary Use only public methods in the SwingLazyValue
  * @run main bug8031971
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JTable/8032874/bug8032874.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8032874
+ * @summary Test whether ArrayIndexOutOfBoundsException is thrown or not,
+ *          once selected row is removed from JTable with Sorter and Filter
+ * @author Dmitry Markov
+ * @run main bug8032874
+ */
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.*;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableRowSorter;
+
+import sun.awt.SunToolkit;
+
+public class bug8032874 {
+    private static final int ROW_COUNT = 5;
+    private static JTable table;
+    private static TestTableModel tableModel;
+
+    public static void main(String args[]) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                createAndShowUI();
+            }
+        });
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                table.getRowSorter().toggleSortOrder(0);
+                table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+                table.setRowSelectionInterval(1, 2);
+            }
+        });
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                for (int i = 0; i < ROW_COUNT; i++) {
+                    tableModel.remove(0);
+                    table.getRowSorter().toggleSortOrder(0);
+                }
+            }
+        });
+    }
+
+    public static void createAndShowUI() {
+        try {
+            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+        JFrame frame = new JFrame("bug8032874");
+        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+        JPanel panel = new JPanel();
+        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+
+        tableModel = new TestTableModel();
+        table = new JTable(tableModel);
+        table.setSurrendersFocusOnKeystroke(true);
+
+        final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel);
+        rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() {
+            @Override
+            public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) {
+                return entry.getIdentifier() % 2 == 0;
+            }
+        });
+        table.setRowSorter(rowSorter);
+
+        JScrollPane jScrollPane = new JScrollPane(table);
+        panel.add(jScrollPane);
+
+        frame.setContentPane(panel);
+        frame.setSize(new Dimension(800, 600));
+        frame.setVisible(true);
+    }
+
+    private static class TestTableModel extends AbstractTableModel {
+        private final List<Integer> data;
+
+        public TestTableModel() {
+            data = new ArrayList<Integer>();
+
+            for (int i = 0; i < ROW_COUNT; i++) {
+                data.add(i);
+            }
+        }
+
+        @Override
+        public int getRowCount() {
+            return data.size();
+        }
+
+        @Override
+        public int getColumnCount() {
+            return 1;
+        }
+
+        @Override
+        public Object getValueAt(int rowIndex, int columnIndex) {
+            return data.get(rowIndex);
+        }
+
+        public void remove(int row) {
+            data.remove(row);
+            fireTableRowsDeleted(row, row);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JTree/8038113/bug8038113.html	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,36 @@
+<!--
+ Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<body>
+
+Verify that scaled icons are rendered smoothly.
+
+1. Run the test.
+2. Check that Collapsed  and Expanded JTree icons are drawn smoothly.
+If so, press PASS, else press FAIL.
+
+<applet  code="bug8038113.class" width=400 height=400></applet>
+
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JTree/8038113/bug8038113.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.awt.BasicStroke;
+import java.awt.BorderLayout;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import javax.swing.Icon;
+import javax.swing.JApplet;
+import javax.swing.JPanel;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.basic.BasicTreeUI;
+
+/* @test
+ * @bug 8038113
+ * @summary [macosx] JTree icon is not rendered in high resolution on Retina
+ * @run applet/manual=yesno bug8038113.html
+ */
+public class bug8038113 extends JApplet {
+
+    @Override
+    public void init() {
+        SwingUtilities.invokeLater(new Runnable() {
+
+            @Override
+            public void run() {
+
+                final JTree tree = new JTree();
+                final BasicTreeUI treeUI = (BasicTreeUI) tree.getUI();
+
+                final JPanel panel = new JPanel() {
+
+                    @Override
+                    public void paint(Graphics g) {
+                        super.paint(g);
+                        Graphics2D g2 = (Graphics2D) g;
+                        g2.setStroke(new BasicStroke(0.5f));
+                        g2.scale(2, 2);
+
+                        int x = 10;
+                        int y = 10;
+                        Icon collapsedIcon = treeUI.getCollapsedIcon();
+                        Icon expandeIcon = treeUI.getExpandedIcon();
+                        int w = collapsedIcon.getIconWidth();
+                        int h = collapsedIcon.getIconHeight();
+                        collapsedIcon.paintIcon(this, g, x, y);
+                        g.drawRect(x, y, w, h);
+
+                        y += 10 + h;
+                        w = expandeIcon.getIconWidth();
+                        h = expandeIcon.getIconHeight();
+                        expandeIcon.paintIcon(this, g, x, y);
+                        g.drawRect(x, y, w, h);
+
+                    }
+                };
+                getContentPane().setLayout(new BorderLayout());
+                getContentPane().add(panel, BorderLayout.CENTER);
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/SwingUtilities/8032219/DrawRect.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import sun.swing.SwingUtilities2;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+/**
+ * @test
+ * @bug 8032219
+ * @author Sergey Bylokhov
+ */
+public final class DrawRect {
+
+    private static final int size = 50;
+
+    private static final Rectangle[] rects = {
+            new Rectangle(0, 0, 1, 1),
+            new Rectangle(0, 0, 1, 2),
+            new Rectangle(0, 0, 2, 1),
+            new Rectangle(10, 10, 10, 10),
+            new Rectangle(10, 10, -1, -1),
+            new Rectangle(-1, -1, 10, 10),
+            new Rectangle(-1, -1, -10, -10),
+            new Rectangle(0, 0, size, size),
+    };
+
+    private static final Rectangle[] vlines = {new Rectangle(0, 0, 0, 0),
+            new Rectangle(0, 0, 0, 1),
+            new Rectangle(0, 0, 0, -1),
+            new Rectangle(1, 1, 0, 1),
+            new Rectangle(1, 1, 0, -1),
+            new Rectangle(15, 15, 0, 10),
+            new Rectangle(15, 15, 0, -10),
+    };
+    private static final Rectangle[] hlines = {new Rectangle(0, 0, 0, 0),
+            new Rectangle(0, 0, 1, 0),
+            new Rectangle(0, 0, -1, 0),
+            new Rectangle(1, 1, 1, 0),
+            new Rectangle(1, 1, -1, 0),
+            new Rectangle(15, 15, 10, 0),
+            new Rectangle(15, 15, -10, 0),
+    };
+
+    public static void main(final String[] args) throws IOException {
+        BufferedImage gold = new BufferedImage(size, size,
+                                               BufferedImage.TYPE_INT_ARGB);
+        Graphics2D g = gold.createGraphics();
+        BufferedImage bi = new BufferedImage(size, size,
+                                             BufferedImage.TYPE_INT_ARGB);
+        Graphics2D g2d = bi.createGraphics();
+        g2d.setColor(new Color(0, 250, 0, 100));
+        g2d.setBackground(Color.BLACK);
+        g.setColor(new Color(0, 250, 0, 100));
+        g.setBackground(Color.BLACK);
+        // Rectangle
+        for (final Rectangle r : rects) {
+            g.clearRect(0, 0, size, size);
+            g2d.clearRect(0, 0, size, size);
+            g.drawRect(r.x, r.y, r.width, r.height);
+            SwingUtilities2.drawRect(g2d, r.x, r.y, r.width, r.height);
+            test(gold, bi);
+        }
+        // Vertical Line
+        for (final Rectangle l : vlines) {
+            g.clearRect(0, 0, size, size);
+            g2d.clearRect(0, 0, size, size);
+            g.drawLine(l.x, l.y, l.x + l.width, l.y + l.height);
+            SwingUtilities2.drawVLine(g2d, l.x, l.y, l.y + l.height);
+            test(gold, bi);
+        }
+        // Horizontal Line
+        for (final Rectangle l : hlines) {
+            g.clearRect(0, 0, size, size);
+            g2d.clearRect(0, 0, size, size);
+            g.drawLine(l.x, l.y, l.x + l.width, l.y + l.height);
+            SwingUtilities2.drawHLine(g2d, l.x, l.x+l.width, l.y);
+            test(gold, bi);
+        }
+
+        g.dispose();
+        g2d.dispose();
+    }
+
+    private static void test(final BufferedImage gold, final BufferedImage bi)
+            throws IOException {
+        for (int x = 0; x < size; x++) {
+            for (int y = 0; y < size; y++) {
+                if (gold.getRGB(x, y) != bi.getRGB(x, y)) {
+                    ImageIO.write(gold, "png", new File("gold.png"));
+                    ImageIO.write(bi, "png", new File("image.png"));
+                    throw new RuntimeException("wrong color");
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/plaf/metal/MetalLookAndFeel/Test8039750.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.UIDefaults;
+import javax.swing.border.CompoundBorder;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/*
+ * @test
+ * @bug 8039750
+ * @summary Tests MetalLazyValue removing
+ * @author Sergey Malenkov
+ */
+public class Test8039750 {
+    public static void main(String[] args) {
+        UIDefaults table= new MetalLookAndFeel().getDefaults();
+        test(table.get("ToolBar.rolloverBorder"),
+                "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
+                "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
+        test(table.get("ToolBar.nonrolloverBorder"),
+                "javax.swing.plaf.metal.MetalBorders$ButtonBorder",
+                "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
+        test(table.get("RootPane.frameBorder"),
+                "javax.swing.plaf.metal.MetalBorders$FrameBorder");
+        test(table.get("RootPane.plainDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$DialogBorder");
+        test(table.get("RootPane.informationDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$DialogBorder");
+        test(table.get("RootPane.errorDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder");
+        test(table.get("RootPane.colorChooserDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
+        test(table.get("RootPane.fileChooserDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
+        test(table.get("RootPane.questionDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
+        test(table.get("RootPane.warningDialogBorder"),
+                "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder");
+    }
+
+    private static void test(Object value, String name) {
+        if (!value.getClass().getName().equals(name)) {
+            throw new Error(name);
+        }
+    }
+
+    private static void test(Object value, String one, String two) {
+        if (value instanceof CompoundBorder) {
+            CompoundBorder border = (CompoundBorder) value;
+            test(border.getOutsideBorder(), one);
+            test(border.getInsideBorder(), two);
+        } else {
+            throw new Error("CompoundBorder");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/text/GlyphView/4984669/bug4984669.html	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,30 @@
+<html>
+<!--
+  Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ 
+  This code is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License version 2 only, as
+  published by the Free Software Foundation.
+ 
+  This code is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+  version 2 for more details (a copy is included in the LICENSE file that
+  accompanied this code).
+ 
+  You should have received a copy of the GNU General Public License version
+  2 along with this work; if not, write to the Free Software Foundation,
+  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ 
+  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+  or visit www.oracle.com if you need additional information or have any
+  questions.
+-->
+<body>
+<applet  code="bug4984669.class" width=300 height=300></applet>
+The four lines printed above in a bold typeface should all be underlined.
+It is a bug if any of these lines is underlined only partially.
+The very first line should not be underlined at all.
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/text/GlyphView/4984669/bug4984669.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 4984669 8002148
+   @summary Tests HTML underlining
+   @author Peter Zhelezniakov
+   @run applet/manual=yesno bug4984669.html
+*/
+import javax.swing.*;
+import javax.swing.text.*;
+
+public class bug4984669 extends JApplet
+{
+    public void init() {
+        JEditorPane pane = new JEditorPane();
+        this.getContentPane().add(new JScrollPane(pane));
+        pane.setEditorKit(new StyledEditorKit());
+
+        try {
+            pane.getDocument().insertString(0,"12   \n",null);
+            MutableAttributeSet attrs = new SimpleAttributeSet();
+
+            StyleConstants.setFontSize(attrs, 36);
+            StyleConstants.setBold(attrs, true);
+            StyleConstants.setUnderline(attrs, true);
+            pane.getDocument().insertString(6, "aa\n", attrs);
+            pane.getDocument().insertString(9, "bbb\n", attrs);
+            pane.getDocument().insertString(13, "cccc\n", attrs);
+            pane.getDocument().insertString(18, "ddddd\n", attrs);
+        } catch (Exception e) {
+            throw new Error("Failed: Unexpected Exception", e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/testlibrary/ExtendedRobot.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,372 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import sun.awt.ExtendedKeyCodes;
+import sun.awt.SunToolkit;
+import sun.security.action.GetIntegerAction;
+
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.GraphicsDevice;
+import java.awt.Toolkit;
+import java.awt.Point;
+import java.awt.MouseInfo;
+import java.awt.event.InputEvent;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * ExtendedRobot is a subclass of {@link java.awt.Robot}. It provides some convenience methods that are
+ * ought to be moved to {@link java.awt.Robot} class.
+ * <p>
+ * ExtendedRobot uses delay {@link #getSyncDelay()} to make syncing threads with {@link #waitForIdle()}
+ * more stable. This delay can be set once on creating object and could not be changed throughout object
+ * lifecycle. Constructor reads vm integer property {@code java.awt.robotdelay} and sets the delay value
+ * equal to the property value. If the property was not set 500 milliseconds default value is used.
+ * <p>
+ * When using jtreg you would include this class via something like:
+ * <pre>
+ * {@literal @}library ../../../../lib/testlibrary
+ * {@literal @}build ExtendedRobot
+ * </pre>
+ *
+ * @author      Dmitriy Ermashov
+ * @since       1.9
+ */
+
+public class ExtendedRobot extends Robot {
+
+    private static int DEFAULT_SPEED = 20;       // Speed for mouse glide and click
+    private static int DEFAULT_SYNC_DELAY = 500; // Default Additional delay for waitForIdle()
+    private static int DEFAULT_STEP_LENGTH = 2;  // Step length (in pixels) for mouse glide
+
+    private final int syncDelay = DEFAULT_SYNC_DELAY;
+
+    //TODO: uncomment three lines below after moving functionality to java.awt.Robot
+    //{
+    //    syncDelay = AccessController.doPrivileged(new GetIntegerAction("java.awt.robotdelay", DEFAULT_SYNC_DELAY));
+    //}
+
+    /**
+     * Constructs an ExtendedRobot object in the coordinate system of the primary screen.
+     *
+     * @throws  AWTException if the platform configuration does not allow low-level input
+     *          control. This exception is always thrown when
+     *          GraphicsEnvironment.isHeadless() returns true
+     * @throws  SecurityException if {@code createRobot} permission is not granted
+     *
+     * @see     java.awt.GraphicsEnvironment#isHeadless
+     * @see     SecurityManager#checkPermission
+     * @see     java.awt.AWTPermission
+     */
+    public ExtendedRobot() throws AWTException {
+        super();
+    }
+
+    /**
+     * Creates an ExtendedRobot for the given screen device. Coordinates passed
+     * to ExtendedRobot method calls like mouseMove and createScreenCapture will
+     * be interpreted as being in the same coordinate system as the specified screen.
+     * Note that depending on the platform configuration, multiple screens may either:
+     * <ul>
+     * <li>share the same coordinate system to form a combined virtual screen</li>
+     * <li>use different coordinate systems to act as independent screens</li>
+     * </ul>
+     * This constructor is meant for the latter case.
+     * <p>
+     * If screen devices are reconfigured such that the coordinate system is
+     * affected, the behavior of existing ExtendedRobot objects is undefined.
+     *
+     * @param   screen  A screen GraphicsDevice indicating the coordinate
+     *                  system the Robot will operate in.
+     * @throws  AWTException if the platform configuration does not allow low-level input
+     *          control. This exception is always thrown when
+     *          GraphicsEnvironment.isHeadless() returns true.
+     * @throws  IllegalArgumentException if {@code screen} is not a screen
+     *          GraphicsDevice.
+     * @throws  SecurityException if {@code createRobot} permission is not granted
+     *
+     * @see     java.awt.GraphicsEnvironment#isHeadless
+     * @see     GraphicsDevice
+     * @see     SecurityManager#checkPermission
+     * @see     java.awt.AWTPermission
+     */
+    public ExtendedRobot(GraphicsDevice screen) throws AWTException {
+        super(screen);
+    }
+
+    /**
+     * Returns delay length for {@link #waitForIdle()} method
+     *
+     * @return  Current delay value
+     *
+     * @see     #waitForIdle()
+     */
+    public int getSyncDelay(){ return this.syncDelay; }
+
+    /**
+     * Clicks mouse button(s) by calling {@link java.awt.Robot#mousePress(int)} and
+     * {@link java.awt.Robot#mouseRelease(int)} methods
+     *
+     *
+     * @param   buttons The button mask; a combination of one or more mouse button masks.
+     * @throws  IllegalArgumentException if the {@code buttons} mask contains the mask for
+     *          extra mouse button and support for extended mouse buttons is
+     *          {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
+     * @throws  IllegalArgumentException if the {@code buttons} mask contains the mask for
+     *          extra mouse button that does not exist on the mouse and support for extended
+     *          mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
+     *          by Java
+     *
+     * @see     #mousePress(int)
+     * @see     #mouseRelease(int)
+     * @see     InputEvent#getMaskForButton(int)
+     * @see     Toolkit#areExtraMouseButtonsEnabled()
+     * @see     java.awt.event.MouseEvent
+     */
+    public void click(int buttons) {
+        mousePress(buttons);
+        waitForIdle(DEFAULT_SPEED);
+        mouseRelease(buttons);
+        waitForIdle();
+    }
+
+    /**
+     * Clicks mouse button 1
+     *
+     * @throws  IllegalArgumentException if the {@code buttons} mask contains the mask for
+     *          extra mouse button and support for extended mouse buttons is
+     *          {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
+     * @throws  IllegalArgumentException if the {@code buttons} mask contains the mask for
+     *          extra mouse button that does not exist on the mouse and support for extended
+     *          mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
+     *          by Java
+     *
+     * @see     #click(int)
+     */
+    public void click() {
+        click(InputEvent.BUTTON1_DOWN_MASK);
+    }
+
+    /**
+     * Waits until all events currently on the event queue have been processed with given
+     * delay after syncing threads. It uses more advanced method of synchronizing threads
+     * unlike {@link java.awt.Robot#waitForIdle()}
+     *
+     * @param   delayValue  Additional delay length in milliseconds to wait until thread
+     *                      sync been completed
+     * @throws  sun.awt.SunToolkit.IllegalThreadException if called on the AWT event
+     *          dispatching thread
+     */
+    public synchronized void waitForIdle(int delayValue) {
+        SunToolkit.flushPendingEvents();
+        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        delay(delayValue);
+    }
+
+    /**
+     * Waits until all events currently on the event queue have been processed with delay
+     * {@link #getSyncDelay()} after syncing threads. It uses more advanced method of
+     * synchronizing threads unlike {@link java.awt.Robot#waitForIdle()}
+     *
+     * @throws  sun.awt.SunToolkit.IllegalThreadException if called on the AWT event
+     *          dispatching thread
+     *
+     * @see     #waitForIdle(int)
+     */
+    @Override
+    public synchronized void waitForIdle() {
+        waitForIdle(syncDelay);
+    }
+
+    /**
+     * Move the mouse in multiple steps from where it is
+     * now to the destination coordinates.
+     *
+     * @param   x   Destination point x coordinate
+     * @param   y   Destination point y coordinate
+     *
+     * @see     #glide(int, int, int, int)
+     */
+    public void glide(int x, int y) {
+        Point p = MouseInfo.getPointerInfo().getLocation();
+        glide(p.x, p.y, x, y);
+    }
+
+    /**
+     * Move the mouse in multiple steps from where it is
+     * now to the destination point.
+     *
+     * @param   dest    Destination point
+     *
+     * @see     #glide(int, int)
+     */
+    public void glide(Point dest) {
+        glide(dest.x, dest.y);
+    }
+
+    /**
+     * Move the mouse in multiple steps from source coordinates
+     * to the destination coordinates.
+     *
+     * @param   fromX   Source point x coordinate
+     * @param   fromY   Source point y coordinate
+     * @param   toX     Destination point x coordinate
+     * @param   toY     Destination point y coordinate
+     *
+     * @see     #glide(int, int, int, int, int, int)
+     */
+    public void glide(int fromX, int fromY, int toX, int toY) {
+        glide(fromX, fromY, toX, toY, DEFAULT_STEP_LENGTH, DEFAULT_SPEED);
+    }
+
+    /**
+     * Move the mouse in multiple steps from source point to the
+     * destination point with default speed and step length.
+     *
+     * @param   src     Source point
+     * @param   dest    Destination point
+     *
+     * @see     #glide(int, int, int, int, int, int)
+     */
+    public void glide(Point src, Point dest) {
+        glide(src.x, src.y, dest.x, dest.y, DEFAULT_STEP_LENGTH, DEFAULT_SPEED);
+    }
+
+    /**
+     * Move the mouse in multiple steps from source point to the
+     * destination point with given speed and step length.
+     *
+     * @param   srcX        Source point x cordinate
+     * @param   srcY        Source point y cordinate
+     * @param   destX       Destination point x cordinate
+     * @param   destY       Destination point y cordinate
+     * @param   stepLength  Approximate length of one step
+     * @param   speed       Delay between steps.
+     *
+     * @see     #mouseMove(int, int)
+     * @see     #delay(int)
+     */
+     public void glide(int srcX, int srcY, int destX, int destY, int stepLength, int speed) {
+        int stepNum;
+        double tDx, tDy;
+        double dx, dy, ds;
+        double x, y;
+
+        dx = (destX - srcX);
+        dy = (destY - srcY);
+        ds = Math.sqrt(dx*dx + dy*dy);
+
+        tDx = dx / ds * stepLength;
+        tDy = dy / ds * stepLength;
+
+        int stepsCount = (int) ds / stepLength;
+
+        // Walk the mouse to the destination one step at a time
+        mouseMove(srcX, srcY);
+
+        for (x = srcX, y = srcY, stepNum = 0;
+             stepNum < stepsCount;
+             stepNum++) {
+            x += tDx;
+            y += tDy;
+            mouseMove((int)x, (int)y);
+            delay(speed);
+        }
+
+        // Ensure the mouse moves to the right destination.
+        // The steps may have led the mouse to a slightly wrong place.
+        mouseMove(destX, destY);
+    }
+
+    /**
+     * Moves mouse pointer to given screen coordinates.
+     *
+     * @param   position    Target position
+     *
+     * @see     java.awt.Robot#mouseMove(int, int)
+     */
+    public synchronized void mouseMove(Point position) {
+        mouseMove(position.x, position.y);
+    }
+
+    /**
+     * Successively presses and releases a given key.
+     * <p>
+     * Key codes that have more than one physical key associated with them
+     * (e.g. {@code KeyEvent.VK_SHIFT} could mean either the
+     * left or right shift key) will map to the left key.
+     *
+     * @param   keycode Key to press (e.g. {@code KeyEvent.VK_A})
+     * @throws  IllegalArgumentException if {@code keycode} is not
+     *          a valid key
+     *
+     * @see     java.awt.Robot#keyPress(int)
+     * @see     java.awt.Robot#keyRelease(int)
+     * @see     java.awt.event.KeyEvent
+     */
+    public void type(int keycode) {
+        keyPress(keycode);
+        waitForIdle(DEFAULT_SPEED);
+        keyRelease(keycode);
+        waitForIdle(DEFAULT_SPEED);
+    }
+
+    /**
+     * Types given character
+     *
+     * @param   c   Character to be typed (e.g. {@code 'a'})
+     *
+     * @see     #type(int)
+     * @see     java.awt.event.KeyEvent
+     */
+    public void type(char c) {
+        type(ExtendedKeyCodes.getExtendedKeyCodeForChar(c));
+    }
+
+    /**
+     * Types given array of characters one by one
+     *
+     * @param   symbols Array of characters to be typed
+     *
+     * @see     #type(char)
+     */
+    public void type(char[] symbols) {
+        for (int i = 0; i < symbols.length; i++) {
+            type(symbols[i]);
+        }
+    }
+
+    /**
+     * Types given string
+     *
+     * @param   s   String to be typed
+     *
+     * @see     #type(char[])
+     */
+    public void type(String s) {
+        type(s.toCharArray());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/java2d/DrawCachedImageAndTransform.java	Thu May 01 14:21:29 2014 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.image.BufferedImage;
+import java.awt.image.VolatileImage;
+
+/**
+ * @test
+ * @bug 8039774
+ * @summary Verifies that we get no exception, when we draw with scale
+ *          BufferedImage to VolatileImage via intermediate texture.
+ * @author Sergey Bylokhov
+ * @run main/othervm -Dsun.java2d.accthreshold=0 DrawCachedImageAndTransform
+ */
+public final class DrawCachedImageAndTransform {
+
+    public static void main(String[] args) {
+        GraphicsEnvironment ge = GraphicsEnvironment
+                .getLocalGraphicsEnvironment();
+        GraphicsConfiguration gc = ge.getDefaultScreenDevice()
+                                     .getDefaultConfiguration();
+        VolatileImage vi = gc.createCompatibleVolatileImage(100, 100);
+
+        Graphics2D g2d = vi.createGraphics();
+        g2d.scale(2, 2);
+        BufferedImage img = new BufferedImage(50, 50,
+                                              BufferedImage.TYPE_INT_ARGB);
+
+        g2d.drawImage(img, 10, 25, Color.blue, null);
+        g2d.dispose();
+    }
+}
--- a/test/sun/security/mscapi/KeytoolChangeAlias.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/mscapi/KeytoolChangeAlias.sh	Thu May 01 14:21:29 2014 -0700
@@ -56,7 +56,7 @@
     #  execute test program - rely on it to exit if platform unsupported
 
         echo "Creating the alias '246810' in the Windows-My store..."
-        ${TESTJAVA}/bin/keytool \
+        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 	    -import \
 	    -storetype Windows-My \
 	    -file ${TESTSRC}/246810.cer \
@@ -68,13 +68,13 @@
 	fi
 
 	echo "Removing the alias '13579', if it is already present..."
-        ${TESTJAVA}/bin/keytool \
+        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 	    -list \
             -storetype Windows-My \
 	    -alias 13579 > /dev/null 2>&1
 
 	if [ $? ] ; then
-            ${TESTJAVA}/bin/keytool \
+            ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 		-delete \
 		-storetype Windows-My \
 		-alias 13579 \
@@ -82,12 +82,12 @@
 	fi
 
 	echo "Counting the entries in the store..."
-	count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
+	count=`${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -list -storetype Windows-My | wc -l`
 	before=$count
 
 	echo "Changing the alias name from '246810' to '13579'..."
 
-        ${TESTJAVA}/bin/keytool \
+        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 	    -changealias \
 	    -storetype Windows-My \
 	    -alias 246810 \
@@ -98,7 +98,7 @@
 	fi
 
 	echo "Re-counting the entries in the store..."
-	count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
+	count=`${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -list -storetype Windows-My | wc -l`
 	after=$count
 
 	if [ ! $before = $after ]; then
@@ -107,7 +107,7 @@
 	fi
 
 	echo "Confirming that the new alias is present..."
-        ${TESTJAVA}/bin/keytool \
+        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 	    -list \
             -storetype Windows-My \
 	    -alias 13579 > /dev/null 2>&1
@@ -118,7 +118,7 @@
 	fi
 
 	echo "Removing the new alias '13579'..."
-        ${TESTJAVA}/bin/keytool \
+        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 	    -delete \
             -storetype Windows-My \
 	    -alias 13579 > /dev/null 2>&1
--- a/test/sun/security/mscapi/PublicKeyInterop.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/mscapi/PublicKeyInterop.sh	Thu May 01 14:21:29 2014 -0700
@@ -51,7 +51,7 @@
     Windows* | CYGWIN* )
 
         echo "Creating a temporary RSA keypair in the Windows-My store..."
-        ${TESTJAVA}/bin/keytool \
+        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 	    -genkeypair \
 	    -storetype Windows-My \
 	    -keyalg RSA \
@@ -61,14 +61,14 @@
 
         echo
 	echo "Running the test..."
-        ${TESTJAVA}/bin/javac -d . ${TESTSRC}\\PublicKeyInterop.java
+        ${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} -d . ${TESTSRC}\\PublicKeyInterop.java
         ${TESTJAVA}/bin/java ${TESTVMOPTS} PublicKeyInterop
 
         rc=$?
 
         echo
         echo "Removing the temporary RSA keypair from the Windows-My store..."
-        ${TESTJAVA}/bin/keytool \
+        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 	    -delete \
 	    -storetype Windows-My \
 	    -alias 6888925
--- a/test/sun/security/mscapi/ShortRSAKey1024.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/mscapi/ShortRSAKey1024.sh	Thu May 01 14:21:29 2014 -0700
@@ -63,14 +63,14 @@
     Windows* | CYGWIN* )
 
         echo "Removing the keypair if it already exists (for unknown reason)..."
-        ${TESTJAVA}${FS}bin${FS}keytool \
+        ${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} \
             -delete \
             -storetype Windows-My \
             -debug \
             -alias 7106773.$BITS
 
         echo "Creating a temporary RSA keypair in the Windows-My store..."
-        ${TESTJAVA}${FS}bin${FS}keytool \
+        ${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} \
             -genkeypair \
             -storetype Windows-My \
             -keyalg RSA \
@@ -87,7 +87,7 @@
 
         echo
         echo "Running the test..."
-        ${TESTJAVA}${FS}bin${FS}javac -d . \
+        ${TESTJAVA}${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} -d . \
             ${TESTSRC}${FS}ShortRSAKeyWithinTLS.java
         ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ShortRSAKeyWithinTLS 7106773.$BITS $BITS \
             TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA
@@ -96,7 +96,7 @@
 
         echo
         echo "Removing the temporary RSA keypair from the Windows-My store..."
-        ${TESTJAVA}${FS}bin${FS}keytool \
+        ${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} \
             -delete \
             -storetype Windows-My \
             -debug \
--- a/test/sun/security/mscapi/SignUsingNONEwithRSA.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/mscapi/SignUsingNONEwithRSA.sh	Thu May 01 14:21:29 2014 -0700
@@ -50,7 +50,7 @@
     Windows* | CYGWIN* )
 
         echo "Creating a temporary RSA keypair in the Windows-My store..."
-        ${TESTJAVA}/bin/keytool \
+        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 	    -genkeypair \
 	    -storetype Windows-My \
 	    -keyalg RSA \
@@ -60,14 +60,14 @@
 
         echo
 	echo "Running the test..."
-        ${TESTJAVA}/bin/javac -d . ${TESTSRC}\\SignUsingNONEwithRSA.java
+        ${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} -d . ${TESTSRC}\\SignUsingNONEwithRSA.java
         ${TESTJAVA}/bin/java ${TESTVMOPTS} SignUsingNONEwithRSA
 
         rc=$?
 
         echo
         echo "Removing the temporary RSA keypair from the Windows-My store..."
-        ${TESTJAVA}/bin/keytool \
+        ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} \
 	    -delete \
 	    -storetype Windows-My \
 	    -alias 6578658
--- a/test/sun/security/tools/jarsigner/AlgOptions.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/AlgOptions.sh	Thu May 01 14:21:29 2014 -0700
@@ -75,7 +75,7 @@
 
 failed=0
 # test missing signature algorithm arg
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -sigalg \
@@ -89,7 +89,7 @@
 fi
 
 # test missing digest algorithm arg
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -digestalg \
@@ -103,7 +103,7 @@
 fi
 
 # test BOGUS signature algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -sigalg BOGUS \
@@ -117,7 +117,7 @@
 fi
 
 # test BOGUS digest algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -digestalg BOGUS \
@@ -131,7 +131,7 @@
 fi
 
 # test incompatible signature algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -sigalg SHA1withDSA \
@@ -145,7 +145,7 @@
 fi
 
 # test compatible signature algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -sigalg SHA512withRSA \
@@ -159,7 +159,7 @@
 fi
 
 # verify it
-${TESTJAVA}${FS}bin${FS}jarsigner -verify ${TESTCLASSES}${FS}AlgOptionsTmp.jar
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -verify ${TESTCLASSES}${FS}AlgOptionsTmp.jar
 RESULT=$?
 if [ $RESULT -eq 0 ]; then
     echo "test 7 passed"
@@ -169,7 +169,7 @@
 fi
 
 # test non-default digest algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -digestalg SHA-256 \
@@ -183,7 +183,7 @@
 fi
 
 # verify it
-${TESTJAVA}${FS}bin${FS}jarsigner -verify ${TESTCLASSES}${FS}AlgOptionsTmp.jar
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -verify ${TESTCLASSES}${FS}AlgOptionsTmp.jar
 RESULT=$?
 if [ $RESULT -eq 0 ]; then
     echo "test 9 passed"
@@ -193,7 +193,7 @@
 fi
 
 # test SHA-512 digest algorithm (creates long lines)
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -digestalg SHA-512 \
@@ -208,7 +208,7 @@
 fi
 
 # verify it
-${TESTJAVA}${FS}bin${FS}jarsigner -verify ${TESTCLASSES}${FS}AlgOptionsTmp.jar
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -verify ${TESTCLASSES}${FS}AlgOptionsTmp.jar
 RESULT=$?
 if [ $RESULT -eq 0 ]; then
     echo "test 11 passed"
--- a/test/sun/security/tools/jarsigner/PercentSign.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/PercentSign.sh	Thu May 01 14:21:29 2014 -0700
@@ -73,7 +73,7 @@
 # copy jar file into writeable location
 ${CP} ${TESTSRC}${FS}AlgOptions.jar ${TESTCLASSES}${FS}AlgOptionsTmp.jar
 
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}a%b${FS}percent.keystore \
     -storepass changeit \
     ${TESTCLASSES}${FS}AlgOptionsTmp.jar ok
--- a/test/sun/security/tools/jarsigner/TimestampCheck.java	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/TimestampCheck.java	Thu May 01 14:21:29 2014 -0700
@@ -255,18 +255,16 @@
         // nonce generation in timestamping request. Not avaibale on
         // Windows and defaults to thread seed generator, not too bad.
         if (System.getProperty("java.home").endsWith("jre")) {
-            cmd = System.getProperty("java.home") + "/../bin/jarsigner" +
+            cmd = System.getProperty("java.home") + "/../bin/jarsigner";
+        } else {
+            cmd = System.getProperty("java.home") + "/bin/jarsigner";
+        }
+
+        cmd +=  " " + System.getProperty("test.tool.vm.opts") +
                 " -J-Djava.security.egd=file:/dev/./urandom" +
                 " -debug -keystore " + TSKS + " -storepass changeit" +
                 " -tsa http://localhost:" + port + "/%d" +
                 " -signedjar new_%d.jar " + JAR + " old";
-        } else {
-            cmd = System.getProperty("java.home") + "/bin/jarsigner" +
-                " -J-Djava.security.egd=file:/dev/./urandom" +
-                " -debug -keystore " + TSKS + " -storepass changeit" +
-                " -tsa http://localhost:" + port + "/%d" +
-                " -signedjar new_%d.jar " + JAR + " old";
-        }
 
         try {
             if (args.length == 0) {         // Run this test
--- a/test/sun/security/tools/jarsigner/checkusage.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/checkusage.sh	Thu May 01 14:21:29 2014 -0700
@@ -45,9 +45,9 @@
     ;;
 esac
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keyalg rsa"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner"
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keyalg rsa"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
 
 rm js.jks trust.jks unrelated.jks 2> /dev/null
 
--- a/test/sun/security/tools/jarsigner/collator.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/collator.sh	Thu May 01 14:21:29 2014 -0700
@@ -46,10 +46,10 @@
 KS=collator.jks
 JFILE=collator.jar
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit \
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit \
         -keyalg rsa -keystore $KS"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner -keystore $KS -storepass changeit"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
 
 rm $F $KS $JFILE 2> /dev/null
 
--- a/test/sun/security/tools/jarsigner/concise_jarsigner.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/concise_jarsigner.sh	Thu May 01 14:21:29 2014 -0700
@@ -47,10 +47,10 @@
 # Choose 1024-bit RSA to make sure it runs fine and fast on all platforms. In
 # fact, every keyalg/keysize combination is OK for this test.
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore js.jks -keyalg rsa -keysize 1024"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
-JAVAC=$TESTJAVA${FS}bin${FS}javac
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore js.jks -keyalg rsa -keysize 1024"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
+JAVAC="$TESTJAVA${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}"
 
 rm js.jks
 
--- a/test/sun/security/tools/jarsigner/crl.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/crl.sh	Thu May 01 14:21:29 2014 -0700
@@ -45,7 +45,7 @@
 
 KS=crl.jks
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
 
 rm $KS 2> /dev/null
 
--- a/test/sun/security/tools/jarsigner/diffend.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/diffend.sh	Thu May 01 14:21:29 2014 -0700
@@ -85,7 +85,7 @@
 rm diffend.jar
 zip diffend.jar META-INF/MANIFEST.MF META-INF/x.RSA 1
 
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -digestalg SHA1 \
@@ -99,7 +99,7 @@
 rm diffend.jar
 zip diffend.jar META-INF/MANIFEST.MF 1
 
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -digestalg SHA1 \
--- a/test/sun/security/tools/jarsigner/ec.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/ec.sh	Thu May 01 14:21:29 2014 -0700
@@ -45,9 +45,9 @@
 KS=ec.jks
 JFILE=ec.jar
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
 
 rm $KS $JFILE
 echo A > A
--- a/test/sun/security/tools/jarsigner/emptymanifest.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/emptymanifest.sh	Thu May 01 14:21:29 2014 -0700
@@ -47,11 +47,11 @@
 KS=emptymanifest.jks
 JFILE=em.jar
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JAVA=$TESTJAVA${FS}bin${FS}java
-JAVAC=$TESTJAVA${FS}bin${FS}javac
-JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JAVA="$TESTJAVA${FS}bin${FS}java ${TESTVMOPTS}"
+JAVAC="$TESTJAVA${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
 
 rm $KS $JFILE
 echo A > A
@@ -65,7 +65,7 @@
 }
 EOF
 $JAVAC CrLf.java
-$JAVA ${TESTVMOPTS} CrLf > META-INF${FS}MANIFEST.MF
+$JAVA CrLf > META-INF${FS}MANIFEST.MF
 zip $JFILE META-INF${FS}MANIFEST.MF A B
 
 $KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
--- a/test/sun/security/tools/jarsigner/jvindex.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/jvindex.sh	Thu May 01 14:21:29 2014 -0700
@@ -46,10 +46,10 @@
 KS=jvindex.jks
 JFILE=jvindex.jar
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit \
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit \
         -keystore $KS -keyalg rsa"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner -keystore $KS -storepass changeit"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
 
 rm $F $KS $JFILE 2> /dev/null
 
--- a/test/sun/security/tools/jarsigner/nameclash.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/nameclash.sh	Thu May 01 14:21:29 2014 -0700
@@ -45,9 +45,9 @@
 KS=nc.jks
 JFILE=nc.jar
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
 
 rm $KS $JFILE
 
--- a/test/sun/security/tools/jarsigner/newsize7.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/newsize7.sh	Thu May 01 14:21:29 2014 -0700
@@ -51,9 +51,9 @@
 
 KSFILE=ns7.jks
 
-KT="${TESTJAVA}${FS}bin${FS}keytool -keystore ns7.jks -storepass changeit -keypass changeit -keyalg rsa"
-JAR="${TESTJAVA}${FS}bin${FS}jar"
-JS="${TESTJAVA}${FS}bin${FS}jarsigner -keystore ns7.jks -storepass changeit"
+KT="${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keystore ns7.jks -storepass changeit -keypass changeit -keyalg rsa"
+JAR="${TESTJAVA}${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JS="${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore ns7.jks -storepass changeit"
 
 rm ns7.*
 
--- a/test/sun/security/tools/jarsigner/oldsig.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/oldsig.sh	Thu May 01 14:21:29 2014 -0700
@@ -70,10 +70,10 @@
 ${CP} ${TESTSRC}${FS}oldsig${FS}A.jar B.jar
 ${CP} ${TESTSRC}${FS}oldsig${FS}A.class B.class
 
-${TESTJAVA}${FS}bin${FS}jar uvf B.jar B.class
-${TESTJAVA}${FS}bin${FS}jarsigner \
+${TESTJAVA}${FS}bin${FS}jar ${TESTTOOLVMOPTS} uvf B.jar B.class
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
     -keystore ${TESTSRC}${FS}JarSigning.keystore \
     -storepass bbbbbb \
     -digestalg SHA1 \
     B.jar c
-${TESTJAVA}${FS}bin${FS}jarsigner -verify B.jar
+${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -verify B.jar
--- a/test/sun/security/tools/jarsigner/onlymanifest.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/onlymanifest.sh	Thu May 01 14:21:29 2014 -0700
@@ -45,10 +45,10 @@
 KS=onlymanifest.jks
 JFILE=onlymanifest.jar
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit \
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit \
         -keystore $KS -keyalg rsa"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
 
 rm $KS $JFILE 2> /dev/null
 
--- a/test/sun/security/tools/jarsigner/passtype.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/passtype.sh	Thu May 01 14:21:29 2014 -0700
@@ -45,9 +45,9 @@
 KS=pt.jks
 JFILE=pt.jar
 
-KT="$TESTJAVA${FS}bin${FS}keytool -keystore $KS -validity 300 -keyalg rsa"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keystore $KS -validity 300 -keyalg rsa"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
 
 rm $KS $JFILE
 
--- a/test/sun/security/tools/jarsigner/samename.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/samename.sh	Thu May 01 14:21:29 2014 -0700
@@ -47,9 +47,9 @@
 KS=samename.jks
 JFILE=em.jar
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
 
 rm $KS $JFILE $SIGNEDJAR
 echo A > A
--- a/test/sun/security/tools/jarsigner/ts.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/ts.sh	Thu May 01 14:21:29 2014 -0700
@@ -50,10 +50,10 @@
   TESTJAVA=`dirname $JAVAC_CMD`/..
 fi
 
-JAR="${TESTJAVA}${FS}bin${FS}jar"
-JAVA="${TESTJAVA}${FS}bin${FS}java"
-JAVAC="${TESTJAVA}${FS}bin${FS}javac"
-KT="${TESTJAVA}${FS}bin${FS}keytool -keystore tsks -storepass changeit -keypass changeit -keyalg rsa -validity 200"
+JAR="${TESTJAVA}${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JAVA="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS}"
+JAVAC="${TESTJAVA}${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}"
+KT="${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keystore tsks -storepass changeit -keypass changeit -keyalg rsa -validity 200"
 
 rm tsks
 echo Nothing > A
@@ -87,5 +87,5 @@
         $KT -alias tsbad3 -importcert
 
 $JAVAC -d . ${TESTSRC}/TimestampCheck.java
-$JAVA ${TESTVMOPTS} TimestampCheck
+$JAVA ${TESTVMOPTS} "-Dtest.tool.vm.opts=${TESTTOOLVMOPTS}" TimestampCheck
 
--- a/test/sun/security/tools/jarsigner/warnings.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/jarsigner/warnings.sh	Thu May 01 14:21:29 2014 -0700
@@ -46,10 +46,10 @@
 KS=warnings.jks
 JFILE=warnings.jar
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit \
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit \
         -keystore $KS"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner -keystore $KS -storepass changeit"
+JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
 
 rm $KS 2> /dev/null
 
--- a/test/sun/security/tools/keytool/AltProviderPath.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/AltProviderPath.sh	Thu May 01 14:21:29 2014 -0700
@@ -69,7 +69,7 @@
 
 # the test code
 #genkey
-${TESTJAVA}${FS}bin${FS}keytool -genkey -v -alias dummyTestCA \
+${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkey -v -alias dummyTestCA \
     -keyalg "RSA" -keysize 1024 -sigalg "ShA1WithRSA" \
     -dname "cn=Dummy Test CA, ou=JSN, o=JavaSoft, c=US" -validity 3650 \
     -keypass storepass -keystore keystoreCA.dks -storepass storepass \
@@ -81,7 +81,7 @@
 fi
 
 #Change keystore password
-${TESTJAVA}${FS}bin${FS}keytool -storepasswd -new storepass2 \
+${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepasswd -new storepass2 \
     -keystore keystoreCA.dks -storetype "dummyks" -storepass storepass \
     -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
 
@@ -91,7 +91,7 @@
 
 
 #Change keystore key password
-${TESTJAVA}${FS}bin${FS}keytool -keypasswd -alias "dummyTestCA" \
+${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keypasswd -alias "dummyTestCA" \
     -keypass storepass -new keypass -keystore keystoreCA.dks \
     -storetype "dummyks" -storepass storepass2 \
     -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
@@ -101,7 +101,7 @@
 fi
 
 #Export certificate
-${TESTJAVA}${FS}bin${FS}keytool -v -export -rfc -alias "dummyTestCA" \
+${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -v -export -rfc -alias "dummyTestCA" \
     -file "dummyTestCA.der" -keystore keystoreCA.dks -storetype "dummyks" \
     -storepass storepass2 -provider "org.test.dummy.DummyProvider" \
     -providerPath ${TESTCLASSES}
@@ -111,7 +111,7 @@
 fi
 
 #list keystore
-${TESTJAVA}${FS}bin${FS}keytool -v -list -keystore keystoreCA.dks \
+${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -v -list -keystore keystoreCA.dks \
     -storetype "dummyks" -storepass storepass2 \
     -provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
 
--- a/test/sun/security/tools/keytool/CloneKeyAskPassword.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/CloneKeyAskPassword.sh	Thu May 01 14:21:29 2014 -0700
@@ -82,7 +82,7 @@
 chmod 644 CloneKeyAskPassword.jks
 
 # run the test: attempt to clone the private key
-${TESTJAVA}${FILESEP}bin${FILESEP}keytool \
+${TESTJAVA}${FILESEP}bin${FILESEP}keytool ${TESTTOOLVMOPTS} \
         -keyclone \
         -alias mykey \
         -dest myclone \
--- a/test/sun/security/tools/keytool/ListKeychainStore.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/ListKeychainStore.sh	Thu May 01 14:21:29 2014 -0700
@@ -46,7 +46,7 @@
 esac
 
 PWD="xxxxxx"
-KEYTOOL="${TESTJAVA}/bin/keytool -storetype KeychainStore -keystore NONE -storepass $PWD"
+KEYTOOL="${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -storetype KeychainStore -keystore NONE -storepass $PWD"
 TEMPORARY_P12="$TESTCLASSES/7133495.p12"
 TEMPORARY_KC="$TESTCLASSES/7133495.keychain"
 CLEANUP_P12="rm -f $TEMPORARY_P12"
@@ -67,7 +67,7 @@
 
 for i in X Y Z
 do
-    ${TESTJAVA}/bin/keytool -genkeypair \
+    ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -genkeypair \
         -storetype PKCS12 \
         -keystore $TEMPORARY_P12 \
         -storepass $PWD \
--- a/test/sun/security/tools/keytool/NoExtNPE.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/NoExtNPE.sh	Thu May 01 14:21:29 2014 -0700
@@ -67,7 +67,7 @@
     ;;
 esac
 
-${TESTJAVA}${FILESEP}bin${FILESEP}keytool \
+${TESTJAVA}${FILESEP}bin${FILESEP}keytool ${TESTTOOLVMOPTS} \
         -list -v \
         -keystore ${TESTSRC}${FILESEP}CloneKeyAskPassword.jks \
         -storepass test123
--- a/test/sun/security/tools/keytool/SecretKeyKS.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/SecretKeyKS.sh	Thu May 01 14:21:29 2014 -0700
@@ -68,6 +68,6 @@
 
 # the test code
 
-${TESTJAVA}${FS}bin${FS}keytool -list -keystore ${TESTSRC}${FS}SecretKeyKS.jks -storepass password
+${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -list -keystore ${TESTSRC}${FS}SecretKeyKS.jks -storepass password
 
 exit $?
--- a/test/sun/security/tools/keytool/StandardAlgName.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/StandardAlgName.sh	Thu May 01 14:21:29 2014 -0700
@@ -69,20 +69,20 @@
 
 # the test code
 #CA
-${TESTJAVA}${FS}bin${FS}keytool -genkey -v -alias pkcs12testCA -keyalg "RsA" -keysize 2048 -sigalg "ShA1wItHRSA" -dname "cn=PKCS12 Test CA, ou=Security SQE, o=JavaSoft, c=US" -validity 3650 -keypass storepass -keystore keystoreCA.jceks.data -storepass storepass -storetype jceKS 2>&1 | egrep 'RsA|ShA1wItHRSA'
+${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkey -v -alias pkcs12testCA -keyalg "RsA" -keysize 2048 -sigalg "ShA1wItHRSA" -dname "cn=PKCS12 Test CA, ou=Security SQE, o=JavaSoft, c=US" -validity 3650 -keypass storepass -keystore keystoreCA.jceks.data -storepass storepass -storetype jceKS 2>&1 | egrep 'RsA|ShA1wItHRSA'
 
 RESULT=$?
 if [ $RESULT -eq 0 ]; then
     exit 1
 else
     #Lead
-    ${TESTJAVA}${FS}bin${FS}keytool -genkey -v -alias pkcs12testLead -keyalg "rSA" -keysize 1024 -sigalg "mD5withRSA" -dname "cn=PKCS12 Test Lead, ou=Security SQE, o=JavaSoft, c=US" -validity 3650 -keypass storepass -keystore keystoreLead.jceks.data -storepass storepass -storetype jCeks 2>&1 | egrep 'rSA|mD5withRSA'
+    ${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkey -v -alias pkcs12testLead -keyalg "rSA" -keysize 1024 -sigalg "mD5withRSA" -dname "cn=PKCS12 Test Lead, ou=Security SQE, o=JavaSoft, c=US" -validity 3650 -keypass storepass -keystore keystoreLead.jceks.data -storepass storepass -storetype jCeks 2>&1 | egrep 'rSA|mD5withRSA'
     RESULT=$?
     if [ $RESULT -eq 0 ]; then
         exit 1
     else
         #End User 1
-        ${TESTJAVA}${FS}bin${FS}keytool -genkey -v -alias pkcs12testEndUser1 -keyalg "RSa" -keysize 1024 -sigalg "sHa1wIThRSA" -dname "cn=PKCS12 Test End User 1, ou=Security SQE, o=JavaSoft, c=US" -validity 3650 -keypass storepass -keystore keystoreEndUser1.jceks.data -storepass storepass -storetype Jceks 2>&1 | egrep 'RSa|sHa1wIThRSA'
+        ${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkey -v -alias pkcs12testEndUser1 -keyalg "RSa" -keysize 1024 -sigalg "sHa1wIThRSA" -dname "cn=PKCS12 Test End User 1, ou=Security SQE, o=JavaSoft, c=US" -validity 3650 -keypass storepass -keystore keystoreEndUser1.jceks.data -storepass storepass -storetype Jceks 2>&1 | egrep 'RSa|sHa1wIThRSA'
         RESULT=$?
         if [ $RESULT -eq 0 ]; then
             exit 1
--- a/test/sun/security/tools/keytool/StorePasswordsByShell.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/StorePasswordsByShell.sh	Thu May 01 14:21:29 2014 -0700
@@ -107,7 +107,7 @@
 
     echo "Storing user password (protected by ${i})"
     echo "${USER_PWD}" | \
-        ${TESTJAVA}${FILESEP}bin${FILESEP}keytool ${IMPORTPASSWORD} \
+        ${TESTJAVA}${FILESEP}bin${FILESEP}keytool ${TESTTOOLVMOPTS} ${IMPORTPASSWORD} \
             -storetype pkcs12 -keystore mykeystore.p12 -storepass changeit \
             -alias "${ALIAS_PREFIX}${i}" ${KEYALG} > /dev/null 2>&1
     if [ $? -ne 0 ]; then
@@ -119,7 +119,7 @@
 done
 echo
 
-COUNTER2=`${TESTJAVA}${FILESEP}bin${FILESEP}keytool -list -storetype pkcs12 \
+COUNTER2=`${TESTJAVA}${FILESEP}bin${FILESEP}keytool ${TESTTOOLVMOPTS} -list -storetype pkcs12 \
   -keystore mykeystore.p12 -storepass changeit | grep -c "${ALIAS_PREFIX}"`
 
 RESULT="stored ${COUNTER} user passwords, detected ${COUNTER2} user passwords"
--- a/test/sun/security/tools/keytool/emptysubject.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/emptysubject.sh	Thu May 01 14:21:29 2014 -0700
@@ -45,7 +45,7 @@
 esac
 
 KS=emptysubject.jks
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
 
 rm $KS
 
--- a/test/sun/security/tools/keytool/file-in-help.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/file-in-help.sh	Thu May 01 14:21:29 2014 -0700
@@ -43,8 +43,8 @@
 esac
 
 LANG=C
-$TESTJAVA${FS}bin${FS}keytool -printcertreq -help 2> h1 || exit 1
-$TESTJAVA${FS}bin${FS}keytool -exportcert -help 2> h2 || exit 2
+$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -printcertreq -help 2> h1 || exit 1
+$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -exportcert -help 2> h2 || exit 2
 
 grep "input file" h1 || exit 3
 grep "output file" h2 || exit 4
--- a/test/sun/security/tools/keytool/importreadall.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/importreadall.sh	Thu May 01 14:21:29 2014 -0700
@@ -49,7 +49,7 @@
     ;;
 esac
 
-KEYTOOL="${TESTJAVA}${FS}bin${FS}keytool -keystore importreadall.jks -storepass changeit -keypass changeit -keyalg rsa"
+KEYTOOL="${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keystore importreadall.jks -storepass changeit -keypass changeit -keyalg rsa"
 
 # In case the test is run twice in the same directory
 
--- a/test/sun/security/tools/keytool/newhelp.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/newhelp.sh	Thu May 01 14:21:29 2014 -0700
@@ -43,8 +43,8 @@
 esac
 
 LANG=C
-$TESTJAVA${FS}bin${FS}keytool -help 2> h1 || exit 1
-$TESTJAVA${FS}bin${FS}keytool -help -list 2> h2 || exit 2
+$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -help 2> h1 || exit 1
+$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -help -list 2> h2 || exit 2
 
 grep Commands: h1 || exit 3
 grep Options: h2 || exit 4
--- a/test/sun/security/tools/keytool/p12importks.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/p12importks.sh	Thu May 01 14:21:29 2014 -0700
@@ -44,7 +44,7 @@
 esac
 
 LANG=C
-KT=$TESTJAVA${FS}bin${FS}keytool
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS}"
 
 # Part 1: JKS keystore with same storepass and keypass
 
--- a/test/sun/security/tools/keytool/printssl.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/printssl.sh	Thu May 01 14:21:29 2014 -0700
@@ -62,7 +62,7 @@
           echo "Server not started"
           exit 2
       else
-          ${TESTJAVA}${FS}bin${FS}keytool -printcert -sslserver localhost:$PORT
+          ${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -printcert -sslserver localhost:$PORT
       fi
 )
 status=$?
--- a/test/sun/security/tools/keytool/resource.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/resource.sh	Thu May 01 14:21:29 2014 -0700
@@ -62,7 +62,7 @@
 esac
 
 # the test code
-${TESTJAVA}${FS}bin${FS}keytool > temp_file_40875602475 2> ${NULL}
+${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} > temp_file_40875602475 2> ${NULL}
 grep MissingResourceException temp_file_40875602475
 
 if [ $? -eq 0 ]; then
--- a/test/sun/security/tools/keytool/selfissued.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/selfissued.sh	Thu May 01 14:21:29 2014 -0700
@@ -45,7 +45,7 @@
 esac
 
 KS=selfsigned.jks
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
 
 rm $KS
 
--- a/test/sun/security/tools/keytool/trystore.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/keytool/trystore.sh	Thu May 01 14:21:29 2014 -0700
@@ -43,7 +43,7 @@
 
 rm trystore.jks 2> /dev/null
 
-KEYTOOL="${TESTJAVA}${FS}bin${FS}keytool -storetype jks -keystore trystore.jks -keyalg rsa"
+KEYTOOL="${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storetype jks -keystore trystore.jks -keyalg rsa"
 $KEYTOOL -genkeypair -alias a -dname CN=A -storepass changeit -keypass changeit
 $KEYTOOL -genkeypair -alias b -dname CN=B -storepass changeit -keypass changeit
 
--- a/test/sun/security/tools/policytool/i18n.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/tools/policytool/i18n.sh	Thu May 01 14:21:29 2014 -0700
@@ -83,11 +83,11 @@
     exit 1
 fi
 
-${TESTJAVA}${FS}bin${FS}keytool -genkeypair -alias hello -dname CN=Hello \
+${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkeypair -alias hello -dname CN=Hello \
         -storepass changeit -keypass changeit -keystore ks
 echo changeit > good
 echo badpass > bad
-${TESTJAVA}${FS}bin${FS}policytool
+${TESTJAVA}${FS}bin${FS}policytool ${TESTTOOLVMOPTS}
 
 exit $?
 
--- a/test/sun/security/validator/certreplace.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/validator/certreplace.sh	Thu May 01 14:21:29 2014 -0700
@@ -47,7 +47,7 @@
     ;;
 esac
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit \
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit \
     -keypass changeit -keystore certreplace.jks -keyalg rsa"
 JAVAC=$COMPILEJAVA${FS}bin${FS}javac
 JAVA=$TESTJAVA${FS}bin${FS}java
--- a/test/sun/security/validator/samedn.sh	Thu May 01 12:51:13 2014 -0700
+++ b/test/sun/security/validator/samedn.sh	Thu May 01 14:21:29 2014 -0700
@@ -47,7 +47,7 @@
     ;;
 esac
 
-KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit \
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit \
     -keypass changeit -keystore samedn.jks -keyalg rsa"
 JAVAC=$COMPILEJAVA${FS}bin${FS}javac
 JAVA=$TESTJAVA${FS}bin${FS}java