Merge
authorddehaven
Tue, 26 Jul 2016 14:45:11 -0700
changeset 39875 7a65bed8f877
parent 39874 bf85c2b8f0e0 (diff)
parent 39825 6441823cea46 (current diff)
child 39876 ddb1d9c633cb
Merge
jdk/test/java/net/URLPermission/policy.1
jdk/test/java/net/URLPermission/policy.2
jdk/test/java/net/URLPermission/policy.3
jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/ClassTracker.java
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/FailOverExecutionControl.java
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIConnection.java
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIEventHandler.java
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDIExecutionControl.java
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/jdi/JDINotConnectedException.java
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteAgent.java
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteClassLoader.java
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteCodes.java
langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Internal.java
langtools/test/jdk/jshell/LocalExecutionControl.java
nashorn/test/script/currently-failing/logcoverage.js
--- a/jdk/make/lib/Awt2dLibraries.gmk	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/make/lib/Awt2dLibraries.gmk	Tue Jul 26 14:45:11 2016 -0700
@@ -917,7 +917,7 @@
     LIBSPLASHSCREEN_LDFLAGS := -delayload:user32.dll
     LIBSPLASHSCREEN_LIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib
   else
-    LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread
+    LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread -ldl
   endif
 
   $(eval $(call SetupNativeCompilation,BUILD_LIBSPLASHSCREEN, \
--- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers	Tue Jul 26 14:45:11 2016 -0700
@@ -164,6 +164,7 @@
         Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl;
         Java_sun_awt_X11_XRobotPeer_mouseWheelImpl;
         Java_sun_awt_X11_XRobotPeer_setup;
+        Java_sun_awt_X11_XRobotPeer_loadNativeLibraries;
         Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl;
         Java_java_awt_Component_initIDs;
         Java_java_awt_Container_initIDs;
--- a/jdk/src/java.datatransfer/share/classes/module-info.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.datatransfer/share/classes/module-info.java	Tue Jul 26 14:45:11 2016 -0700
@@ -23,6 +23,11 @@
  * questions.
  */
 
+/**
+ * Provides interfaces and classes for transferring data between and
+ * within applications.
+ */
+
 module java.datatransfer {
     exports java.awt.datatransfer;
     exports sun.datatransfer to java.desktop;
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java	Tue Jul 26 12:56:26 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,253 +0,0 @@
-/*
- * Copyright (c) 2002, 2016, 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.lwawt.macosx;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleContext;
-import javax.accessibility.AccessibleRole;
-import javax.accessibility.AccessibleState;
-import javax.accessibility.AccessibleStateSet;
-import javax.swing.event.EventListenerList;
-
-/**
- * <P>{@code AccessibilityEventMonitor} implements a PropertyChange listener
- * on every UI object that implements interface {@code Accessible} in the Java
- * Virtual Machine.  The events captured by these listeners are made available
- * through listeners supported by {@code AccessibilityEventMonitor}.
- * With this, all the individual events on each of the UI object
- * instances are funneled into one set of PropertyChange listeners.
- *
- * This code is a subset of com.sun.java.accessibility.util.AccessibilityEventMonitor
- * which resides in module jdk.accessibility.  Due to modularization the code in
- * this package, java.desktop, can not be dependent on code in jdk.accessibility.
- */
-
-class AccessibilityEventMonitor {
-
-    /**
-     * The current list of registered {@link java.beans.PropertyChangeListener
-     * PropertyChangeListener} classes.
-     *
-     * @see #addPropertyChangeListener
-     */
-    private static final EventListenerList listenerList =
-        new EventListenerList();
-
-
-    /**
-     * The actual listener that is installed on the component instances.
-     * This listener calls the other registered listeners when an event
-     * occurs.  By doing things this way, the actual number of listeners
-     * installed on a component instance is drastically reduced.
-     */
-    private static final AccessibilityEventListener accessibilityListener =
-        new AccessibilityEventListener();
-
-    /**
-     * Adds the specified listener to receive all PropertyChange events on
-     * each UI object instance in the Java Virtual Machine as they occur.
-     * <P>Note: This listener is automatically added to all component
-     * instances created after this method is called.  In addition, it
-     * is only added to UI object instances that support this listener type.
-     *
-     * @param l the listener to add
-     * @param a  the Accessible object to add the PropertyChangeListener to
-     */
-
-    static void addPropertyChangeListener(PropertyChangeListener l, Accessible a) {
-        if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) {
-            accessibilityListener.installListeners(a);
-        }
-        listenerList.add(PropertyChangeListener.class, l);
-    }
-
-    /**
-     * AccessibilityEventListener is the class that does all the work for
-     * AccessibilityEventMonitor.  It is not intended for use by any other
-     * class except AccessibilityEventMonitor.
-     */
-
-    private static class AccessibilityEventListener implements PropertyChangeListener {
-
-        /**
-         * Installs PropertyChange listeners to the Accessible object, and its
-         * children (so long as the object isn't of TRANSIENT state).
-         *
-         * @param a the Accessible object to add listeners to
-         */
-        private void installListeners(Accessible a) {
-            installListeners(a.getAccessibleContext());
-        }
-
-        /**
-         * Installs PropertyChange listeners to the AccessibleContext object,
-         * and its * children (so long as the object isn't of TRANSIENT state).
-         *
-         * @param ac the AccessibleContext to add listeners to
-         */
-        private void installListeners(AccessibleContext ac) {
-
-            if (ac != null) {
-                AccessibleStateSet states = ac.getAccessibleStateSet();
-                if (!states.contains(AccessibleState.TRANSIENT)) {
-                    ac.addPropertyChangeListener(this);
-                    /*
-                     * Don't add listeners to transient children. Components
-                     * with transient children should return an AccessibleStateSet
-                     * containing AccessibleState.MANAGES_DESCENDANTS. Components
-                     * may not explicitly return the MANAGES_DESCENDANTS state.
-                     * In this case, don't add listeners to the children of
-                     * lists, tables and trees.
-                     */
-                    AccessibleStateSet set = ac.getAccessibleStateSet();
-                    if (set.contains(AccessibleState.MANAGES_DESCENDANTS)) {
-                        return;
-                    }
-                    AccessibleRole role = ac.getAccessibleRole();
-                    if ( role == AccessibleRole.LIST ||
-                         role == AccessibleRole.TREE ) {
-                        return;
-                    }
-                    if (role == AccessibleRole.TABLE) {
-                        // handle Oracle tables containing tables
-                        Accessible child = ac.getAccessibleChild(0);
-                        if (child != null) {
-                            AccessibleContext ac2 = child.getAccessibleContext();
-                            if (ac2 != null) {
-                                role = ac2.getAccessibleRole();
-                                if (role != null && role != AccessibleRole.TABLE) {
-                                    return;
-                                }
-                            }
-                        }
-                    }
-                    int count = ac.getAccessibleChildrenCount();
-                    for (int i = 0; i < count; i++) {
-                        Accessible child = ac.getAccessibleChild(i);
-                        if (child != null) {
-                            installListeners(child);
-                        }
-                    }
-                }
-            }
-        }
-
-        /**
-         * Removes PropertyChange listeners for the given Accessible object,
-         * its children (so long as the object isn't of TRANSIENT state).
-         *
-         * @param a the Accessible object to remove listeners from
-         */
-        private void removeListeners(Accessible a) {
-            removeListeners(a.getAccessibleContext());
-        }
-
-        /**
-         * Removes PropertyChange listeners for the given AccessibleContext
-         * object, its children (so long as the object isn't of TRANSIENT
-         * state).
-         *
-         * @param a the Accessible object to remove listeners from
-         */
-        private void removeListeners(AccessibleContext ac) {
-
-            if (ac != null) {
-                // Listeners are not added to transient components.
-                AccessibleStateSet states = ac.getAccessibleStateSet();
-                if (!states.contains(AccessibleState.TRANSIENT)) {
-                    ac.removePropertyChangeListener(this);
-                    /*
-                     * Listeners are not added to transient children. Components
-                     * with transient children should return an AccessibleStateSet
-                     * containing AccessibleState.MANAGES_DESCENDANTS. Components
-                     * may not explicitly return the MANAGES_DESCENDANTS state.
-                     * In this case, don't remove listeners from the children of
-                     * lists, tables and trees.
-                     */
-                    if (states.contains(AccessibleState.MANAGES_DESCENDANTS)) {
-                        return;
-                    }
-                    AccessibleRole role = ac.getAccessibleRole();
-                    if ( role == AccessibleRole.LIST ||
-                         role == AccessibleRole.TABLE ||
-                         role == AccessibleRole.TREE ) {
-                        return;
-                    }
-                    int count = ac.getAccessibleChildrenCount();
-                    for (int i = 0; i < count; i++) {
-                        Accessible child = ac.getAccessibleChild(i);
-                        if (child != null) {
-                            removeListeners(child);
-                        }
-                    }
-                }
-            }
-        }
-
-        @Override
-        public void propertyChange(PropertyChangeEvent e) {
-            // propogate the event
-            Object[] listeners =
-                AccessibilityEventMonitor.listenerList.getListenerList();
-            for (int i = listeners.length-2; i>=0; i-=2) {
-                if (listeners[i]==PropertyChangeListener.class) {
-                    ((PropertyChangeListener)listeners[i+1]).propertyChange(e);
-                }
-            }
-
-            // handle childbirth/death
-            String name = e.getPropertyName();
-            if (name.compareTo(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY) == 0) {
-                Object oldValue = e.getOldValue();
-                Object newValue = e.getNewValue();
-
-                if ((oldValue == null) ^ (newValue == null)) { // one null, not both
-                    if (oldValue != null) {
-                        // this Accessible is a child that's going away
-                        if (oldValue instanceof Accessible) {
-                            Accessible a = (Accessible) oldValue;
-                            removeListeners(a.getAccessibleContext());
-                        } else if (oldValue instanceof AccessibleContext) {
-                            removeListeners((AccessibleContext) oldValue);
-                        }
-                    } else if (newValue != null) {
-                        // this Accessible is a child was just born
-                        if (newValue instanceof Accessible) {
-                            Accessible a = (Accessible) newValue;
-                            installListeners(a.getAccessibleContext());
-                        } else if (newValue instanceof AccessibleContext) {
-                            installListeners((AccessibleContext) newValue);
-                        }
-                    }
-                } else {
-                    System.out.println("ERROR in usage of PropertyChangeEvents for: " + e.toString());
-                }
-            }
-        }
-    }
-}
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java	Tue Jul 26 14:45:11 2016 -0700
@@ -285,7 +285,7 @@
     }
 
     public static int getAccessibleIndexInParent(final Accessible a, final Component c) {
-        if (a == null) return 0;
+        if (a == null) return -1;
 
         return invokeAndWait(new Callable<Integer>() {
             public Integer call() throws Exception {
@@ -468,6 +468,24 @@
         }, c);
     }
 
+    public static void requestSelection(final Accessible a, final Component c) {
+        if (a == null) return;
+        invokeLater(new Runnable() {
+            public void run() {
+                AccessibleContext ac = a.getAccessibleContext();
+                if (ac == null) return;
+                int i = ac.getAccessibleIndexInParent();
+                if (i == -1) return;
+                Accessible parent = ac.getAccessibleParent();
+                AccessibleContext pac = parent.getAccessibleContext();
+                if (pac == null) return;
+                AccessibleSelection as = pac.getAccessibleSelection();
+                if (as == null) return;
+                as.addAccessibleSelection(i);
+            }
+        }, c);
+    }
+
     public static Number getMaximumAccessibleValue(final Accessible a, final Component c) {
         if (a == null) return null;
 
@@ -572,9 +590,57 @@
         if (a == null) return null;
         return invokeAndWait(new Callable<Object[]>() {
             public Object[] call() throws Exception {
-                final ArrayList<Object> childrenAndRoles = new ArrayList<Object>();
+                ArrayList<Object> childrenAndRoles = new ArrayList<Object>();
                 _addChildren(a, whichChildren, allowIgnored, childrenAndRoles);
 
+                /* In the case of fetching a selection, need to check to see if
+                 * the active descendant is at the beginning of the list.  If it
+                 * is not it needs to be moved to the beginning of the list so
+                 * VoiceOver will annouce it correctly.  The list returned
+                 * from Java is always in order from top to bottom, but when shift
+                 * selecting downward (extending the list) or multi-selecting using
+                 * the VO keys control+option+command+return the active descendant
+                 * is not at the top of the list in the shift select down case and
+                 * may not be in the multi select case.
+                 */
+                if (whichChildren == JAVA_AX_SELECTED_CHILDREN) {
+                    if (!childrenAndRoles.isEmpty()) {
+                        AccessibleContext activeDescendantAC =
+                            CAccessible.getActiveDescendant(a);
+                        if (activeDescendantAC != null) {
+                            String activeDescendantName =
+                                activeDescendantAC.getAccessibleName();
+                            AccessibleRole activeDescendantRole =
+                                activeDescendantAC.getAccessibleRole();
+                            // Move active descendant to front of list.
+                            // List contains pairs of each selected item's
+                            // Accessible and AccessibleRole.
+                            ArrayList<Object> newArray  = new ArrayList<Object>();
+                            int count = childrenAndRoles.size();
+                            Accessible currentAccessible = null;
+                            AccessibleContext currentAC = null;
+                            String currentName = null;
+                            AccessibleRole currentRole = null;
+                            for (int i = 0; i < count; i+=2) {
+                                // Is this the active descendant?
+                                currentAccessible = (Accessible)childrenAndRoles.get(i);
+                                currentAC = currentAccessible.getAccessibleContext();
+                                currentName = currentAC.getAccessibleName();
+                                currentRole = (AccessibleRole)childrenAndRoles.get(i+1);
+                                if ( currentName.equals(activeDescendantName) &&
+                                     currentRole.equals(activeDescendantRole) ) {
+                                    newArray.add(0, currentAccessible);
+                                    newArray.add(1, currentRole);
+                                } else {
+                                    newArray.add(currentAccessible);
+                                    newArray.add(currentRole);
+                                }
+                            }
+                            childrenAndRoles = newArray;
+                        }
+                    }
+                }
+
                 if ((whichChildren < 0) || (whichChildren * 2 >= childrenAndRoles.size())) {
                     return childrenAndRoles.toArray();
                 }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java	Tue Jul 26 14:45:11 2016 -0700
@@ -37,7 +37,11 @@
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
-import sun.lwawt.macosx.CFRetainedResource;
+import static javax.accessibility.AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY;
+import static javax.accessibility.AccessibleContext.ACCESSIBLE_CARET_PROPERTY;
+import static javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY;
+import static javax.accessibility.AccessibleContext.ACCESSIBLE_TEXT_PROPERTY;
+
 
 class CAccessible extends CFRetainedResource implements Accessible {
     static Field getNativeAXResourceField() {
@@ -71,10 +75,13 @@
 
     private static native void unregisterFromCocoaAXSystem(long ptr);
     private static native void valueChanged(long ptr);
+    private static native void selectedTextChanged(long ptr);
     private static native void selectionChanged(long ptr);
 
     private Accessible accessible;
 
+    private AccessibleContext activeDescendant;
+
     private CAccessible(final Accessible accessible) {
         super(0L, true); // real pointer will be poked in by native
 
@@ -98,9 +105,9 @@
     }
 
     public void addNotificationListeners(Component c) {
-        AXTextChangeNotifier listener = new AXTextChangeNotifier();
         if (c instanceof Accessible) {
-            AccessibilityEventMonitor.addPropertyChangeListener(listener, (Accessible)c);
+            AccessibleContext ac = ((Accessible)c).getAccessibleContext();
+            ac.addPropertyChangeListener(new AXChangeNotifier());
         }
         if (c instanceof JProgressBar) {
             JProgressBar pb = (JProgressBar) c;
@@ -112,16 +119,23 @@
     }
 
 
-    private class AXTextChangeNotifier implements PropertyChangeListener {
+    private class AXChangeNotifier implements PropertyChangeListener {
 
         @Override
         public void propertyChange(PropertyChangeEvent e) {
             String name = e.getPropertyName();
             if ( ptr != 0 ) {
-                if (name.compareTo(AccessibleContext.ACCESSIBLE_CARET_PROPERTY) == 0) {
+                if (name.compareTo(ACCESSIBLE_CARET_PROPERTY) == 0) {
+                    selectedTextChanged(ptr);
+                } else if (name.compareTo(ACCESSIBLE_TEXT_PROPERTY) == 0 ) {
+                    valueChanged(ptr);
+                } else if (name.compareTo(ACCESSIBLE_SELECTION_PROPERTY) == 0 ) {
                     selectionChanged(ptr);
-                } else if (name.compareTo(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY) == 0 ) {
-                    valueChanged(ptr);
+                }  else if (name.compareTo(ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY) == 0 ) {
+                    Object nv = e.getNewValue();
+                    if (nv instanceof AccessibleContext) {
+                        activeDescendant = (AccessibleContext)nv;
+                    }
                 }
             }
         }
@@ -137,4 +151,9 @@
     static Accessible getSwingAccessible(final Accessible a) {
         return (a instanceof CAccessible) ? ((CAccessible)a).accessible : a;
     }
+
+    static AccessibleContext getActiveDescendant(final Accessible a) {
+        return (a instanceof CAccessible) ? ((CAccessible)a).activeDescendant : null;
+    }
+
 }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Tue Jul 26 14:45:11 2016 -0700
@@ -135,6 +135,7 @@
         int jkeyCode = KeyEvent.VK_UNDEFINED;
         int jkeyLocation = KeyEvent.KEY_LOCATION_UNKNOWN;
         boolean postsTyped = false;
+        boolean spaceKeyTyped = false;
 
         char testChar = KeyEvent.CHAR_UNDEFINED;
         boolean isDeadChar = (chars!= null && chars.length() == 0);
@@ -151,6 +152,11 @@
         } else {
             if (chars != null && chars.length() > 0) {
                 testChar = chars.charAt(0);
+
+                //Check if String chars contains SPACE character.
+                if (chars.trim().isEmpty()) {
+                    spaceKeyTyped = true;
+                }
             }
 
             char testCharIgnoringModifiers = charsIgnoringModifiers != null && charsIgnoringModifiers.length() > 0 ?
@@ -187,7 +193,7 @@
                                            NSEvent.nsToJavaEventType(eventType);
         }
 
-        char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags);
+        char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags, spaceKeyTyped);
         // Some keys may generate a KEY_TYPED, but we can't determine
         // what that character is. That's likely a bug, but for now we
         // just check for CHAR_UNDEFINED.
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java	Tue Jul 26 14:45:11 2016 -0700
@@ -254,7 +254,7 @@
      * There is a small number of NS characters that need to be converted
      * into other characters before we pass them to AWT.
      */
-    static native char nsToJavaChar(char nsChar, int modifierFlags);
+    static native char nsToJavaChar(char nsChar, int modifierFlags, boolean spaceKeyTyped);
 
     static boolean isPopupTrigger(int jmodifiers) {
         final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m	Tue Jul 26 14:45:11 2016 -0700
@@ -278,6 +278,16 @@
         java_awt_event_KeyEvent_VK_CONTROL
     },
     {
+        NSCommandKeyMask,
+        //kCGSFlagsMaskAppleLeftCommandKey,
+        //kCGSFlagsMaskAppleRightCommandKey,
+        55,
+        54,
+        java_awt_event_InputEvent_META_DOWN_MASK,
+        java_awt_event_InputEvent_META_MASK,
+        java_awt_event_KeyEvent_VK_META
+    },
+    {
         NSAlternateKeyMask,
         //kCGSFlagsMaskAppleLeftAlternateKey,
         //kCGSFlagsMaskAppleRightAlternateKey,
@@ -295,16 +305,6 @@
         java_awt_event_InputEvent_ALT_MASK | java_awt_event_InputEvent_ALT_GRAPH_MASK,
         java_awt_event_KeyEvent_VK_ALT | java_awt_event_KeyEvent_VK_ALT_GRAPH
     },
-	{
-		NSCommandKeyMask,
-		//kCGSFlagsMaskAppleLeftCommandKey,
-		//kCGSFlagsMaskAppleRightCommandKey,
-		55,
-		54,
-		java_awt_event_InputEvent_META_DOWN_MASK,
-		java_awt_event_InputEvent_META_MASK,
-		java_awt_event_KeyEvent_VK_META
-	},
     // NSNumericPadKeyMask
     {
         NSHelpKeyMask,
@@ -319,6 +319,7 @@
 };
 
 static BOOL leftAltKeyPressed;
+static BOOL altGRPressed = NO;
 
 /*
  * Almost all unicode characters just go from NS to Java with no translation.
@@ -349,7 +350,7 @@
     {0, 0, 0}
 };
 
-unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
+unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers, BOOL spaceKeyTyped)
 {
     const struct _char *cur;
     // Mask off just the keyboard modifiers from the event modifier mask.
@@ -382,6 +383,11 @@
         return java_awt_event_KeyEvent_CHAR_UNDEFINED;
     }
 
+    // nsChar receives value 0 when SPACE key is typed.
+    if (nsChar == 0 && spaceKeyTyped == YES) {
+        return java_awt_event_KeyEvent_VK_SPACE;
+    }
+	
     // otherwise return character unchanged
     return nsChar;
 }
@@ -554,20 +560,28 @@
  */
 jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods)
 {
-	jint javaModifiers = 0;
-	const struct _nsKeyToJavaModifier* cur;
+    jint javaModifiers = 0;
+    const struct _nsKeyToJavaModifier* cur;
 	
-	for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
-		if ((cur->nsMask & nsFlags) != 0) {
-				javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask;
-				if (cur->nsMask == NSAlternateKeyMask && leftAltKeyPressed == NO) {
-					continue;
-			}
-			break;
-		}
-	}
+    for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
+        if ((cur->nsMask & nsFlags) != 0) {
+			
+            if (cur->nsMask == NSAlternateKeyMask) {
+                if (leftAltKeyPressed == YES) {
+                    javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask;
+                    if (altGRPressed == NO)
+                        break;
+                    } else {
+                        leftAltKeyPressed = YES;
+                        altGRPressed = YES;
+                        continue;
+                    }
+                }
+            javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask;
+        }
+    }
 
-	return javaModifiers;
+    return javaModifiers;
 }
 
 /*
@@ -757,13 +771,13 @@
  */
 JNIEXPORT jint JNICALL
 Java_sun_lwawt_macosx_NSEvent_nsToJavaChar
-(JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags)
+(JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags, jboolean spaceKeyTyped)
 {
     jchar javaChar = 0;
 
 JNF_COCOA_ENTER(env);
 
-    javaChar = NsCharToJavaChar(nsChar, modifierFlags);
+    javaChar = NsCharToJavaChar(nsChar, modifierFlags, spaceKeyTyped);
 
 JNF_COCOA_EXIT(env);
 
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m	Tue Jul 26 14:45:11 2016 -0700
@@ -261,27 +261,10 @@
 {
     CGKeyCode keyCode = GetCGKeyCode(javaKeyCode);
 
-    if ((javaKeyCode >= java_awt_event_KeyEvent_VK_0) &&
-		(javaKeyCode <= java_awt_event_KeyEvent_VK_9))
-    {
-        AXUIElementRef elem = AXUIElementCreateSystemWide();
-        AXUIElementPostKeyboardEvent(elem, (CGCharCode)0, keyCode, keyPressed);
-        CFRelease(elem);
-    } else {
-        /*
-         * JDK-8155740: AXUIElementPostKeyboardEvent posts correct key codes for
-         * number keys whereas CGEventPost posts Numpad keys for corresponding
-         * number key. Hence AXUIElementPostKeyboardEvent is used for posting
-         * numbers and CGEventCreateKeyboardEvent/CGEventPost is used for other
-         * keys.
-         * Key code for modifier key is required to distinguish between ALT and
-         * ALT-GR key for fixing issue 8155740.
-         */
-        CGEventRef event = CGEventCreateKeyboardEvent(NULL, keyCode, keyPressed);
-        if (event != NULL) {
-            CGEventPost(kCGSessionEventTap, event);
-            CFRelease(event);
-        }
+    CGEventRef event = CGEventCreateKeyboardEvent(NULL, keyCode, keyPressed);
+    if (event != NULL) {
+        CGEventPost(kCGSessionEventTap, event);
+        CFRelease(event);
     }
 }
 
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityAction.m	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityAction.m	Tue Jul 26 14:45:11 2016 -0700
@@ -63,16 +63,20 @@
 
     jobject fCompLocal = (*env)->NewLocalRef(env, fComponent);
     if ((*env)->IsSameObject(env, fCompLocal, NULL)) {
-        return @"unknown";
+        return nil;
     }
     NSString *str = nil;
-    jobject jstr = JNFCallStaticObjectMethod(env, jm_getAccessibleActionDescription, fAccessibleAction, fIndex, fCompLocal);
+    jstring jstr = JNFCallStaticObjectMethod( env,
+                                              jm_getAccessibleActionDescription,
+                                              fAccessibleAction,
+                                              fIndex,
+                                              fCompLocal );
     if (jstr != NULL) {
-        NSString *str = JNFJavaToNSString(env, jstr); // AWT_THREADING Safe (AWTRunLoopMode)
+        str = JNFJavaToNSString(env, jstr); // AWT_THREADING Safe (AWTRunLoopMode)
         (*env)->DeleteLocalRef(env, jstr);
     }
     (*env)->DeleteLocalRef(env, fCompLocal);
-    return str == nil ? @"unknown" : str;
+    return str;
 }
 
 - (void)perform
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.h	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.h	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -55,6 +55,7 @@
 BOOL isVertical(JNIEnv *env, jobject axContext, jobject component);
 BOOL isHorizontal(JNIEnv *env, jobject axContext, jobject component);
 BOOL isShowing(JNIEnv *env, jobject axContext, jobject component);
+BOOL isSelectable(JNIEnv *env, jobject axContext, jobject component);
 NSPoint getAxComponentLocationOnScreen(JNIEnv *env, jobject axComponent, jobject component);
 jint getAxTextCharCount(JNIEnv *env, jobject axText, jobject component);
 
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m	Tue Jul 26 14:45:11 2016 -0700
@@ -151,6 +151,18 @@
     return showing;
 }
 
+BOOL isSelectable(JNIEnv *env, jobject axContext, jobject component)
+{
+    static JNF_STATIC_MEMBER_CACHE( jm_SELECTABLE,
+                                    sjc_AccessibleState,
+                                    "SELECTABLE",
+                                    "Ljavax/accessibility/AccessibleState;" );
+    jobject axSelectableState = JNFGetStaticObjectField(env, jm_SELECTABLE);
+    BOOL selectable = containsAxState(env, axContext, axSelectableState, component);
+    (*env)->DeleteLocalRef(env, axSelectableState);
+    return selectable;
+}
+
 NSPoint getAxComponentLocationOnScreen(JNIEnv *env, jobject axComponent, jobject component)
 {
     static JNF_STATIC_MEMBER_CACHE(jm_getLocationOnScreen, sjc_CAccessibility, "getLocationOnScreen", "(Ljavax/accessibility/AccessibleComponent;Ljava/awt/Component;)Ljava/awt/Point;");
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.h	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.h	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -50,6 +50,7 @@
 - (id)initWithParent:(NSObject*)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole;
 - (void)unregisterFromCocoaAXSystem;
 - (void)postValueChanged;
+- (void)postSelectedTextChanged;
 - (void)postSelectionChanged;
 - (BOOL)isEqual:(id)anObject;
 - (BOOL)isAccessibleWithEnv:(JNIEnv *)env forAccessible:(jobject)accessible;
@@ -71,6 +72,7 @@
 - (NSString *)javaRole;
 - (BOOL)isMenu;
 - (BOOL)isSelected:(JNIEnv *)env;
+- (BOOL)isSelectable:(JNIEnv *)env;
 - (BOOL)isVisible:(JNIEnv *)env;
 
 // attribute names
@@ -85,6 +87,8 @@
 - (NSArray *)accessibilityChildrenAttribute;
 - (BOOL)accessibilityIsChildrenAttributeSettable;
 - (NSUInteger)accessibilityIndexOfChild:(id)child;
+- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute
+    index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
 - (NSNumber *)accessibilityEnabledAttribute;
 - (BOOL)accessibilityIsEnabledAttributeSettable;
 - (NSNumber *)accessibilityFocusedAttribute;
@@ -92,6 +96,8 @@
 - (void)accessibilitySetFocusedAttribute:(id)value;
 - (NSString *)accessibilityHelpAttribute;
 - (BOOL)accessibilityIsHelpAttributeSettable;
+- (NSValue *)accessibilityIndexAttribute;
+- (BOOL)accessibilityIsIndexAttributeSettable;
 - (id)accessibilityMaxValueAttribute;
 - (BOOL)accessibilityIsMaxValueAttributeSettable;
 - (id)accessibilityMinValueAttribute;
@@ -108,6 +114,9 @@
 - (BOOL)accessibilityIsRoleDescriptionAttributeSettable;
 - (NSArray *)accessibilitySelectedChildrenAttribute;
 - (BOOL)accessibilityIsSelectedChildrenAttributeSettable;
+- (NSNumber *)accessibilitySelectedAttribute;
+- (BOOL)accessibilityIsSelectedAttributeSettable;
+- (void)accessibilitySetSelectedAttribute:(id)value;
 - (NSValue *)accessibilitySizeAttribute;
 - (BOOL)accessibilityIsSizeAttributeSettable;
 - (NSString *)accessibilitySubroleAttribute;
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m	Tue Jul 26 14:45:11 2016 -0700
@@ -201,10 +201,16 @@
     NSAccessibilityPostNotification(self, NSAccessibilityValueChangedNotification);
 }
 
+- (void)postSelectedTextChanged
+{
+    AWT_ASSERT_APPKIT_THREAD;
+    NSAccessibilityPostNotification(self, NSAccessibilitySelectedTextChangedNotification);
+}
+
 - (void)postSelectionChanged
 {
     AWT_ASSERT_APPKIT_THREAD;
-    NSAccessibilityPostNotification(self, NSAccessibilitySelectedTextChangedNotification);
+    NSAccessibilityPostNotification(self, NSAccessibilitySelectedChildrenChangedNotification);
 }
 
 - (BOOL)isEqual:(id)anObject
@@ -225,7 +231,7 @@
 {
     if (sAttributeNamesForRoleCache == nil) {
         sAttributeNamesLOCK = [[NSObject alloc] init];
-        sAttributeNamesForRoleCache = [[NSMutableDictionary alloc] initWithCapacity:10];
+        sAttributeNamesForRoleCache = [[NSMutableDictionary alloc] initWithCapacity:60];
     }
 
     if (sRoles == nil) {
@@ -281,6 +287,7 @@
 
 + (NSArray *)childrenOfParent:(JavaComponentAccessibility *)parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored
 {
+    if (parent->fAccessible == NULL) return nil;
     jobjectArray jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, parent->fAccessible, parent->fComponent, whichChildren, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
     if (jchildrenAndRoles == NULL) return nil;
 
@@ -370,7 +377,7 @@
 {
     static JNF_STATIC_MEMBER_CACHE(jm_getInitialAttributeStates, sjc_CAccessibility, "getInitialAttributeStates", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[Z");
 
-    NSMutableArray *attributeNames = [NSMutableArray arrayWithCapacity:10];
+    NSMutableArray *attributeNames = [NSMutableArray arrayWithCapacity:20];
     [attributeNames retain];
 
     // all elements respond to parent, role, role description, window, topLevelUIElement, help
@@ -449,6 +456,12 @@
     // children
     if (attributeStatesArray[6]) {
         [attributeNames addObject:NSAccessibilityChildrenAttribute];
+        if ([javaRole isEqualToString:@"list"]) {
+            [attributeNames addObject:NSAccessibilitySelectedChildrenAttribute];
+            [attributeNames addObject:NSAccessibilityVisibleChildrenAttribute];
+        }
+        // Just above, the below mentioned support has been added back in for lists.
+        // However, the following comments may still be useful for future fixes.
 //        [attributeNames addObject:NSAccessibilitySelectedChildrenAttribute];
 //        [attributeNames addObject:NSAccessibilityVisibleChildrenAttribute];
                 //According to AXRoles.txt:
@@ -567,6 +580,14 @@
     return isChildSelected(env, ((JavaComponentAccessibility *)[self parent])->fAccessible, fIndex, fComponent);
 }
 
+- (BOOL)isSelectable:(JNIEnv *)env
+{
+    jobject axContext = [self axContextWithEnv:env];
+    BOOL selectable = isSelectable(env, axContext, fComponent);
+    (*env)->DeleteLocalRef(env, axContext);
+    return selectable;
+}
+
 - (BOOL)isVisible:(JNIEnv *)env
 {
     if (fIndex == -1) {
@@ -586,18 +607,32 @@
 
     @synchronized(sAttributeNamesLOCK) {
         NSString *javaRole = [self javaRole];
-        NSArray *names = (NSArray *)[sAttributeNamesForRoleCache objectForKey:javaRole];
-        if (names != nil) return names;
-
-        names = [self initializeAttributeNamesWithEnv:env];
-        if (names != nil) {
+        NSArray *names =
+            (NSArray *)[sAttributeNamesForRoleCache objectForKey:javaRole];
+        if (names == nil) {
+            names = [self initializeAttributeNamesWithEnv:env];
 #ifdef JAVA_AX_DEBUG
             NSLog(@"Initializing: %s for %@: %@", __FUNCTION__, javaRole, names);
 #endif
             [sAttributeNamesForRoleCache setObject:names forKey:javaRole];
-            return names;
         }
-    }
+        // The above set of attributes is immutable per role, but some objects, if
+        // they are the child of a list, need to add the selected and index attributes.
+        id myParent = [self accessibilityParentAttribute];
+        if ([myParent isKindOfClass:[JavaComponentAccessibility class]]) {
+            NSString *parentRole = [(JavaComponentAccessibility *)myParent javaRole];
+            if ([parentRole isEqualToString:@"list"]) {
+                NSMutableArray *moreNames =
+                    [[NSMutableArray alloc] initWithCapacity: [names count] + 2];
+                [moreNames addObjectsFromArray: names];
+                [moreNames addObject:NSAccessibilitySelectedAttribute];
+                [moreNames addObject:NSAccessibilityIndexAttribute];
+                return moreNames;
+            }
+        }
+        return names;
+
+    }  // end @synchronized
 
 #ifdef JAVA_AX_DEBUG
     NSLog(@"Warning in %s: could not find attribute names for role: %@", __FUNCTION__, [self javaRole]);
@@ -656,7 +691,10 @@
 - (NSArray *)accessibilityChildrenAttribute
 {
     JNIEnv* env = [ThreadUtilities getJNIEnv];
-    NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_VISIBLE_CHILDREN allowIgnored:NO];
+    NSArray *children = [JavaComponentAccessibility childrenOfParent:self
+                                                    withEnv:env
+                                                    withChildrenCode:JAVA_AX_ALL_CHILDREN
+                                                    allowIgnored:NO];
 
     NSArray *value = nil;
     if ([children count] > 0) {
@@ -680,7 +718,12 @@
         return [super accessibilityIndexOfChild:child];
     }
 
-    return JNFCallStaticIntMethod([ThreadUtilities getJNIEnv], sjm_getAccessibleIndexInParent, ((JavaComponentAccessibility *)child)->fAccessible, ((JavaComponentAccessibility *)child)->fComponent);
+    jint returnValue =
+        JNFCallStaticIntMethod( [ThreadUtilities getJNIEnv],
+                                sjm_getAccessibleIndexInParent,
+                                ((JavaComponentAccessibility *)child)->fAccessible,
+                                ((JavaComponentAccessibility *)child)->fComponent );
+    return (returnValue == -1) ? NSNotFound : returnValue;
 }
 
 // Without this optimization accessibilityChildrenAttribute is called in order to get the entire array of children.
@@ -754,7 +797,7 @@
 
     jobject val = JNFCallStaticObjectMethod(env, sjm_getAccessibleDescription, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
     if (val == NULL) {
-        return @"unknown";
+        return nil;
     }
     NSString* str = JNFJavaToNSString(env, val);
     (*env)->DeleteLocalRef(env, val);
@@ -766,6 +809,18 @@
     return NO;
 }
 
+- (NSValue *)accessibilityIndexAttribute
+{
+    NSInteger index = fIndex;
+    NSValue *returnValue = [NSValue value:&index withObjCType:@encode(NSInteger)];
+    return returnValue;
+}
+
+- (BOOL)accessibilityIsIndexAttributeSettable
+{
+    return NO;
+}
+
 // Element's maximum value (id)
 - (id)accessibilityMaxValueAttribute
 {
@@ -939,6 +994,33 @@
     return NO; // cmcnote: actually it should be. so need to write accessibilitySetSelectedChildrenAttribute also
 }
 
+- (NSNumber *)accessibilitySelectedAttribute
+{
+    return [NSNumber numberWithBool:[self isSelected:[ThreadUtilities getJNIEnv]]];
+}
+
+- (BOOL)accessibilityIsSelectedAttributeSettable
+{
+    if ([self isSelectable:[ThreadUtilities getJNIEnv]]) {
+        return YES;
+    } else {
+        return NO;
+    }
+}
+
+- (void)accessibilitySetSelectedAttribute:(id)value
+{
+    static JNF_STATIC_MEMBER_CACHE( jm_requestSelection,
+                                    sjc_CAccessibility,
+                                    "requestSelection",
+                                    "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V" );
+    
+    if ([(NSNumber*)value boolValue]) {
+        JNIEnv* env = [ThreadUtilities getJNIEnv];
+        JNFCallStaticVoidMethod(env, jm_requestSelection, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
+    }
+}
+
 // Element size (NSValue)
 - (NSValue *)accessibilitySizeAttribute {
     JNIEnv* env = [ThreadUtilities getJNIEnv];
@@ -1005,7 +1087,7 @@
 
     jobject val = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
     if (val == NULL) {
-        return @"unknown";
+        return nil;
     }
     NSString* str = JNFJavaToNSString(env, val);
     (*env)->DeleteLocalRef(env, val);
@@ -1210,14 +1292,11 @@
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessibility_focusChanged
 (JNIEnv *env, jobject jthis)
 {
-
 JNF_COCOA_ENTER(env);
     [ThreadUtilities performOnMainThread:@selector(postFocusChanged:) on:[JavaComponentAccessibility class] withObject:nil waitUntilDone:NO];
 JNF_COCOA_EXIT(env);
 }
 
-
-
 /*
  * Class:     sun_lwawt_macosx_CAccessible
  * Method:    valueChanged
@@ -1233,6 +1312,22 @@
 
 /*
  * Class:     sun_lwawt_macosx_CAccessible
+ * Method:    selectedTextChanged
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_selectedTextChanged
+(JNIEnv *env, jclass jklass, jlong element)
+{
+JNF_COCOA_ENTER(env);
+    [ThreadUtilities performOnMainThread:@selector(postSelectedTextChanged)
+                     on:(JavaComponentAccessibility *)jlong_to_ptr(element)
+                     withObject:nil
+                     waitUntilDone:NO];
+JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CAccessible
  * Method:    selectionChanged
  * Signature: (I)V
  */
@@ -1244,7 +1339,6 @@
 JNF_COCOA_EXIT(env);
 }
 
-
 /*
  * Class:     sun_lwawt_macosx_CAccessible
  * Method:    unregisterFromCocoaAXSystem
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaTextAccessibility.h	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaTextAccessibility.h	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -60,6 +60,4 @@
 - (NSValue *)accessibilityRangeForPositionAttributeForParameter:(id)parameter;
 - (NSValue *)accessibilityRangeForIndexAttributeForParameter:(id)parameter;
 
-// actions
-- (NSDictionary *)getActions:(JNIEnv *)env;
 @end
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaTextAccessibility.m	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaTextAccessibility.m	Tue Jul 26 14:45:11 2016 -0700
@@ -427,13 +427,15 @@
     return javaIntArrayToNSRangeValue(env, axTextRange);
 }
 
-- (NSDictionary *)getActions:(JNIEnv *)env {
-    // cmcnote: this isn't correct; text can have actions. Not yet implemented. radr://3941691
-    // Editable text has AXShowMenu. Textfields have AXConfirm. Static text has no actions.
-#ifdef JAVA_AX_DEBUG
-    NSLog(@"Not yet implemented: %s\n", __FUNCTION__);
-#endif
-    return nil;
-}
+/* 
+ * - (NSDictionary *)getActions:(JNIEnv *)env { ... }
+ *
+ * In the future, possibly add support: Editable text has AXShowMenu.
+ * Textfields have AXConfirm.
+ *
+ * Note: JLabels (static text) in JLists have a press/click selection action
+ *   which is currently handled in superclass JavaComponentAccessibility.
+ *   If function is added here be sure to use [super getActions:env] for JLabels.
+ */
 
 @end
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1339,14 +1339,14 @@
             Graphics g, int state, int x, int y, int w, int h) {
         ENGINE.paintExpander(g, context, Region.TREE,
                 GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state),
-                ExpanderStyle.EXPANDED, "treeview", x, y, w, h);
+                ExpanderStyle.EXPANDED, "expander", x, y, w, h);
     }
 
     public void paintTreeCollapsedIcon(SynthContext context,
             Graphics g, int state, int x, int y, int w, int h) {
         ENGINE.paintExpander(g, context, Region.TREE,
                 GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state),
-                ExpanderStyle.COLLAPSED, "treeview", x, y, w, h);
+                ExpanderStyle.COLLAPSED, "expander", x, y, w, h);
     }
 
     public void paintCheckBoxIcon(SynthContext context,
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Tue Jul 26 14:45:11 2016 -0700
@@ -854,6 +854,12 @@
             return indicatorSpacing + focusSize + focusPad;
         } else if (GTKLookAndFeel.is3() && "ComboBox.forceOpaque".equals(key)) {
             return true;
+        } else if ("Tree.expanderSize".equals(key)) {
+            Object value = getClassSpecificValue("expander-size");
+            if (value instanceof Integer) {
+                return (Integer)value + 4;
+            }
+            return null;
         }
 
         // Is it a stock icon ?
@@ -1136,7 +1142,6 @@
         CLASS_SPECIFIC_MAP.put("Slider.thumbWidth", "slider-length");
         CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border");
         CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size");
-        CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size");
         CLASS_SPECIFIC_MAP.put("ScrollBar.thumbHeight", "slider-width");
         CLASS_SPECIFIC_MAP.put("ScrollBar.width", "slider-width");
         CLASS_SPECIFIC_MAP.put("TextArea.caretForeground", "cursor-color");
--- a/jdk/src/java.desktop/share/classes/java/awt/Desktop.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/Desktop.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1013,8 +1013,8 @@
      * @param file the file
      * @return returns true if successfully moved the file to the trash.
      * @throws SecurityException If a security manager exists and its
-     *         {@link SecurityManager#checkWrite(java.lang.String)} method
-     *         denies write access to the file
+     *         {@link SecurityManager#checkDelete(java.lang.String)} method
+     *         denies deletion of the file
      * @throws UnsupportedOperationException if the current platform
      *         does not support the {@link Desktop.Action#MOVE_TO_TRASH} action
      * @throws NullPointerException if {@code file} is {@code null}
--- a/jdk/src/java.desktop/share/classes/java/awt/Font.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/Font.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1813,35 +1813,31 @@
             return true;
         }
 
-        if (obj != null) {
-            try {
-                Font font = (Font)obj;
-                if (size == font.size &&
-                    style == font.style &&
-                    nonIdentityTx == font.nonIdentityTx &&
-                    hasLayoutAttributes == font.hasLayoutAttributes &&
-                    pointSize == font.pointSize &&
-                    name.equals(font.name)) {
+        if (obj instanceof Font) {
+            Font font = (Font)obj;
+            if (size == font.size &&
+                style == font.style &&
+                nonIdentityTx == font.nonIdentityTx &&
+                hasLayoutAttributes == font.hasLayoutAttributes &&
+                pointSize == font.pointSize &&
+                name.equals(font.name)) {
 
-                    /* 'values' is usually initialized lazily, except when
-                     * the font is constructed from a Map, or derived using
-                     * a Map or other values. So if only one font has
-                     * the field initialized we need to initialize it in
-                     * the other instance and compare.
-                     */
-                    if (values == null) {
-                        if (font.values == null) {
-                            return true;
-                        } else {
-                            return getAttributeValues().equals(font.values);
-                        }
+                /* 'values' is usually initialized lazily, except when
+                 * the font is constructed from a Map, or derived using
+                 * a Map or other values. So if only one font has
+                 * the field initialized we need to initialize it in
+                 * the other instance and compare.
+                 */
+                if (values == null) {
+                    if (font.values == null) {
+                        return true;
                     } else {
-                        return values.equals(font.getAttributeValues());
+                        return getAttributeValues().equals(font.values);
                     }
+                } else {
+                    return values.equals(font.getAttributeValues());
                 }
             }
-            catch (ClassCastException e) {
-            }
         }
         return false;
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java	Tue Jul 26 14:45:11 2016 -0700
@@ -356,7 +356,7 @@
      *
      * Some platforms do not support string values and accept only integer
      * values. In this case, pass an integer represented as a string as parameter.
-     * This can be tested by {@code Feature.ICON_BADGE_STRING} and
+     * This can be tested by {@code Feature.ICON_BADGE_TEXT} and
      * {@code Feature.ICON_BADGE_NUMBER}.
      *
      * Passing {@code null} as parameter hides the badge.
@@ -364,7 +364,8 @@
      * @throws SecurityException if a security manager exists and it denies the
      * {@code AWTPermission("showWindowWithoutWarningBanner")} permission.
      * @throws UnsupportedOperationException if the current platform
-     * does not support the {@link Taskbar.Feature#ICON_BADGE_NUMBER} feature
+     * does not support the {@link Taskbar.Feature#ICON_BADGE_NUMBER}
+     * or {@link Taskbar.Feature#ICON_BADGE_TEXT} feature
      */
     public void setIconBadge(final String badge) {
         checkAWTPermission();
--- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1388,9 +1388,7 @@
         // ensure that the proper libraries are loaded
         loadLibraries();
         initAssistiveTechnologies();
-        if (!GraphicsEnvironment.isHeadless()) {
-            initIDs();
-        }
+        initIDs();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComboBox.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComboBox.java	Tue Jul 26 14:45:11 2016 -0700
@@ -168,6 +168,9 @@
     // Flag to ensure the we don't get multiple ActionEvents on item selection.
     private boolean selectingItem = false;
 
+    // Flag to indicate UI update is in progress
+    private transient boolean updateInProgress;
+
     /**
      * Creates a <code>JComboBox</code> that takes its items from an
      * existing <code>ComboBoxModel</code>.  Since the
@@ -268,11 +271,18 @@
      * @see JComponent#updateUI
      */
     public void updateUI() {
-        setUI((ComboBoxUI)UIManager.getUI(this));
+        if (!updateInProgress) {
+            updateInProgress = true;
+            try {
+                setUI((ComboBoxUI)UIManager.getUI(this));
 
-        ListCellRenderer<? super E> renderer = getRenderer();
-        if (renderer instanceof Component) {
-            SwingUtilities.updateComponentTreeUI((Component)renderer);
+                ListCellRenderer<? super E> renderer = getRenderer();
+                if (renderer instanceof Component) {
+                    SwingUtilities.updateComponentTreeUI((Component)renderer);
+                }
+            } finally {
+                updateInProgress = false;
+            }
         }
     }
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/JList.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JList.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -338,6 +338,11 @@
     private transient DropLocation dropLocation;
 
     /**
+     * Flag to indicate UI update is in progress
+     */
+    private transient boolean updateInProgress;
+
+    /**
      * A subclass of <code>TransferHandler.DropLocation</code> representing
      * a drop location for a <code>JList</code>.
      *
@@ -531,11 +536,18 @@
      * @see SwingUtilities#updateComponentTreeUI
      */
     public void updateUI() {
-        setUI((ListUI)UIManager.getUI(this));
-
-        ListCellRenderer<? super E> renderer = getCellRenderer();
-        if (renderer instanceof Component) {
-            SwingUtilities.updateComponentTreeUI((Component)renderer);
+        if (!updateInProgress) {
+            updateInProgress = true;
+            try {
+                setUI((ListUI)UIManager.getUI(this));
+
+                ListCellRenderer<? super E> renderer = getCellRenderer();
+                if (renderer instanceof Component) {
+                    SwingUtilities.updateComponentTreeUI((Component)renderer);
+                }
+            } finally {
+                updateInProgress = false;
+            }
         }
     }
 
@@ -3046,7 +3058,7 @@
         public Accessible getAccessibleAt(Point p) {
             int i = locationToIndex(p);
             if (i >= 0) {
-                return new AccessibleJListChild(JList.this, i);
+                return new ActionableAccessibleJListChild(JList.this, i);
             } else {
                 return null;
             }
@@ -3073,7 +3085,7 @@
             if (i >= getModel().getSize()) {
                 return null;
             } else {
-                return new AccessibleJListChild(JList.this, i);
+                return new ActionableAccessibleJListChild(JList.this, i);
             }
         }
 
@@ -3178,7 +3190,7 @@
         protected class AccessibleJListChild extends AccessibleContext
                 implements Accessible, AccessibleComponent {
             private JList<E>     parent = null;
-            private int       indexInParent;
+            int indexInParent;
             private Component component = null;
             private AccessibleContext accessibleContext = null;
             private ListModel<E> listModel;
@@ -3203,7 +3215,7 @@
                 return getComponentAtIndex(indexInParent);
             }
 
-            private AccessibleContext getCurrentAccessibleContext() {
+            AccessibleContext getCurrentAccessibleContext() {
                 Component c = getComponentAtIndex(indexInParent);
                 if (c instanceof Accessible) {
                     return c.getAccessibleContext();
@@ -3369,10 +3381,6 @@
                 }
             }
 
-            public AccessibleAction getAccessibleAction() {
-                return getCurrentAccessibleContext().getAccessibleAction();
-            }
-
            /**
             * Get the AccessibleComponent associated with this object.  In the
             * implementation of the Java Accessibility API for this class,
@@ -3587,7 +3595,13 @@
 
             public Point getLocationOnScreen() {
                 if (parent != null) {
-                    Point listLocation = parent.getLocationOnScreen();
+                    Point listLocation;
+                    try {
+                        listLocation = parent.getLocationOnScreen();
+                    } catch (IllegalComponentStateException e) {
+                        // This can happen if the component isn't visisble
+                        return null;
+                    }
                     Point componentLocation = parent.indexToLocation(indexInParent);
                     if (componentLocation != null) {
                         componentLocation.translate(listLocation.x, listLocation.y);
@@ -3728,6 +3742,57 @@
                     return null;
                 }
             }
+
         } // inner class AccessibleJListChild
+
+        private class ActionableAccessibleJListChild
+            extends AccessibleJListChild
+            implements AccessibleAction {
+
+            ActionableAccessibleJListChild(JList<E> parent, int indexInParent) {
+                super(parent, indexInParent);
+            }
+
+            @Override
+            public AccessibleAction getAccessibleAction() {
+                AccessibleContext ac = getCurrentAccessibleContext();
+                if (ac == null) {
+                    return null;
+                } else {
+                    AccessibleAction aa = ac.getAccessibleAction();
+                    if (aa != null) {
+                        return aa;
+                    } else {
+                        return this;
+                    }
+                }
+            }
+
+            @Override
+            public boolean doAccessibleAction(int i) {
+                if (i == 0) {
+                    JList.this.setSelectedIndex(indexInParent);
+                    return true;
+                } else {
+                    return false;
+                }
+            }
+
+            @Override
+            public String getAccessibleActionDescription(int i) {
+                if (i == 0) {
+                    return UIManager.getString("AbstractButton.clickText");
+                } else {
+                    return null;
+                }
+            }
+
+            @Override
+            public int getAccessibleActionCount() {
+                return 1;
+            }
+
+        } // inner class ActionableAccessibleJListChild
+
     } // inner class AccessibleJList
 }
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java	Tue Jul 26 14:45:11 2016 -0700
@@ -455,6 +455,11 @@
     private transient DropLocation dropLocation;
 
     /**
+     * Flag to indicate UI update is in progress
+     */
+    private transient boolean updateInProgress;
+
+    /**
      * A subclass of <code>TransferHandler.DropLocation</code> representing
      * a drop location for a <code>JTable</code>.
      *
@@ -3621,36 +3626,46 @@
      * @see JComponent#updateUI
      */
     public void updateUI() {
-        // Update the UIs of the cell renderers, cell editors and header renderers.
-        TableColumnModel cm = getColumnModel();
-        for(int column = 0; column < cm.getColumnCount(); column++) {
-            TableColumn aColumn = cm.getColumn(column);
-            SwingUtilities.updateRendererOrEditorUI(aColumn.getCellRenderer());
-            SwingUtilities.updateRendererOrEditorUI(aColumn.getCellEditor());
-            SwingUtilities.updateRendererOrEditorUI(aColumn.getHeaderRenderer());
-        }
-
-        // Update the UIs of all the default renderers.
-        Enumeration<?> defaultRenderers = defaultRenderersByColumnClass.elements();
-        while (defaultRenderers.hasMoreElements()) {
-            SwingUtilities.updateRendererOrEditorUI(defaultRenderers.nextElement());
-        }
-
-        // Update the UIs of all the default editors.
-        Enumeration<?> defaultEditors = defaultEditorsByColumnClass.elements();
-        while (defaultEditors.hasMoreElements()) {
-            SwingUtilities.updateRendererOrEditorUI(defaultEditors.nextElement());
-        }
-
-        // Update the UI of the table header
-        if (tableHeader != null && tableHeader.getParent() == null) {
-            tableHeader.updateUI();
-        }
-
-        // Update UI applied to parent ScrollPane
-        configureEnclosingScrollPaneUI();
-
-        setUI((TableUI)UIManager.getUI(this));
+        if (updateInProgress) {
+            return;
+        }
+
+        updateInProgress = true;
+
+        try {
+            // Update the UIs of the cell renderers, cell editors and header renderers.
+            TableColumnModel cm = getColumnModel();
+            for(int column = 0; column < cm.getColumnCount(); column++) {
+                TableColumn aColumn = cm.getColumn(column);
+                SwingUtilities.updateRendererOrEditorUI(aColumn.getCellRenderer());
+                SwingUtilities.updateRendererOrEditorUI(aColumn.getCellEditor());
+                SwingUtilities.updateRendererOrEditorUI(aColumn.getHeaderRenderer());
+            }
+
+            // Update the UIs of all the default renderers.
+            Enumeration<?> defaultRenderers = defaultRenderersByColumnClass.elements();
+            while (defaultRenderers.hasMoreElements()) {
+                SwingUtilities.updateRendererOrEditorUI(defaultRenderers.nextElement());
+            }
+
+            // Update the UIs of all the default editors.
+            Enumeration<?> defaultEditors = defaultEditorsByColumnClass.elements();
+            while (defaultEditors.hasMoreElements()) {
+                SwingUtilities.updateRendererOrEditorUI(defaultEditors.nextElement());
+            }
+
+            // Update the UI of the table header
+            if (tableHeader != null && tableHeader.getParent() == null) {
+                tableHeader.updateUI();
+            }
+
+            // Update UI applied to parent ScrollPane
+            configureEnclosingScrollPaneUI();
+
+            setUI((TableUI)UIManager.getUI(this));
+        } finally {
+            updateInProgress = false;
+        }
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTree.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTree.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -321,6 +321,11 @@
     private transient DropLocation dropLocation;
 
     /**
+     * Flag to indicate UI update is in progress
+     */
+    private transient boolean updateInProgress;
+
+    /**
      * A subclass of <code>TransferHandler.DropLocation</code> representing
      * a drop location for a <code>JTree</code>.
      *
@@ -713,10 +718,19 @@
      * @see JComponent#updateUI
      */
     public void updateUI() {
-        setUI((TreeUI)UIManager.getUI(this));
-
-        SwingUtilities.updateRendererOrEditorUI(getCellRenderer());
-        SwingUtilities.updateRendererOrEditorUI(getCellEditor());
+        if (!updateInProgress) {
+
+            updateInProgress = true;
+
+            try {
+                setUI((TreeUI)UIManager.getUI(this));
+
+                SwingUtilities.updateRendererOrEditorUI(getCellRenderer());
+                SwingUtilities.updateRendererOrEditorUI(getCellEditor());
+            } finally {
+                updateInProgress = false;
+            }
+        }
     }
 
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/table/JTableHeader.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/table/JTableHeader.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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,11 @@
       */
     private TableCellRenderer defaultRenderer;
 
+    /**
+     * Flag to indicate UI update is in progress
+     */
+    private transient boolean updateInProgress;
+
 //
 // Constructors
 //
@@ -475,11 +480,18 @@
      * @see JComponent#updateUI
      */
     public void updateUI(){
-        setUI((TableHeaderUI)UIManager.getUI(this));
+        if (!updateInProgress) {
+            updateInProgress = true;
+            try {
+                setUI((TableHeaderUI)UIManager.getUI(this));
 
-        TableCellRenderer renderer = getDefaultRenderer();
-        if (renderer instanceof Component) {
-            SwingUtilities.updateComponentTreeUI((Component)renderer);
+                TableCellRenderer renderer = getDefaultRenderer();
+                if (renderer instanceof Component) {
+                    SwingUtilities.updateComponentTreeUI((Component)renderer);
+                }
+            } finally {
+                updateInProgress = false;
+            }
         }
     }
 
--- a/jdk/src/java.desktop/share/classes/module-info.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/module-info.java	Tue Jul 26 14:45:11 2016 -0700
@@ -23,6 +23,10 @@
  * questions.
  */
 
+/**
+  * java.desktop defines and exports the user interface, graphics
+  * and imaging APIs of the Java SE platform.
+  */
 module java.desktop {
     requires public java.datatransfer;
     requires public java.xml;
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/OffScreenImageSource.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/OffScreenImageSource.java	Tue Jul 26 14:45:11 2016 -0700
@@ -187,17 +187,19 @@
             sendPixels();
             theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
 
-            try {
-                theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE);
-            } catch (RuntimeException e) {
-                // We did not previously call this method here and
-                // some image consumer filters were not prepared for it to be
-                // called at this time. We allow them to have runtime issues
-                // for this one call only without triggering the IMAGEERROR
-                // condition below.
-                e.printStackTrace();
+            // If 'theconsumer' has not unregistered itself after previous call
+            if (theConsumer != null) {
+                try {
+                    theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE);
+                } catch (RuntimeException e) {
+                    // We did not previously call this method here and
+                    // some image consumer filters were not prepared for it to be
+                    // called at this time. We allow them to have runtime issues
+                    // for this one call only without triggering the IMAGEERROR
+                    // condition below.
+                    e.printStackTrace();
+                }
             }
-
         } catch (NullPointerException e) {
             e.printStackTrace();
 
--- a/jdk/src/java.desktop/share/classes/sun/font/GlyphList.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/font/GlyphList.java	Tue Jul 26 14:45:11 2016 -0700
@@ -28,6 +28,7 @@
 import java.awt.Font;
 import java.awt.font.GlyphVector;
 import java.awt.font.FontRenderContext;
+import java.util.concurrent.atomic.AtomicBoolean;
 import sun.java2d.loops.FontInfo;
 
 /*
@@ -151,8 +152,8 @@
      * occur and if it did, it would just lead to some extra garbage being
      * created.
      */
-    private static GlyphList reusableGL = new GlyphList();
-    private static boolean inUse;
+    private static final GlyphList reusableGL = new GlyphList();
+    private static final AtomicBoolean inUse = new AtomicBoolean();
 
 
     void ensureCapacity(int len) {
@@ -184,24 +185,10 @@
 //     }
 
     public static GlyphList getInstance() {
-        /* The following heuristic is that if the reusable instance is
-         * in use, it probably still will be in a micro-second, so avoid
-         * synchronising on the class and just allocate a new instance.
-         * The cost is one extra boolean test for the normal case, and some
-         * small number of cases where we allocate an extra object when
-         * in fact the reusable one would be freed very soon.
-         */
-        if (inUse) {
+        if (inUse.compareAndSet(false, true)) {
+            return reusableGL;
+        } else {
             return new GlyphList();
-        } else {
-            synchronized(GlyphList.class) {
-                if (inUse) {
-                    return new GlyphList();
-                } else {
-                    inUse = true;
-                    return reusableGL;
-                }
-            }
         }
     }
 
@@ -212,17 +199,10 @@
      * will be discarded so the re-allocation overhead is high.
      */
 //     public static GlyphList getInstance(int sz) {
-//      if (inUse) {
-//          return new GlyphList(sz);
+//      if (inUse.compareAndSet(false, true) {
+//          return reusableGL;
 //      } else {
-//          synchronized(GlyphList.class) {
-//              if (inUse) {
-//                  return new GlyphList();
-//              } else {
-//                  inUse = true;
-//                  return reusableGL;
-//              }
-//          }
+//          return new GlyphList(sz);
 //      }
 //     }
 
@@ -423,7 +403,7 @@
             }
             usePositions = false;
             strikelist = null; // remove reference to the strike list
-            inUse = false;
+            inUse.set(false);
         }
     }
 
--- a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java	Tue Jul 26 14:45:11 2016 -0700
@@ -74,7 +74,7 @@
 import java.awt.event.KeyEvent;
 import java.net.URISyntaxException;
 import java.lang.reflect.Field;
-
+import java.net.MalformedURLException;
 
 /**
  * A class which implements a cross-platform print dialog.
@@ -932,12 +932,18 @@
                 allowedToPrintToFile() : false;
 
             // setup Destination (print-to-file) widgets
-            if (psCurrent.isAttributeCategorySupported(dstCategory)) {
-                dstSupported = true;
-            }
             Destination dst = (Destination)asCurrent.get(dstCategory);
             if (dst != null) {
-                dstSelected = true;
+                try {
+                     dst.getURI().toURL();
+                     if (psCurrent.isAttributeValueSupported(dst, docFlavor,
+                                                             asCurrent)) {
+                         dstSupported = true;
+                         dstSelected = true;
+                     }
+                 } catch (MalformedURLException ex) {
+                     dstSupported = true;
+                 }
             }
             cbPrintToFile.setEnabled(dstSupported && dstAllowed);
             cbPrintToFile.setSelected(dstSelected && dstAllowed
@@ -1294,8 +1300,16 @@
                 if (sc == null) {
                     sc = SheetCollate.UNCOLLATED;
                 }
+                if (sc != null &&
+                    !psCurrent.isAttributeValueSupported(sc, docFlavor, asCurrent)) {
+                    scSupported = false;
+                }
+            } else {
+                if (!psCurrent.isAttributeValueSupported(sc, docFlavor, asCurrent)) {
+                    scSupported = false;
+                }
             }
-            cbCollate.setSelected(sc == SheetCollate.COLLATED);
+            cbCollate.setSelected(sc == SheetCollate.COLLATED && scSupported);
             updateCollateCB();
         }
     }
--- a/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java	Tue Jul 26 14:45:11 2016 -0700
@@ -25,6 +25,7 @@
 package sun.swing;
 
 import java.awt.*;
+import java.awt.geom.AffineTransform;
 import java.awt.image.*;
 import java.util.*;
 
@@ -99,9 +100,7 @@
         }
     }
 
-    private void paint0(Component c, Graphics g, int x,
-                         int y, int w, int h, Object... args) {
-        Object key = getClass();
+    private Image getImage(Object key, Component c, int w, int h, Object... args) {
         GraphicsConfiguration config = getGraphicsConfiguration(c);
         ImageCache cache = getCache(key);
         Image image = cache.getImage(key, config, w, h, args);
@@ -133,14 +132,40 @@
                 g2.dispose();
             }
 
-            // Render to the passed in Graphics
-            paintImage(c, g, x, y, w, h, image, args);
-
             // If we did this 3 times and the contents are still lost
             // assume we're painting to a VolatileImage that is bogus and
             // give up.  Presumably we'll be called again to paint.
         } while ((image instanceof VolatileImage) &&
                  ((VolatileImage)image).contentsLost() && ++attempts < 3);
+
+        return image;
+    }
+
+    private void paint0(Component c, Graphics g, int x,
+                        int y, int w, int h, Object... args) {
+        Object key = getClass();
+        GraphicsConfiguration config = getGraphicsConfiguration(c);
+        ImageCache cache = getCache(key);
+        Image image = cache.getImage(key, config, w, h, args);
+
+        if (image == null) {
+            double sx = 1;
+            double sy = 1;
+            if (g instanceof Graphics2D) {
+                AffineTransform tx = ((Graphics2D) g).getTransform();
+                sx = tx.getScaleX();
+                sy = tx.getScaleY();
+            }
+            image = new PainterMultiResolutionCachedImage(sx, sy, w, h);
+            cache.setImage(key, config, w, h, args, image);
+        }
+
+        if (image instanceof PainterMultiResolutionCachedImage) {
+            ((PainterMultiResolutionCachedImage) image).setParams(c, args);
+        }
+
+        // Render to the passed in Graphics
+        paintImage(c, g, x, y, w, h, image, args);
     }
 
     /**
@@ -210,4 +235,62 @@
         }
         return c.getGraphicsConfiguration();
     }
-}
+
+    class PainterMultiResolutionCachedImage extends AbstractMultiResolutionImage {
+
+        private final double scaleX;
+        private final double scaleY;
+        private final int baseWidth;
+        private final int baseHeight;
+        private Component c;
+        private Object[] args;
+
+        public PainterMultiResolutionCachedImage(double scaleX, double scaleY,
+                                                 int baseWidth, int baseHeight) {
+            this.scaleX = scaleX;
+            this.scaleY = scaleY;
+            this.baseWidth = baseWidth;
+            this.baseHeight = baseHeight;
+        }
+
+        public void setParams(Component c, Object[] args) {
+            this.c = c;
+            this.args = args;
+        }
+
+        @Override
+        public int getWidth(ImageObserver observer) {
+            return baseWidth;
+        }
+
+        @Override
+        public int getHeight(ImageObserver observer) {
+            return baseHeight;
+        }
+
+        @Override
+        public Image getResolutionVariant(double destWidth, double destHeight) {
+            int w = (int) Math.ceil(destWidth);
+            int h = (int) Math.ceil(destHeight);
+            return getImage(this, c, w, h, args);
+        }
+
+        @Override
+        protected Image getBaseImage() {
+            return getResolutionVariant(baseWidth, baseHeight);
+        }
+
+        @Override
+        public java.util.List<Image> getResolutionVariants() {
+
+            if (scaleX == 1 && scaleY == 1) {
+                return Arrays.asList(getResolutionVariant(baseWidth, baseHeight));
+            }
+
+            return Arrays.asList(
+                    getResolutionVariant(baseWidth, baseHeight),
+                    getResolutionVariant(scaleX * baseWidth, scaleY * baseHeight)
+            );
+        }
+    }
+}
\ No newline at end of file
--- a/jdk/src/java.desktop/share/classes/sun/swing/FilePane.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/swing/FilePane.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1748,8 +1748,8 @@
         if (listSelectionModel != null) {
             listSelectionModel.clearSelection();
             if (listSelectionModel instanceof DefaultListSelectionModel) {
-                ((DefaultListSelectionModel)listSelectionModel).moveLeadSelectionIndex(0);
-                listSelectionModel.setAnchorSelectionIndex(0);
+                ((DefaultListSelectionModel)listSelectionModel).moveLeadSelectionIndex(-1);
+                listSelectionModel.setAnchorSelectionIndex(-1);
             }
         }
     }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, 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
@@ -29,6 +29,9 @@
 import java.awt.event.ComponentEvent;
 import java.awt.event.InvocationEvent;
 import java.awt.event.WindowEvent;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 import sun.awt.IconInfo;
 import sun.util.logging.PlatformLogger;
@@ -52,6 +55,8 @@
     XContentWindow content;
     Insets currentInsets;
     XFocusProxyWindow focusProxy;
+    static final Map<Class<?>,Insets> lastKnownInsets =
+                                   Collections.synchronizedMap(new HashMap<>());
 
     XDecoratedPeer(Window target) {
         super(target);
@@ -74,6 +79,9 @@
         winAttr.initialFocus = true;
 
         currentInsets = new Insets(0,0,0,0);
+        if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
+            currentInsets = lastKnownInsets.get(getClass());
+        }
         applyGuessedInsets();
 
         Rectangle bounds = (Rectangle)params.get(BOUNDS);
@@ -297,7 +305,25 @@
         if (ev.get_atom() == XWM.XA_KDE_NET_WM_FRAME_STRUT.getAtom()
             || ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom())
         {
-            getWMSetInsets(XAtom.get(ev.get_atom()));
+            if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
+                getWMSetInsets(XAtom.get(ev.get_atom()));
+            } else {
+                if(!isReparented()) {
+                    return;
+                }
+                wm_set_insets = null;
+                Insets in = getWMSetInsets(XAtom.get(ev.get_atom()));
+                if (isNull(in)) {
+                    return;
+                }
+                if (!isEmbedded() && !isTargetUndecorated()) {
+                    lastKnownInsets.put(getClass(), in);
+                }
+                if (!in.equals(dimensions.getInsets())) {
+                    handleCorrectInsets(in);
+                }
+                insets_corrected = true;
+            }
         }
     }
 
@@ -370,7 +396,7 @@
                     }
                 }
 
-                if (correctWM != null) {
+                if (correctWM != null && XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
                     handleCorrectInsets(correctWM);
                 }
             }
@@ -664,6 +690,9 @@
 
     boolean no_reparent_artifacts = false;
     public void handleConfigureNotifyEvent(XEvent xev) {
+        if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM && !insets_corrected) {
+            return;
+        }
         assert (SunToolkit.isAWTLockHeldByCurrentThread());
         XConfigureEvent xe = xev.get_xconfigure();
         if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
@@ -1010,7 +1039,22 @@
         if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
             focusLog.fine("WM_TAKE_FOCUS on {0}", this);
         }
-        requestWindowFocus(cl.get_data(1), true);
+
+        if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
+            // JDK-8159460
+            Window focusedWindow = XKeyboardFocusManagerPeer.getInstance()
+                    .getCurrentFocusedWindow();
+            Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
+            if (activeWindow != target) {
+                requestWindowFocus(cl.get_data(1), true);
+            } else {
+                WindowEvent we = new WindowEvent(focusedWindow,
+                        WindowEvent.WINDOW_GAINED_FOCUS);
+                sendEvent(we);
+            }
+        } else {
+            requestWindowFocus(cl.get_data(1), true);
+        }
     }
 
     /**
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java	Tue Jul 26 14:45:11 2016 -0700
@@ -35,8 +35,16 @@
 
 class XRobotPeer implements RobotPeer {
 
-    private static volatile boolean isGtkSupported;
+    static final boolean tryGtk;
+    static {
+        loadNativeLibraries();
+        tryGtk = Boolean.getBoolean("awt.robot.gtk");
+    }
+
+    private static boolean isGtkSupported =  false;
+    private static volatile boolean useGtk;
     private X11GraphicsConfig   xgc = null;
+
     /*
      * native implementation uses some static shared data (pipes, processes)
      * so use a class lock to synchronize native method calls
@@ -49,13 +57,14 @@
         setup(tk.getNumberOfButtons(),
                 AWTAccessor.getInputEventAccessor().getButtonDownMasks());
 
-        Toolkit toolkit = Toolkit.getDefaultToolkit();
-        if (!isGtkSupported) {
-            if (toolkit instanceof UNIXToolkit
-                    && ((UNIXToolkit) toolkit).loadGTK()) {
+        boolean isGtkSupported = false;
+        if (tryGtk) {
+            if (tk instanceof UNIXToolkit && ((UNIXToolkit) tk).loadGTK()) {
                 isGtkSupported = true;
             }
         }
+
+        useGtk = (tryGtk && isGtkSupported);
     }
 
     @Override
@@ -104,7 +113,7 @@
     public int getRGBPixel(int x, int y) {
         int pixelArray[] = new int[1];
         getRGBPixelsImpl(xgc, x, y, 1, 1, xgc.getScale(), pixelArray,
-                         isGtkSupported);
+                         useGtk);
         return pixelArray[0];
     }
 
@@ -112,11 +121,12 @@
     public int [] getRGBPixels(Rectangle bounds) {
         int pixelArray[] = new int[bounds.width*bounds.height];
         getRGBPixelsImpl(xgc, bounds.x, bounds.y, bounds.width, bounds.height,
-                         xgc.getScale(), pixelArray, isGtkSupported);
+                         xgc.getScale(), pixelArray, useGtk);
         return pixelArray;
     }
 
     private static synchronized native void setup(int numberOfButtons, int[] buttonDownMasks);
+    private static native void loadNativeLibraries();
 
     private static synchronized native void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
     private static synchronized native void mousePressImpl(int buttons);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java	Tue Jul 26 14:45:11 2016 -0700
@@ -32,6 +32,7 @@
 
 import sun.awt.UNIXToolkit;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import sun.security.action.GetPropertyAction;
 
 final class XTaskbarPeer implements TaskbarPeer {
@@ -40,6 +41,14 @@
     private static boolean initExecuted = false;
 
     private PopupMenu menu = null;
+    private static boolean isUnity;
+
+    static {
+        String de = AccessController.doPrivileged(
+                        (PrivilegedAction<String>) ()
+                                -> System.getenv("XDG_CURRENT_DESKTOP"));
+        isUnity = de != null && de.equals("Unity");
+    }
 
     private static void initWithLock() {
         XToolkit.awtLock();
@@ -68,6 +77,9 @@
     }
 
     static boolean isTaskbarSupported() {
+        if (!isUnity) {
+            return false;
+        }
         initWithLock();
         return nativeLibraryLoaded;
     }
@@ -107,6 +119,8 @@
                 val = Long.parseLong(badge);
                 visible = true;
             } catch (NumberFormatException e) {
+                throw new UnsupportedOperationException("The " + Feature.ICON_BADGE_TEXT
+                    + " feature is not supported on the current platform!");
             }
         }
         setBadge(val, visible);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -104,7 +104,8 @@
         COMPIZ_WM = 12,
         LG3D_WM = 13,
         CWM_WM = 14,
-        MUTTER_WM = 15;
+        MUTTER_WM = 15,
+        UNITY_COMPIZ_WM = 16;
     public String toString() {
         switch  (WMID) {
           case NO_WM:
@@ -129,6 +130,8 @@
               return "Metacity";
           case COMPIZ_WM:
               return "Compiz";
+            case UNITY_COMPIZ_WM:
+              return "Unity Compiz";
           case LG3D_WM:
               return "LookingGlass";
           case CWM_WM:
@@ -572,6 +575,10 @@
         return isNetWMName("compiz");
     }
 
+    static boolean isUnityCompiz() {
+        return isNetWMName("Compiz");
+    }
+
     static boolean isLookingGlass() {
         return isNetWMName("LG3D");
     }
@@ -790,6 +797,8 @@
                 awt_wmgr = CWM_WM;
             } else if (doIsIceWM && isIceWM()) {
                 awt_wmgr = XWM.ICE_WM;
+            } else if (isUnityCompiz()) {
+                awt_wmgr = XWM.UNITY_COMPIZ_WM;
             }
             /*
              * We don't check for legacy WM when we already know that WM
@@ -1351,6 +1360,9 @@
               case LG3D_WM:
                   res = zeroInsets;
                   break;
+              case UNITY_COMPIZ_WM:
+                  res = new Insets(28, 1, 1, 1);
+                  break;
               case MOTIF_WM:
               case OPENLOOK_WM:
               default:
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java	Tue Jul 26 14:45:11 2016 -0700
@@ -777,6 +777,7 @@
                 case XWM.METACITY_WM:
                 case XWM.MUTTER_WM:
                 case XWM.SAWFISH_WM:
+                case XWM.UNITY_COMPIZ_WM:
                 {
                     Point xlocation = queryXLocation();
                     if (log.isLoggable(PlatformLogger.Level.FINE)) {
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -281,7 +281,7 @@
                                                  int width, int height,
                                                  int displayMode);
     private static native void resetNativeData(int screen);
-    private static native int getNativeScaleFactor(int screen);
+    private static native double getNativeScaleFactor(int screen);
 
     /**
      * Returns true only if:
@@ -516,6 +516,11 @@
         return scale;
     }
 
+    public int getNativeScale() {
+        isXrandrExtensionSupported();
+        return (int)Math.round(getNativeScaleFactor(screen));
+    }
+
     private int initScaleFactor() {
 
         if (SunGraphicsEnvironment.isUIScaleEnabled()) {
@@ -525,8 +530,7 @@
             if (debugScale >= 1) {
                 return (int) debugScale;
             }
-
-            int nativeScale = getNativeScaleFactor(screen);
+            int nativeScale = getNativeScale();
             return nativeScale >= 1 ? nativeScale : 1;
         }
 
--- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c	Tue Jul 26 14:45:11 2016 -0700
@@ -22,23 +22,171 @@
 */
 
 #include "systemScale.h"
+#include "jni.h"
+#include "jni_util.h"
+#include "jvm_md.h"
+#include <dlfcn.h>
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
-int getNativeScaleFactor() {
+typedef void* g_settings_schema_source_get_default();
+typedef void* g_settings_schema_source_ref(void *);
+typedef void g_settings_schema_source_unref(void *);
+typedef void* g_settings_schema_source_lookup(void *, char *, int);
+typedef int g_settings_schema_has_key(void *, char *);
+typedef void* g_settings_new_full(void *, void *, char *);
+typedef void* g_settings_get_value(void *, char *);
+typedef int g_variant_is_of_type(void *, char *);
+typedef unsigned long g_variant_n_children(void *);
+typedef void* g_variant_get_child_value(void *, unsigned long);
+typedef void  g_variant_unref(void *);
+typedef char*  g_variant_get_string(void *, unsigned long *);
+typedef int  g_variant_get_int32(void *);
+typedef double  g_variant_get_double(void *);
+
+static g_settings_schema_has_key* fp_g_settings_schema_has_key;
+static g_settings_new_full* fp_g_settings_new_full;
+static g_settings_get_value* fp_g_settings_get_value;
+static g_variant_is_of_type* fp_g_variant_is_of_type;
+static g_variant_n_children* fp_g_variant_n_children;
+static g_variant_get_child_value* fp_g_variant_get_child_value;
+static g_variant_get_string* fp_g_variant_get_string;
+static g_variant_get_int32* fp_g_variant_get_int32;
+static g_variant_get_double* fp_g_variant_get_double;
+static g_variant_unref* fp_g_variant_unref;
 
-    static int scale = -2.0;
+static void* get_schema_value(char *name, char *key) {
+    static void *lib_handle;
+    static int initialized = 0;
+    static void * default_schema;
+    static g_settings_schema_source_lookup* schema_lookup;
+    void *schema = NULL, *fp = NULL;
+    if (!initialized) {
+        initialized = 1;
+        lib_handle = dlopen(JNI_LIB_NAME("gio-2.0"), RTLD_GLOBAL | RTLD_LAZY);
+        if (!lib_handle) {
+            CHECK_NULL_RETURN(lib_handle =
+                          dlopen(VERSIONED_JNI_LIB_NAME("gio-2.0", "0"),
+                                                RTLD_GLOBAL | RTLD_LAZY), NULL);
+        }
+        CHECK_NULL_RETURN(fp_g_settings_schema_has_key =
+                          (g_settings_schema_has_key*)
+                          dlsym(lib_handle, "g_settings_schema_has_key"), NULL);
+        CHECK_NULL_RETURN(fp_g_settings_new_full =
+                          (g_settings_new_full*)
+                          dlsym(lib_handle, "g_settings_new_full"), NULL);
+        CHECK_NULL_RETURN(fp_g_settings_get_value =
+                          (g_settings_get_value*)
+                          dlsym(lib_handle, "g_settings_get_value"), NULL);
+        CHECK_NULL_RETURN(fp_g_variant_is_of_type =
+                          (g_variant_is_of_type*)
+                          dlsym(lib_handle, "g_variant_is_of_type"), NULL);
+        CHECK_NULL_RETURN(fp_g_variant_n_children =
+                          (g_variant_n_children*)
+                          dlsym(lib_handle, "g_variant_n_children"), NULL);
+        CHECK_NULL_RETURN(fp_g_variant_get_child_value =
+                          (g_variant_get_child_value*)
+                          dlsym(lib_handle, "g_variant_get_child_value"), NULL);
+        CHECK_NULL_RETURN(fp_g_variant_get_string =
+                          (g_variant_get_string*)
+                          dlsym(lib_handle, "g_variant_get_string"), NULL);
+        CHECK_NULL_RETURN(fp_g_variant_get_int32 =
+                          (g_variant_get_int32*)
+                          dlsym(lib_handle, "g_variant_get_int32"), NULL);
+        CHECK_NULL_RETURN(fp_g_variant_get_double =
+                          (g_variant_get_double*)
+                          dlsym(lib_handle, "g_variant_get_double"), NULL);
+        CHECK_NULL_RETURN(fp_g_variant_unref =
+                          (g_variant_unref*)
+                          dlsym(lib_handle, "g_variant_unref"), NULL);
 
-    if (scale == -2) {
-        scale = getScale("J2D_UISCALE");
+        fp = dlsym(lib_handle, "g_settings_schema_source_get_default");
+        if (fp) {
+            default_schema = ((g_settings_schema_source_get_default*)fp)();
+        }
+        if (default_schema) {
+            fp = dlsym(lib_handle, "g_settings_schema_source_ref");
+            if (fp) {
+                ((g_settings_schema_source_ref*)fp)(default_schema);
+            }
+        }
+        schema_lookup = (g_settings_schema_source_lookup*)
+                           dlsym(lib_handle, "g_settings_schema_source_lookup");
     }
 
-    if (scale >= 1) {
-        return (int) scale;
+    if (!default_schema || !schema_lookup) {
+        return NULL;
     }
-    return getScale("GDK_SCALE");
+
+    schema = schema_lookup(default_schema, name, 1);
+    if (schema) {
+        if (fp_g_settings_schema_has_key(schema, key)) {
+            void *settings = fp_g_settings_new_full(schema, NULL, NULL);
+            if (settings) {
+                return fp_g_settings_get_value(settings, key);
+            }
+        }
+    }
+    return NULL;
 }
 
-int getScale(const char *name) {
+
+static double getDesktopScale(char *output_name) {
+    double result = -1;
+    if(output_name) {
+        void *value = get_schema_value("com.ubuntu.user-interface",
+                                                                "scale-factor");
+        if (value) {
+            if(fp_g_variant_is_of_type(value, "a{si}")) {
+                int num = fp_g_variant_n_children(value);
+                int i = 0;
+                while (i < num) {
+                    void *entry = fp_g_variant_get_child_value(value, i++);
+                    if (entry) {
+                        void *screen = fp_g_variant_get_child_value(entry, 0);
+                        void *scale = fp_g_variant_get_child_value(entry, 1);
+                        if (screen && scale) {
+                            char *name = fp_g_variant_get_string(screen, NULL);
+                            if (name && strcmp(name, output_name)) {
+                                result = fp_g_variant_get_int32(scale) / 8.;
+                            }
+                            fp_g_variant_unref(screen);
+                            fp_g_variant_unref(scale);
+                        }
+                        fp_g_variant_unref(entry);
+                    }
+                    if (result > 0) {
+                        break;
+                    }
+                }
+            }
+            fp_g_variant_unref(value);
+        }
+        if (result > 0) {
+            value = get_schema_value("com.canonical.Unity.Interface",
+                                                           "text-scale-factor");
+            if (value && fp_g_variant_is_of_type(value, "d")) {
+                result *= fp_g_variant_get_double(value);
+                fp_g_variant_unref(value);
+            }
+        }
+    }
+
+    if (result <= 0) {
+        void *value = get_schema_value("org.gnome.desktop.interface",
+                                                         "text-scaling-factor");
+        if (value && fp_g_variant_is_of_type(value, "d")) {
+            result = fp_g_variant_get_double(value);
+            fp_g_variant_unref(value);
+        }
+    }
+
+    return result;
+
+}
+
+static int getScale(const char *name) {
     char *uiScale = getenv(name);
     if (uiScale != NULL) {
         double scale = strtod(uiScale, NULL);
@@ -50,3 +198,26 @@
     return -1;
 }
 
+double getNativeScaleFactor(char *output_name) {
+    static int scale = -2.0;
+    double native_scale = 0;
+    int gdk_scale = 0;
+
+    if (scale == -2) {
+        scale = getScale("J2D_UISCALE");
+    }
+
+    if (scale > 0) {
+        return scale;
+    }
+
+    native_scale = getDesktopScale(output_name);
+
+    if (native_scale <= 0) {
+        native_scale = 1;
+    }
+
+    gdk_scale = getScale("GDK_SCALE");
+
+    return gdk_scale > 0 ? native_scale * gdk_scale : native_scale;
+}
--- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h	Tue Jul 26 14:45:11 2016 -0700
@@ -26,8 +26,7 @@
 #include <signal.h>
 #include <stdlib.h>
 
-int getNativeScaleFactor();
-int getScale(const char *uiScale);
+double getNativeScaleFactor();
 
 #endif
 
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c	Tue Jul 26 14:45:11 2016 -0700
@@ -2141,15 +2141,50 @@
  * End DisplayMode/FullScreen support
  */
 
+static char *get_output_screen_name(JNIEnv *env, int screen) {
+    if (!awt_XRRGetScreenResources || !awt_XRRGetOutputInfo) {
+        return NULL;
+    }
+    char *name = NULL;
+    AWT_LOCK();
+    int scr = 0, out = 0;
+    if (usingXinerama && XScreenCount(awt_display) > 0) {
+        out = screen;
+    } else {
+        scr = screen;
+    }
+
+    XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
+                                                  RootWindow(awt_display, scr));
+    if (res) {
+       if (res->noutput > out) {
+            XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
+                                                        res, res->outputs[out]);
+            if (output_info) {
+                if (output_info->name) {
+                    name = strdup(output_info->name);
+                }
+                awt_XRRFreeOutputInfo(output_info);
+            }
+        }
+        awt_XRRFreeScreenResources(res);
+    }
+    AWT_UNLOCK();
+    return name;
+}
 
 /*
  * Class:     sun_awt_X11GraphicsDevice
  * Method:    getNativeScaleFactor
- * Signature: (I)I
+ * Signature: (I)D
  */
-JNIEXPORT jint JNICALL
+JNIEXPORT jdouble JNICALL
 Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor
     (JNIEnv *env, jobject this, jint screen) {
-
-    return getNativeScaleFactor();
+    char *name = get_output_screen_name(env, screen);
+    double scale = getNativeScaleFactor(name);
+    if (name) {
+        free(name);
+    }
+    return scale;
 }
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c	Tue Jul 26 14:45:11 2016 -0700
@@ -27,6 +27,9 @@
     #error This file should not be included in headless library
 #endif
 
+#include "jvm_md.h"
+#include <dlfcn.h>
+
 #include "awt_p.h"
 #include "awt_GraphicsEnv.h"
 #define XK_MISCELLANY
@@ -50,11 +53,46 @@
 #include <sys/socket.h>
 #endif
 
+static Bool   (*compositeQueryExtension)   (Display*, int*, int*);
+static Status (*compositeQueryVersion)     (Display*, int*, int*);
+static Window (*compositeGetOverlayWindow) (Display *, Window);
+
 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
 
 static jint * masks;
 static jint num_buttons;
 
+static void *xCompositeHandle;
+
+static const char* XCOMPOSITE = JNI_LIB_NAME("Xcomposite");
+static const char* XCOMPOSITE_VERSIONED = VERSIONED_JNI_LIB_NAME("Xcomposite", "1");
+
+static Bool checkXCompositeFunctions(void) {
+    return (compositeQueryExtension   != NULL   &&
+            compositeQueryVersion     != NULL   &&
+            compositeGetOverlayWindow != NULL);
+}
+
+static void initXCompositeFunctions(void) {
+
+    if (xCompositeHandle == NULL) {
+        xCompositeHandle = dlopen(XCOMPOSITE, RTLD_LAZY | RTLD_GLOBAL);
+        if (xCompositeHandle == NULL) {
+            xCompositeHandle = dlopen(XCOMPOSITE_VERSIONED, RTLD_LAZY | RTLD_GLOBAL);
+        }
+    }
+    //*(void **)(&asyncGetCallTraceFunction)
+    if (xCompositeHandle != NULL) {
+        *(void **)(&compositeQueryExtension) = dlsym(xCompositeHandle, "XCompositeQueryExtension");
+        *(void **)(&compositeQueryVersion) = dlsym(xCompositeHandle, "XCompositeQueryVersion");
+        *(void **)(&compositeGetOverlayWindow) = dlsym(xCompositeHandle, "XCompositeGetOverlayWindow");
+    }
+
+    if (xCompositeHandle && !checkXCompositeFunctions()) {
+        dlclose(xCompositeHandle);
+    }
+}
+
 static int32_t isXTestAvailable() {
     int32_t major_opcode, first_event, first_error;
     int32_t  event_basep, error_basep, majorp, minorp;
@@ -89,6 +127,35 @@
     return isXTestAvailable;
 }
 
+static Bool hasXCompositeOverlayExtension(Display *display) {
+
+    int xoverlay = False;
+    int eventBase, errorBase;
+    if (checkXCompositeFunctions() &&
+        compositeQueryExtension(display, &eventBase, &errorBase))
+    {
+        int major = 0;
+        int minor = 0;
+
+        compositeQueryVersion(display, &major, &minor);
+        if (major > 0 || minor >= 3) {
+            xoverlay = True;
+        }
+    }
+
+    return xoverlay;
+}
+
+static jboolean isXCompositeDisplay(Display *display, int screenNumber) {
+
+    char NET_WM_CM_Sn[25];
+    snprintf(NET_WM_CM_Sn, sizeof(NET_WM_CM_Sn), "_NET_WM_CM_S%d\0", screenNumber);
+
+    Atom managerSelection = XInternAtom(display, NET_WM_CM_Sn, 0);
+    Window owner = XGetSelectionOwner(display, managerSelection);
+
+    return owner != 0;
+}
 
 static XImage *getWindowImage(Display * display, Window window,
                               int32_t x, int32_t y,
@@ -211,7 +278,7 @@
                              jint jheight,
                              jint scale,
                              jintArray pixelArray,
-                             jboolean isGtkSupported) {
+                             jboolean useGtk) {
     XImage *image;
     jint *ary;               /* Array of jints for sending pixel values back
                               * to parent process.
@@ -238,6 +305,14 @@
 
     rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen);
 
+    if (!useGtk) {
+        if (hasXCompositeOverlayExtension(awt_display) &&
+            isXCompositeDisplay(awt_display, adata->awt_visInfo.screen))
+        {
+            rootWindow = compositeGetOverlayWindow(awt_display, rootWindow);
+        }
+    }
+
     if (!XGetWindowAttributes(awt_display, rootWindow, &attr)
             || sx + swidth <= attr.x
             || attr.x + attr.width <= sx
@@ -262,7 +337,7 @@
 
     int index;
 
-    if (isGtkSupported) {
+    if (useGtk) {
         gtk->gdk_threads_enter();
         gtk_failed = gtk->get_drawable_data(env, pixelArray, x, y, width,
                                             height, jwidth, dx, dy, scale);
@@ -454,3 +529,8 @@
 
     AWT_UNLOCK();
 }
+
+JNIEXPORT void JNICALL
+Java_sun_awt_X11_XRobotPeer_loadNativeLibraries (JNIEnv *env, jclass cls) {
+    initXCompositeFunctions();
+}
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c	Tue Jul 26 14:45:11 2016 -0700
@@ -1586,13 +1586,17 @@
     fp_gtk_style_context_save (context);
 
     GtkStateFlags flags = get_gtk_flags(state_type);
+    if (expander_style == GTK_EXPANDER_EXPANDED) {
+        flags |= GTK_STATE_FLAG_ACTIVE;
+    }
+
     fp_gtk_style_context_set_state(context, flags);
 
     if (detail != 0) {
         transform_detail_string(detail, context);
     }
 
-    fp_gtk_render_expander (context, cr, x, y, width, height);
+    fp_gtk_render_expander (context, cr, x + 2, y + 2, width - 4, height - 4);
 
     fp_gtk_style_context_restore (context);
 }
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h	Tue Jul 26 14:45:11 2016 -0700
@@ -11,7 +11,7 @@
  * 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 thats
+ * 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
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java	Tue Jul 26 14:45:11 2016 -0700
@@ -55,6 +55,7 @@
 
 import java.awt.dnd.DropTarget;
 import java.awt.dnd.peer.DropTargetPeer;
+import java.awt.geom.AffineTransform;
 import sun.awt.AWTAccessor;
 
 import sun.util.logging.PlatformLogger;
@@ -1128,6 +1129,12 @@
         }
 
         if (shape != null) {
+            AffineTransform tx = winGraphicsConfig.getDefaultTransform();
+            double scaleX = tx.getScaleX();
+            double scaleY = tx.getScaleY();
+            if (scaleX != 1 || scaleY != 1) {
+                shape = shape.getScaledRegion(scaleX, scaleY);
+            }
             setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
                     (shape.isRectangular() ? null : shape));
         } else {
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp	Tue Jul 26 14:45:11 2016 -0700
@@ -473,8 +473,14 @@
 
     POINT p;
     ::GetCursorPos(&p);
-    env->SetIntField(point, AwtCursor::pointXID, (jint)p.x);
-    env->SetIntField(point, AwtCursor::pointYID, (jint)p.y);
+    HMONITOR monitor = MonitorFromPoint(p, MONITOR_DEFAULTTOPRIMARY);
+    int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor);
+    Devices::InstanceAccess devices;
+    AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
+    int x = (device == NULL) ? p.x : device->ScaleDownX(p.x);
+    int y = (device == NULL) ? p.y : device->ScaleDownY(p.y);
+    env->SetIntField(point, AwtCursor::pointXID, x);
+    env->SetIntField(point, AwtCursor::pointYID, y);
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/java.desktop/windows/native/libfontmanager/fontpath.c	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libfontmanager/fontpath.c	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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,6 +32,20 @@
 
 #define BSIZE (max(512, MAX_PATH+1))
 
+/* Typically all local references held by a JNI function are automatically
+ * released by JVM when the function returns. However, there is a limit to the
+ * number of local references that can remain active. If the local references
+ * continue to grow, it could result in out of memory error. Henceforth, we
+ * invoke DeleteLocalRef on objects that are no longer needed for execution in
+ * the JNI function.
+ */
+#define DeleteLocalReference(env, jniRef) \
+    do { \
+        if (jniRef != NULL) { \
+            (*env)->DeleteLocalRef(env, jniRef); \
+            jniRef = NULL; \
+        } \
+    } while (0)
 
 JNIEXPORT jstring JNICALL Java_sun_awt_Win32FontManager_getFontPath(JNIEnv *env, jobject thiz, jboolean noType1)
 {
@@ -88,81 +102,9 @@
     jobject locale;
 } GdiFontMapInfo;
 
-/* IS_NT means NT or later OSes which support Unicode.
- * We have to painfully deal with the ASCII and non-ASCII case we
- * we really want to get the font names as unicode wherever possible.
- * UNICODE_OS is 0 to mean uninitialised, 1 to mean not a unicode OS,
- * 2 to mean a unicode OS.
- */
-
-#define UC_UNKNOWN 0
-#define UC_NO     1
-#define UC_YES    2
-static int UNICODE_OS = UC_UNKNOWN;
-static int GetOSVersion () {
-    OSVERSIONINFO vinfo;
-    vinfo.dwOSVersionInfoSize = sizeof(vinfo);
-    GetVersionEx(&vinfo);
-    if ((int)vinfo.dwMajorVersion > 4) {
-        UNICODE_OS = UC_YES;
-    } else if ((int)vinfo.dwMajorVersion < 4) {
-        UNICODE_OS = UC_NO;
-    } else {
-        if ((int)vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
-            UNICODE_OS = UC_NO;
-        } else {
-            UNICODE_OS = UC_YES;
-        }
-    }
-    return UNICODE_OS;
-}
-
-#define IS_NT ((UNICODE_OS == UC_UNKNOWN) \
-   ? (GetOSVersion() == UC_YES) : (UNICODE_OS == UC_YES))
-
-/* NT is W2K & XP. WIN is Win9x */
+/* Registry entry for fonts */
 static const char FONTKEY_NT[] =
     "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts";
-static const char FONTKEY_WIN[] =
-    "Software\\Microsoft\\Windows\\CurrentVersion\\Fonts";
-
-/* Callback for call to EnumFontFamiliesEx in the EnumFamilyNames function.
- * Expects to be called once for each face name in the family specified
- * in the call. We extract the full name for the font which is expected
- * to be in the "system encoding" and create canonical and lower case
- * Java strings for the name which are added to the maps. The lower case
- * name is used as key to the family name value in the font to family map,
- * the canonical name is one of the"list" of members of the family.
- */
-static int CALLBACK EnumFontFacesInFamilyProcA(
-  ENUMLOGFONTEXA *lpelfe,
-  NEWTEXTMETRICEX *lpntme,
-  int FontType,
-  LPARAM lParam )
-{
-    GdiFontMapInfo *fmi = (GdiFontMapInfo*)lParam;
-    JNIEnv *env = fmi->env;
-    jstring fullname, fullnameLC;
-
-    /* Both Vista and XP return DEVICE_FONTTYPE for OTF fonts */
-    if (FontType != TRUETYPE_FONTTYPE && FontType != DEVICE_FONTTYPE) {
-        return 1;
-    }
-
-    /* printf("FULL=%s\n",lpelfe->elfFullName);fflush(stdout);  */
-
-    fullname = JNU_NewStringPlatform(env, lpelfe->elfFullName);
-    if (fullname == NULL) {
-        (*env)->ExceptionClear(env);
-        return 1;
-    }
-    fullnameLC = (*env)->CallObjectMethod(env, fullname,
-                                          fmi->toLowerCaseMID, fmi->locale);
-    (*env)->CallBooleanMethod(env, fmi->list, fmi->addMID, fullname);
-    (*env)->CallObjectMethod(env, fmi->fontToFamilyMap,
-                             fmi->putMID, fullnameLC, fmi->family);
-    return 1;
-}
 
 typedef struct CheckFamilyInfo {
   wchar_t *family;
@@ -219,6 +161,14 @@
     return info.isDifferent;
 }
 
+/* Callback for call to EnumFontFamiliesEx in the EnumFamilyNames function.
+ * Expects to be called once for each face name in the family specified
+ * in the call. We extract the full name for the font which is expected
+ * to be in the "system encoding" and create canonical and lower case
+ * Java strings for the name which are added to the maps. The lower case
+ * name is used as key to the family name value in the font to family map,
+ * the canonical name is one of the"list" of members of the family.
+ */
 static int CALLBACK EnumFontFacesInFamilyProcW(
   ENUMLOGFONTEXW *lpelfe,
   NEWTEXTMETRICEX *lpntme,
@@ -229,6 +179,19 @@
     JNIEnv *env = fmi->env;
     jstring fullname, fullnameLC;
 
+    /* Exceptions indicate critical errors such that program cannot continue
+     * with further execution. Henceforth, the function returns immediately
+     * on pending exceptions. In these situations, the function also returns
+     * 0 indicating windows API to stop further enumeration and callbacks.
+     *
+     * The JNI functions do not clear the pending exceptions. This allows the
+     * caller (Java code) to check and handle exceptions in the best possible
+     * way.
+     */
+    if ((*env)->ExceptionCheck(env)) {
+        return 0;
+    }
+
     /* Both Vista and XP return DEVICE_FONTTYPE for OTF fonts */
     if (FontType != TRUETYPE_FONTTYPE && FontType != DEVICE_FONTTYPE) {
         return 1;
@@ -250,11 +213,30 @@
         (*env)->ExceptionClear(env);
         return 1;
     }
+
+    (*env)->CallBooleanMethod(env, fmi->list, fmi->addMID, fullname);
+    if ((*env)->ExceptionCheck(env)) {
+        /* Delete the created reference before return */
+        DeleteLocalReference(env, fullname);
+        return 0;
+    }
+
     fullnameLC = (*env)->CallObjectMethod(env, fullname,
                                           fmi->toLowerCaseMID, fmi->locale);
-    (*env)->CallBooleanMethod(env, fmi->list, fmi->addMID, fullname);
+    /* Delete the created reference after its usage */
+    DeleteLocalReference(env, fullname);
+    if ((*env)->ExceptionCheck(env)) {
+        return 0;
+    }
+
     (*env)->CallObjectMethod(env, fmi->fontToFamilyMap,
                              fmi->putMID, fullnameLC, fmi->family);
+    /* Delete the created reference after its usage */
+    DeleteLocalReference(env, fullnameLC);
+    if ((*env)->ExceptionCheck(env)) {
+        return 0;
+    }
+
     return 1;
 }
 
@@ -270,62 +252,6 @@
  * Because we set fmi->list to be the newly created list the call back
  * can safely add to that list without a search.
  */
-static int CALLBACK EnumFamilyNamesA(
-  ENUMLOGFONTEXA *lpelfe,    /* pointer to logical-font data */
-  NEWTEXTMETRICEX *lpntme,   /* pointer to physical-font data */
-  int FontType,              /* type of font */
-  LPARAM lParam)             /* application-defined data */
-{
-    GdiFontMapInfo *fmi = (GdiFontMapInfo*)lParam;
-    JNIEnv *env = fmi->env;
-    jstring familyLC;
-    LOGFONTA lfa;
-
-    /* Both Vista and XP return DEVICE_FONTTYPE for OTF fonts */
-    if (FontType != TRUETYPE_FONTTYPE && FontType != DEVICE_FONTTYPE) {
-        return 1;
-    }
-
-    /* Windows lists fonts which have a vmtx (vertical metrics) table twice.
-     * Once using their normal name, and again preceded by '@'. These appear
-     * in font lists in some windows apps, such as wordpad. We don't want
-     * these so we skip any font where the first character is '@'
-     */
-    if (lpelfe->elfLogFont.lfFaceName[0] == '@') {
-        return 1;
-    }
-    fmi->family = JNU_NewStringPlatform(env,lpelfe->elfLogFont.lfFaceName);
-    if (fmi->family == NULL) {
-        (*env)->ExceptionClear(env);
-        return 1;
-    }
-    familyLC = (*env)->CallObjectMethod(env, fmi->family,
-                                        fmi->toLowerCaseMID, fmi->locale);
-    /* check if already seen this family with a different charset */
-    if ((*env)->CallBooleanMethod(env,fmi->familyToFontListMap,
-                                  fmi->containsKeyMID, familyLC)) {
-        return 1;
-    }
-    fmi->list = (*env)->NewObject(env,
-                                  fmi->arrayListClass, fmi->arrayListCtr, 4);
-    if (fmi->list == NULL) {
-        (*env)->ExceptionClear(env);
-        return 1;
-    }
-    (*env)->CallObjectMethod(env, fmi->familyToFontListMap,
-                             fmi->putMID, familyLC, fmi->list);
-
-/*  printf("FAMILY=%s\n", lpelfe->elfLogFont.lfFaceName);fflush(stdout); */
-
-    memset(&lfa, 0, sizeof(lfa));
-    strcpy(lfa.lfFaceName, lpelfe->elfLogFont.lfFaceName);
-    lfa.lfCharSet = lpelfe->elfLogFont.lfCharSet;
-    EnumFontFamiliesExA(screenDC, &lfa,
-                        (FONTENUMPROCA)EnumFontFacesInFamilyProcA,
-                        lParam, 0L);
-    return 1;
-}
-
 static int CALLBACK EnumFamilyNamesW(
   ENUMLOGFONTEXW *lpelfe,    /* pointer to logical-font data */
   NEWTEXTMETRICEX *lpntme,  /* pointer to physical-font data */
@@ -338,6 +264,19 @@
     size_t slen;
     LOGFONTW lfw;
 
+    /* Exceptions indicate critical errors such that program cannot continue
+     * with further execution. Henceforth, the function returns immediately
+     * on pending exceptions. In these situations, the function also returns
+     * 0 indicating windows API to stop further enumeration and callbacks.
+     *
+     * The JNI functions do not clear the pending exceptions. This allows the
+     * caller (Java code) to check and handle exceptions in the best possible
+     * way.
+     */
+    if ((*env)->ExceptionCheck(env)) {
+        return 0;
+    }
+
     /* Both Vista and XP return DEVICE_FONTTYPE for OTF fonts */
     if (FontType != TRUETYPE_FONTTYPE && FontType != DEVICE_FONTTYPE) {
         return 1;
@@ -362,21 +301,51 @@
         (*env)->ExceptionClear(env);
         return 1;
     }
+
     familyLC = (*env)->CallObjectMethod(env, fmi->family,
                                         fmi->toLowerCaseMID, fmi->locale);
+    /* Delete the created reference after its usage */
+    if ((*env)->ExceptionCheck(env)) {
+        DeleteLocalReference(env, fmi->family);
+        return 0;
+    }
+
     /* check if already seen this family with a different charset */
-    if ((*env)->CallBooleanMethod(env,fmi->familyToFontListMap,
-                                  fmi->containsKeyMID, familyLC)) {
+    jboolean mapHasKey = (*env)->CallBooleanMethod(env,
+                                                   fmi->familyToFontListMap,
+                                                   fmi->containsKeyMID,
+                                                   familyLC);
+    if ((*env)->ExceptionCheck(env)) {
+        /* Delete the created references before return */
+        DeleteLocalReference(env, fmi->family);
+        DeleteLocalReference(env, familyLC);
+        return 0;
+    } else if (mapHasKey) {
+        /* Delete the created references before return */
+        DeleteLocalReference(env, fmi->family);
+        DeleteLocalReference(env, familyLC);
         return 1;
     }
+
     fmi->list = (*env)->NewObject(env,
                                   fmi->arrayListClass, fmi->arrayListCtr, 4);
     if (fmi->list == NULL) {
-        (*env)->ExceptionClear(env);
-        return 1;
+        /* Delete the created references before return */
+        DeleteLocalReference(env, fmi->family);
+        DeleteLocalReference(env, familyLC);
+        return 0;
     }
+
     (*env)->CallObjectMethod(env, fmi->familyToFontListMap,
                              fmi->putMID, familyLC, fmi->list);
+    /* Delete the created reference after its usage */
+    DeleteLocalReference(env, familyLC);
+    if ((*env)->ExceptionCheck(env)) {
+        /* Delete the created reference before return */
+        DeleteLocalReference(env, fmi->family);
+        DeleteLocalReference(env, fmi->list);
+        return 0;
+    }
 
     memset(&lfw, 0, sizeof(lfw));
     wcscpy(lfw.lfFaceName, lpelfe->elfLogFont.lfFaceName);
@@ -384,10 +353,13 @@
     EnumFontFamiliesExW(screenDC, &lfw,
                         (FONTENUMPROCW)EnumFontFacesInFamilyProcW,
                         lParam, 0L);
+
+    /* Delete the created reference after its usage in the enum function */
+    DeleteLocalReference(env, fmi->family);
+    DeleteLocalReference(env, fmi->list);
     return 1;
 }
 
-
 /* It looks like TrueType fonts have " (TrueType)" tacked on the end of their
  * name, so we can try to use that to distinguish TT from other fonts.
  * However if a program "installed" a font in the registry the key may
@@ -410,33 +382,6 @@
  * Note: OpenType fonts seems to have " (TrueType)" suffix on Vista
  *   but " (OpenType)" on XP.
  */
-
-static BOOL RegistryToBaseTTNameA(LPSTR name) {
-    static const char TTSUFFIX[] = " (TrueType)";
-    static const char OTSUFFIX[] = " (OpenType)";
-    size_t TTSLEN = strlen(TTSUFFIX);
-    char *suffix;
-
-    size_t len = strlen(name);
-    if (len == 0) {
-        return FALSE;
-    }
-    if (name[len-1] != ')') {
-        return FALSE;
-    }
-    if (len <= TTSLEN) {
-        return FALSE;
-    }
-
-    /* suffix length is the same for truetype and opentype fonts */
-    suffix = name + len - TTSLEN;
-    if (strcmp(suffix, TTSUFFIX) == 0 || strcmp(suffix, OTSUFFIX) == 0) {
-        suffix[0] = '\0'; /* truncate name */
-        return TRUE;
-    }
-    return FALSE;
-}
-
 static BOOL RegistryToBaseTTNameW(LPWSTR name) {
     static const wchar_t TTSUFFIX[] = L" (TrueType)";
     static const wchar_t OTSUFFIX[] = L" (OpenType)";
@@ -462,71 +407,12 @@
     return FALSE;
 }
 
-static void registerFontA(GdiFontMapInfo *fmi, jobject fontToFileMap,
-                          LPCSTR name, LPCSTR data) {
-    LPSTR ptr1, ptr2;
-    jstring fontStr;
-    JNIEnv *env = fmi->env;
-    size_t dslen = strlen(data);
-    jstring fileStr = JNU_NewStringPlatform(env, data);
-    if (fileStr == NULL) {
-        (*env)->ExceptionClear(env);
-        return;
-    }
-
-    /* TTC or ttc means it may be a collection. Need to parse out
-     * multiple font face names separated by " & "
-     * By only doing this for fonts which look like collections based on
-     * file name we are adhering to MS recommendations for font file names
-     * so it seems that we can be sure that this identifies precisely
-     * the MS-supplied truetype collections.
-     * This avoids any potential issues if a TTF file happens to have
-     * a & in the font name (I can't find anything which prohibits this)
-     * and also means we only parse the key in cases we know to be
-     * worthwhile.
-     */
-    if ((data[dslen-1] == 'C' || data[dslen-1] == 'c') &&
-        (ptr1 = strstr(name, " & ")) != NULL) {
-        ptr1+=3;
-        while (ptr1 >= name) { /* marginally safer than while (true) */
-            while ((ptr2 = strstr(ptr1, " & ")) != NULL) {
-                    ptr1 = ptr2+3;
-            }
-            fontStr = JNU_NewStringPlatform(env, ptr1);
-            if (fontStr == NULL) {
-                (*env)->ExceptionClear(env);
-                return;
-            }
-            fontStr = (*env)->CallObjectMethod(env, fontStr,
-                                               fmi->toLowerCaseMID,
-                                               fmi->locale);
-            (*env)->CallObjectMethod(env, fontToFileMap, fmi->putMID,
-                                     fontStr, fileStr);
-            if (ptr1 == name) {
-                break;
-            } else {
-                *(ptr1-3) ='\0';
-                ptr1 = (LPSTR)name;
-            }
-        }
-    } else {
-        fontStr = JNU_NewStringPlatform(env, name);
-        if (fontStr == NULL) {
-            (*env)->ExceptionClear(env);
-            return;
-        }
-        fontStr = (*env)->CallObjectMethod(env, fontStr,
-                                           fmi->toLowerCaseMID, fmi->locale);
-        (*env)->CallObjectMethod(env, fontToFileMap, fmi->putMID,
-                                 fontStr, fileStr);
-    }
-}
-
 static void registerFontW(GdiFontMapInfo *fmi, jobject fontToFileMap,
                           LPWSTR name, LPWSTR data) {
 
     wchar_t *ptr1, *ptr2;
     jstring fontStr;
+    jstring fontStrLC;
     JNIEnv *env = fmi->env;
     size_t dslen = wcslen(data);
     jstring fileStr = (*env)->NewString(env, data, (jsize)dslen);
@@ -557,13 +443,32 @@
             fontStr = (*env)->NewString(env, ptr1, (jsize)wcslen(ptr1));
             if (fontStr == NULL) {
                 (*env)->ExceptionClear(env);
+                /* Delete the created reference before return */
+                DeleteLocalReference(env, fileStr);
                 return;
             }
-            fontStr = (*env)->CallObjectMethod(env, fontStr,
-                                               fmi->toLowerCaseMID,
-                                               fmi->locale);
+
+            fontStrLC = (*env)->CallObjectMethod(env, fontStr,
+                                                 fmi->toLowerCaseMID,
+                                                 fmi->locale);
+            /* Delete the created reference after its usage */
+            DeleteLocalReference(env, fontStr);
+            if ((*env)->ExceptionCheck(env)) {
+                /* Delete the created reference before return */
+                DeleteLocalReference(env, fileStr);
+                return;
+            }
+
             (*env)->CallObjectMethod(env, fontToFileMap, fmi->putMID,
-                                     fontStr, fileStr);
+                                     fontStrLC, fileStr);
+            /* Delete the reference after its usage */
+            DeleteLocalReference(env, fontStrLC);
+            if ((*env)->ExceptionCheck(env)) {
+                /* Delete the created reference before return */
+                DeleteLocalReference(env, fileStr);
+                return;
+            }
+
             if (ptr1 == name) {
                 break;
             } else {
@@ -575,13 +480,34 @@
         fontStr = (*env)->NewString(env, name, (jsize)wcslen(name));
         if (fontStr == NULL) {
             (*env)->ExceptionClear(env);
+            /* Delete the created reference before return */
+            DeleteLocalReference(env, fileStr);
+            return;
+        }
+
+        fontStrLC = (*env)->CallObjectMethod(env, fontStr,
+                                           fmi->toLowerCaseMID, fmi->locale);
+        /* Delete the created reference after its usage */
+        DeleteLocalReference(env, fontStr);
+        if ((*env)->ExceptionCheck(env)) {
+            /* Delete the created reference before return */
+            DeleteLocalReference(env, fileStr);
             return;
         }
-        fontStr = (*env)->CallObjectMethod(env, fontStr,
-                                           fmi->toLowerCaseMID, fmi->locale);
+
         (*env)->CallObjectMethod(env, fontToFileMap, fmi->putMID,
-                                 fontStr, fileStr);
+                                 fontStrLC, fileStr);
+        /* Delete the created reference after its usage */
+        DeleteLocalReference(env, fontStrLC);
+        if ((*env)->ExceptionCheck(env)) {
+            /* Delete the created reference before return */
+            DeleteLocalReference(env, fileStr);
+            return;
+        }
     }
+
+    /* Delete the created reference after its usage */
+    DeleteLocalReference(env, fileStr);
 }
 
 /* Obtain all the fontname -> filename mappings.
@@ -595,7 +521,6 @@
 {
 #define MAX_BUFFER (FILENAME_MAX+1)
     const wchar_t wname[MAX_BUFFER];
-    const char cname[MAX_BUFFER];
     const char data[MAX_BUFFER];
 
     DWORD type;
@@ -604,10 +529,10 @@
     DWORD dwNameSize;
     DWORD dwDataValueSize;
     DWORD nval;
-    LPCSTR fontKeyName;
     DWORD dwNumValues, dwMaxValueNameLen, dwMaxValueDataLen;
     DWORD numValues = 0;
-    jclass classID;
+    jclass classIDHashMap;
+    jclass classIDString;
     jmethodID putMID;
     GdiFontMapInfo fmi;
 
@@ -619,11 +544,11 @@
         familyToFontListMap == NULL) {
         return;
     }
-    classID = (*env)->FindClass(env, "java/util/HashMap");
-    if (classID == NULL) {
+    classIDHashMap = (*env)->FindClass(env, "java/util/HashMap");
+    if (classIDHashMap == NULL) {
         return;
     }
-    putMID = (*env)->GetMethodID(env, classID, "put",
+    putMID = (*env)->GetMethodID(env, classIDHashMap, "put",
                  "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
     if (putMID == NULL) {
         return;
@@ -634,7 +559,8 @@
     fmi.familyToFontListMap = familyToFontListMap;
     fmi.putMID = putMID;
     fmi.locale = locale;
-    fmi.containsKeyMID = (*env)->GetMethodID(env, classID, "containsKey",
+    fmi.containsKeyMID = (*env)->GetMethodID(env, classIDHashMap,
+                                             "containsKey",
                                              "(Ljava/lang/Object;)Z");
     if (fmi.containsKeyMID == NULL) {
         return;
@@ -654,12 +580,13 @@
     if (fmi.addMID == NULL) {
         return;
     }
-    classID = (*env)->FindClass(env, "java/lang/String");
-    if (classID == NULL) {
+
+    classIDString = (*env)->FindClass(env, "java/lang/String");
+    if (classIDString == NULL) {
         return;
     }
     fmi.toLowerCaseMID =
-        (*env)->GetMethodID(env, classID, "toLowerCase",
+        (*env)->GetMethodID(env, classIDString, "toLowerCase",
                             "(Ljava/util/Locale;)Ljava/lang/String;");
     if (fmi.toLowerCaseMID == NULL) {
         return;
@@ -669,44 +596,29 @@
     if (screenDC == NULL) {
         return;
     }
+
     /* Enumerate fonts via GDI to build maps of fonts and families */
-    if (IS_NT) {
-        LOGFONTW lfw;
-        memset(&lfw, 0, sizeof(lfw));
-        lfw.lfCharSet = DEFAULT_CHARSET;  /* all charsets */
-        wcscpy(lfw.lfFaceName, L"");      /* one face per family (CHECK) */
-        EnumFontFamiliesExW(screenDC, &lfw,
-                            (FONTENUMPROCW)EnumFamilyNamesW,
-                            (LPARAM)(&fmi), 0L);
-    } else {
-        LOGFONT lfa;
-        memset(&lfa, 0, sizeof(lfa));
-        lfa.lfCharSet = DEFAULT_CHARSET; /* all charsets */
-        strcpy(lfa.lfFaceName, "");      /* one face per family */
-        ret = EnumFontFamiliesExA(screenDC, &lfa,
-                            (FONTENUMPROCA)EnumFamilyNamesA,
-                            (LPARAM)(&fmi), 0L);
-    }
+    LOGFONTW lfw;
+    memset(&lfw, 0, sizeof(lfw));
+    lfw.lfCharSet = DEFAULT_CHARSET;  /* all charsets */
+    wcscpy(lfw.lfFaceName, L"");      /* one face per family (CHECK) */
+    EnumFontFamiliesExW(screenDC, &lfw,
+                        (FONTENUMPROCW)EnumFamilyNamesW,
+                        (LPARAM)(&fmi), 0L);
 
     /* Use the windows registry to map font names to files */
-    fontKeyName = (IS_NT) ? FONTKEY_NT : FONTKEY_WIN;
     ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
-                       fontKeyName, 0L, KEY_READ, &hkeyFonts);
+                       FONTKEY_NT, 0L, KEY_READ, &hkeyFonts);
     if (ret != ERROR_SUCCESS) {
         ReleaseDC(NULL, screenDC);
         screenDC = NULL;
         return;
     }
 
-    if (IS_NT) {
-        ret = RegQueryInfoKeyW(hkeyFonts, NULL, NULL, NULL, NULL, NULL, NULL,
-                               &dwNumValues, &dwMaxValueNameLen,
-                               &dwMaxValueDataLen, NULL, NULL);
-    } else {
-        ret = RegQueryInfoKeyA(hkeyFonts, NULL, NULL, NULL, NULL, NULL, NULL,
-                               &dwNumValues, &dwMaxValueNameLen,
-                               &dwMaxValueDataLen, NULL, NULL);
-    }
+    ret = RegQueryInfoKeyW(hkeyFonts, NULL, NULL, NULL, NULL, NULL, NULL,
+                           &dwNumValues, &dwMaxValueNameLen,
+                           &dwMaxValueDataLen, NULL, NULL);
+
     if (ret != ERROR_SUCCESS ||
         dwMaxValueNameLen >= MAX_BUFFER ||
         dwMaxValueDataLen >= MAX_BUFFER) {
@@ -718,39 +630,30 @@
     for (nval = 0; nval < dwNumValues; nval++ ) {
         dwNameSize = MAX_BUFFER;
         dwDataValueSize = MAX_BUFFER;
-        if (IS_NT) {
-            ret = RegEnumValueW(hkeyFonts, nval, (LPWSTR)wname, &dwNameSize,
-                                NULL, &type, (LPBYTE)data, &dwDataValueSize);
-        } else {
-            ret = RegEnumValueA(hkeyFonts, nval, (LPSTR)cname, &dwNameSize,
-                                NULL, &type, (LPBYTE)data, &dwDataValueSize);
-        }
+        ret = RegEnumValueW(hkeyFonts, nval, (LPWSTR)wname, &dwNameSize,
+                            NULL, &type, (LPBYTE)data, &dwDataValueSize);
+
         if (ret != ERROR_SUCCESS) {
             break;
         }
         if (type != REG_SZ) { /* REG_SZ means a null-terminated string */
             continue;
         }
-        if (IS_NT) {
-            if (!RegistryToBaseTTNameW((LPWSTR)wname) ) {
-                /* If the filename ends with ".ttf" or ".otf" also accept it.
-                 * Not expecting to need to do this for .ttc files.
-                 * Also note this code is not mirrored in the "A" (win9x) path.
-                 */
-                LPWSTR dot = wcsrchr((LPWSTR)data, L'.');
-                if (dot == NULL || ((wcsicmp(dot, L".ttf") != 0)
-                                      && (wcsicmp(dot, L".otf") != 0))) {
-                    continue;  /* not a TT font... */
-                }
+
+        if (!RegistryToBaseTTNameW((LPWSTR)wname) ) {
+            /* If the filename ends with ".ttf" or ".otf" also accept it.
+             * Not expecting to need to do this for .ttc files.
+             * Also note this code is not mirrored in the "A" (win9x) path.
+             */
+            LPWSTR dot = wcsrchr((LPWSTR)data, L'.');
+            if (dot == NULL || ((wcsicmp(dot, L".ttf") != 0)
+                                  && (wcsicmp(dot, L".otf") != 0))) {
+                continue;  /* not a TT font... */
             }
-            registerFontW(&fmi, fontToFileMap, (LPWSTR)wname, (LPWSTR)data);
-        } else {
-            if (!RegistryToBaseTTNameA((LPSTR)cname)) {
-                continue; /* not a TT font... */
-            }
-            registerFontA(&fmi, fontToFileMap, cname, (LPCSTR)data);
         }
+        registerFontW(&fmi, fontToFileMap, (LPWSTR)wname, (LPWSTR)data);
     }
+
     RegCloseKey(hkeyFonts);
     ReleaseDC(NULL, screenDC);
     screenDC = NULL;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Dialog/NestedDialogs/Modal/NestedModalDialogTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2011, 2016 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 8155740
+ @summary See <rdar://problem/3429130>: Events: actionPerformed() method not
+          called when it is button is clicked (system load related)
+ @summary com.apple.junit.java.awt.Frame
+ @library ../../../regtesthelpers
+ @build VisibilityValidator
+ @build Util
+ @build Waypoint
+ @run main NestedModalDialogTest
+ */
+//////////////////////////////////////////////////////////////////////////////
+//  NestedModalDialogTest.java
+// The test launches a parent frame. From this parent frame it launches a modal
+// dialog. From the modal dialog it launches a second modal dialog with a text
+// field in it and tries to write into the text field. The test succeeds if you
+// are successfully able to write into this second Nested Modal Dialog
+//////////////////////////////////////////////////////////////////////////////
+// classes necessary for this test
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.Enumeration;
+
+import test.java.awt.regtesthelpers.Waypoint;
+import test.java.awt.regtesthelpers.VisibilityValidator;
+import test.java.awt.regtesthelpers.Util;
+
+public class NestedModalDialogTest {
+
+    Waypoint[] event_checkpoint = new Waypoint[3];
+    VisibilityValidator[] win_checkpoint = new VisibilityValidator[2];
+
+    IntermediateDialog interDiag;
+    TextDialog txtDiag;
+
+    // Global variables so the robot thread can locate things.
+    Button[] robot_button = new Button[2];
+    TextField robot_text = null;
+    static Robot _robot = null;
+
+    /*
+     * @throws InterruptedException
+     * @throws WaypointException
+     */
+    public void testModalDialogs() throws Exception {
+        Frame frame = null;
+        String result = "";
+        Robot robot = getRobot();
+
+        event_checkpoint[0] = new Waypoint(); // "-Launch 1-"
+        event_checkpoint[1] = new Waypoint(); // "-Launch 2-"
+
+        // Thread.currentThread().setName("NestedModalDialogTest Thread");
+        // launch first frame with firstButton
+        frame = new StartFrame();
+        VisibilityValidator.setVisibleAndConfirm(frame);
+        Util.clickOnComp(robot_button[0], robot);
+
+        // Dialog must be created and onscreen before we proceed.
+        //   The event_checkpoint waits for the Dialog to be created.
+        //   The win_checkpoint waits for the Dialog to be visible.
+        event_checkpoint[0].requireClear("TestFrame actionPerformed() never "
+                + "called, see <rdar://problem/3429130>");
+        win_checkpoint[0].requireVisible();
+        Util.clickOnComp(robot_button[1], robot);
+
+        // Again, the Dialog must be created and onscreen before we proceed.
+        //   The event_checkpoint waits for the Dialog to be created.
+        //   The win_checkpoint waits for the Dialog to be visible.
+        event_checkpoint[1].requireClear("IntermediateDialog actionPerformed() "
+                + "never called, see <rdar://problem/3429130>");
+        win_checkpoint[1].requireVisible();
+        Util.clickOnComp(robot_text, robot);
+
+        // I'm really not sure whether the click is needed for focus
+        // but since it's asynchronous, as is the actually gaining of focus
+        // we might as well do our best
+        try {
+            EventQueue.invokeAndWait(new Runnable() {
+                public void run() {
+                }
+            });
+        } catch (Exception e) {
+        }
+
+        robot.keyPress(KeyEvent.VK_SHIFT);
+
+        robot.keyPress(KeyEvent.VK_H);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_H);
+
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+
+        robot.keyPress(KeyEvent.VK_E);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_E);
+
+        robot.keyPress(KeyEvent.VK_L);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_L);
+
+        robot.keyPress(KeyEvent.VK_L);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_L);
+
+        robot.keyPress(KeyEvent.VK_O);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_O);
+
+        //
+        // NOTE THAT WE MAY HAVE MORE SYNCHRONIZATION WORK TO DO HERE.
+        // CURRENTLY THERE IS NO GUARANTEE THAT THE KEYEVENT THAT THAT
+        // TYPES THE 'O' HAS BEEN PROCESSED BEFORE WE GET THE RESULT
+        //
+        // This is a (lame) attempt at waiting for the last typeKey events to
+        // propagate. It's not quite right because robot uses
+        // CGRemoteOperations, which are asynchronous. But that's why I put in
+        // the pause
+        try {
+            EventQueue.invokeAndWait(new Runnable() {
+                public void run() {
+                }
+            });
+        } catch (Exception e) {
+        }
+
+        // Need to call this before the dialog that robot_text is in is disposed
+        result = robot_text.getText();
+
+        Thread.sleep(50); // shouldn't need this, but pause adds stability
+        // Click Close box of modal dialog with textField
+        Util.clickOnComp(txtDiag, robot);
+
+        Thread.sleep(50); // shouldn't need this, but pause adds stability
+        // Click Close box of intermediate modal dialog
+        Util.clickOnComp(interDiag, robot);
+
+        Thread.sleep(50); // shouldn't need this, but pause adds stability
+        // Click Close box of intermediate modal dialog
+        Util.clickOnComp(frame, robot);
+
+        String expected = "Hello";
+    }
+
+    private static Robot getRobot() {
+        if (_robot == null) {
+            try {
+                _robot = new Robot();
+            } catch (AWTException e) {
+                throw new RuntimeException("Robot creation failed");
+            }
+        }
+        return _robot;
+    }
+
+    //////////////////// Start Frame ///////////////////
+    /**
+     * Launches the first frame with a button in it
+     */
+    class StartFrame extends Frame {
+
+        /**
+         * Constructs a new instance.
+         */
+        public StartFrame() {
+            super("First Frame");
+            setLayout(new GridBagLayout());
+            setLocation(375, 200);
+            setSize(271, 161);
+            Button but = new Button("Make Intermediate");
+            but.addActionListener(new java.awt.event.ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    interDiag = new IntermediateDialog(StartFrame.this);
+                    win_checkpoint[0] = new VisibilityValidator(interDiag);
+                    interDiag.setSize(300, 200);
+
+                    // may need listener to watch this move.
+                    interDiag.setLocation(getLocationOnScreen());
+                    interDiag.pack();
+                    event_checkpoint[0].clear();
+                    interDiag.setVisible(true);
+                }
+            });
+            Panel pan = new Panel();
+            pan.add(but);
+            add(pan);
+            robot_button[0] = but;
+            addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent e) {
+                    setVisible(false);
+                    dispose();
+                }
+            });
+        }
+    }
+
+    ///////////////////////////// MODAL DIALOGS /////////////////////////////
+    /* A Dialog that launches a sub-dialog */
+    class IntermediateDialog extends Dialog {
+
+        Dialog m_parent;
+
+        public IntermediateDialog(Frame parent) {
+            super(parent, "Intermediate Modal", true /*Modal*/);
+            m_parent = this;
+            Button but = new Button("Make Text");
+            but.addActionListener(new java.awt.event.ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    txtDiag = new TextDialog(m_parent);
+                    win_checkpoint[1] = new VisibilityValidator(txtDiag);
+                    txtDiag.setSize(300, 100);
+                    event_checkpoint[1].clear();
+                    txtDiag.setVisible(true);
+                }
+            });
+            Panel pan = new Panel();
+            pan.add(but);
+            add(pan);
+            pack();
+            addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent e) {
+                    setVisible(false);
+                    dispose();
+                }
+            });
+
+            // The robot needs to know about us, so set global
+            robot_button[1] = but;
+        }
+    }
+
+    /* A Dialog that just holds a text field */
+    class TextDialog extends Dialog {
+
+        public TextDialog(Dialog parent) {
+            super(parent, "Modal Dialog", true /*Modal*/);
+            TextField txt = new TextField("", 10);
+            Panel pan = new Panel();
+            pan.add(txt);
+            add(pan);
+            pack();
+            addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent e) {
+                    setVisible(false);
+                    dispose();
+                }
+            });
+
+            // The robot needs to know about us, so set global
+            robot_text = txt;
+        }
+    }
+
+    public static void main(String[] args) throws RuntimeException, Exception {
+        try {
+            new NestedModalDialogTest().testModalDialogs();
+        } catch (Exception e) {
+            throw new RuntimeException("NestedModalDialogTest object creation "
+                    + "failed");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Dialog/NestedDialogs/Modeless/NestedModelessDialogTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2011, 2016 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 8155740
+ @summary See <rdar://problem/3429130>: Events: actionPerformed() method not
+              called when it is button is clicked (system load related)
+ @summary com.apple.junit.java.awt.Frame
+ @library ../../../regtesthelpers
+ @build VisibilityValidator
+ @build Util
+ @build Waypoint
+ @run main NestedModelessDialogTest
+ */
+/////////////////////////////////////////////////////////////////////////////
+//  NestedModelessDialogTest.java
+// The test launches a parent frame. From this parent frame it launches a modal
+// dialog. From the modal dialog it launches a modeless dialog with a text
+// field in it and tries to write into the text field. The test succeeds if you
+// are successfully able to write into this Nested Modeless Dialog
+/////////////////////////////////////////////////////////////////////////////
+// classes necessary for this test
+import java.awt.*;
+import java.awt.event.*;
+import java.util.Enumeration;
+
+import test.java.awt.regtesthelpers.Util;
+import test.java.awt.regtesthelpers.VisibilityValidator;
+import test.java.awt.regtesthelpers.Waypoint;
+
+public class NestedModelessDialogTest {
+
+    Waypoint[] event_checkpoint = new Waypoint[3];
+    VisibilityValidator[] win_checkpoint = new VisibilityValidator[2];
+
+    IntermediateDialog interDiag;
+    TextDialog txtDiag;
+
+    // Global variables so the robot thread can locate things.
+    Button[] robot_button = new Button[2];
+    TextField robot_text = null;
+    static Robot _robot = null;
+
+    /**
+     * Get called by test harness
+     *
+     * @throws Exception
+     */
+    public void testModelessDialogs() throws Exception {
+        Frame frame = null;
+        String result = "";
+        Robot robot = getRobot();
+
+        event_checkpoint[0] = new Waypoint(); // "-Launch 1-"
+        event_checkpoint[1] = new Waypoint(); // "-Launch 2-"
+
+        // launch first frame with fistButton
+        frame = new StartFrame();
+        VisibilityValidator.setVisibleAndConfirm(frame);
+        Util.clickOnComp(robot_button[0], robot);
+
+        // Dialog must be created and onscreen before we proceed.
+        //   The event_checkpoint waits for the Dialog to be created.
+        //   The win_checkpoint waits for the Dialog to be visible.
+        event_checkpoint[0].requireClear();
+        win_checkpoint[0].requireVisible();
+        Util.clickOnComp(robot_button[1], robot);
+
+        // Again, the Dialog must be created and onscreen before we proceed.
+        //   The event_checkpoint waits for the Dialog to be created.
+        //   The win_checkpoint waits for the Dialog to be visible.
+        event_checkpoint[1].requireClear();
+        win_checkpoint[1].requireVisible();
+        Util.clickOnComp(robot_text, robot);
+
+        // I'm really not sure whether the click is needed for focus
+        // but since it's asynchronous, as is the actually gaining of focus
+        // we might as well do our best
+        try {
+            EventQueue.invokeAndWait(new Runnable() {
+                public void run() {
+                }
+            });
+        } catch (Exception e) {
+        }
+
+        robot.keyPress(KeyEvent.VK_SHIFT);
+
+        robot.keyPress(KeyEvent.VK_H);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_H);
+
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+
+        robot.keyPress(KeyEvent.VK_E);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_E);
+
+        robot.keyPress(KeyEvent.VK_L);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_L);
+
+        robot.keyPress(KeyEvent.VK_L);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_L);
+
+        robot.keyPress(KeyEvent.VK_O);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_O);
+
+        //
+        // NOTE THAT WE MAY HAVE MORE SYNCHRONIZATION WORK TO DO HERE.
+        // CURRENTLY THERE IS NO GUARANTEE THAT THE KEYEVENT THAT THAT
+        // TYPES THE 'O' HAS BEEN PROCESSED BEFORE WE GET THE RESULT
+        //
+        // This is a (lame) attempt at waiting for the last typeKey events to
+        // propagate. It's not quite right because robot uses
+        // CGRemoteOperations, which are asynchronous. But that's why I put in
+        // the Thread.sleep
+        try {
+            EventQueue.invokeAndWait(new Runnable() {
+                public void run() {
+                }
+            });
+        } catch (Exception e) {
+        }
+
+        // Need to call this before the dialog that robot_text is in is disposed
+        result = robot_text.getText();
+
+        Thread.sleep(50); // Thread.sleep adds stability
+        // Click Close box of modeless dialog with textField
+        Util.clickOnComp(txtDiag, robot);
+
+        Thread.sleep(50); // Thread.sleep adds stability
+        // Click Close box of intermediate modal dialog
+        Util.clickOnComp(interDiag, robot);
+
+        Thread.sleep(50); // Thread.sleep adds stability
+        // Click Close box of intermediate modal dialog
+        Util.clickOnComp(frame, robot);
+
+        String expected = "Hello";
+    }
+
+    private static Robot getRobot() {
+        if (_robot == null) {
+            try {
+                _robot = new Robot();
+            } catch (AWTException e) {
+                throw new RuntimeException("Robot creation failed");
+            }
+        }
+        return _robot;
+    }
+
+    //////////////////// Start Frame ///////////////////
+    /**
+     * Launches the first frame with a button in it
+     */
+    class StartFrame extends Frame {
+
+        /**
+         * Constructs a new instance.
+         */
+        public StartFrame() {
+            super("First Frame");
+            setLayout(new GridBagLayout());
+            setLocation(375, 200);
+            setSize(271, 161);
+            Button but = new Button("Make Intermediate");
+            but.addActionListener(new java.awt.event.ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    interDiag = new IntermediateDialog(StartFrame.this);
+                    win_checkpoint[0] = new VisibilityValidator(interDiag);
+                    interDiag.setSize(300, 200);
+
+                    // may need listener to watch this move.
+                    interDiag.setLocation(getLocationOnScreen());
+                    interDiag.pack();
+                    event_checkpoint[0].clear();
+                    interDiag.setVisible(true);
+                }
+            });
+            Panel pan = new Panel();
+            pan.add(but);
+            add(pan);
+            robot_button[0] = but;
+            addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent e) {
+                    setVisible(false);
+                    dispose();
+                }
+            });
+        }
+    }
+
+    ///////////////////////////// VARIOUS DIALOGS //////////////////////////
+    /* A Dialog that launches a sub-dialog */
+    class IntermediateDialog extends Dialog {
+
+        Dialog m_parent;
+
+        public IntermediateDialog(Frame parent) {
+            super(parent, "Intermediate Modal", true /*Modal*/);
+            m_parent = this;
+            Button but = new Button("Make Text");
+            but.addActionListener(new java.awt.event.ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    txtDiag = new TextDialog(m_parent);
+                    win_checkpoint[1] = new VisibilityValidator(txtDiag);
+                    txtDiag.setSize(300, 100);
+                    event_checkpoint[1].clear();
+                    txtDiag.setVisible(true);
+                }
+            });
+            Panel pan = new Panel();
+            pan.add(but);
+            add(pan);
+            pack();
+            addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent e) {
+                    setVisible(false);
+                    dispose();
+                }
+            });
+
+            // The robot needs to know about us, so set global
+            robot_button[1] = but;
+        }
+    }
+
+    /* A Dialog that just holds a text field */
+    class TextDialog extends Dialog {
+
+        public TextDialog(Dialog parent) {
+            super(parent, "Modeless Dialog", false /*Modeless*/);
+            TextField txt = new TextField("", 10);
+            Panel pan = new Panel();
+            pan.add(txt);
+            add(pan);
+            pack();
+            addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent e) {
+                    setVisible(false);
+                    dispose();
+                }
+            });
+
+            // The robot needs to know about us, so set global
+            robot_text = txt;
+        }
+    }
+
+    public static void main(String[] args) throws RuntimeException {
+        try {
+            new NestedModelessDialogTest().testModelessDialogs();
+        } catch (Exception e) {
+            throw new RuntimeException("NestedModelessDialogTest object "
+                    + "creation failed");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Headless/ThemeReaderCrashTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2016, 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 8159956
+ * @summary Test to check JVM crash is not observed in headless mode while
+ * trying to create a JScrollPane
+ * @run main/othervm -Djava.awt.headless=true ThemeReaderCrashTest
+ */
+
+import javax.swing.JScrollPane;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.ScrollPaneConstants;
+
+public class ThemeReaderCrashTest {
+
+    public static void main(String[] args) throws Exception {
+
+        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                ThemeReaderCrashTest obj = new ThemeReaderCrashTest();
+            }
+        });
+    }
+
+    ThemeReaderCrashTest() {
+        JPanel panel = new JPanel();
+        JScrollPane pane =
+            new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
+                            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
+        panel.setSize(300, 200);
+
+        panel.add(pane);
+    }
+}
+
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/JGlassPaneInternalFrameOverlapping.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JGlassPaneInternalFrameOverlapping.java	Tue Jul 26 14:45:11 2016 -0700
@@ -45,9 +45,10 @@
  * @bug 6637655 6985776
  * @summary Overlapping test for javax.swing.JScrollPane
  * @author sergey.grinev@oracle.com: area=awt.mixing
- * @library ../../regtesthelpers
+ * @library /java/awt/patchlib  ../../regtesthelpers
  * @modules java.desktop/sun.awt
  *          java.desktop/java.awt.peer
+ * @build java.desktop/java.awt.Helper
  * @build Util
  * @run main JGlassPaneInternalFrameOverlapping
  */
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/JGlassPaneMoveOverlapping.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JGlassPaneMoveOverlapping.java	Tue Jul 26 14:45:11 2016 -0700
@@ -46,9 +46,10 @@
  * @bug 6637655 6981919
  * @summary Overlapping test for javax.swing.JScrollPane
  * @author sergey.grinev@oracle.com: area=awt.mixing
- * @library ../../regtesthelpers
+ * @library /java/awt/patchlib  ../../regtesthelpers
  * @modules java.desktop/sun.awt
  *          java.desktop/java.awt.peer
+ * @build java.desktop/java.awt.Helper
  * @build Util
  * @run main JGlassPaneMoveOverlapping
  */
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/JInternalFrameMoveOverlapping.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JInternalFrameMoveOverlapping.java	Tue Jul 26 14:45:11 2016 -0700
@@ -42,9 +42,10 @@
  * @bug 6985399
  * @summary Overlapping test for javax.swing.JScrollPane
  * @author sergey.grinev@oracle.com: area=awt.mixing
- * @library ../../regtesthelpers
+ * @library /java/awt/patchlib  ../../regtesthelpers
  * @modules java.desktop/sun.awt
  *          java.desktop/java.awt.peer
+ * @build java.desktop/java.awt.Helper
  * @build Util
  * @run main JInternalFrameMoveOverlapping
  */
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/JInternalFrameOverlapping.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JInternalFrameOverlapping.java	Tue Jul 26 14:45:11 2016 -0700
@@ -41,9 +41,10 @@
  * @key headful
  * @summary Overlapping test for javax.swing.JScrollPane
  * @author sergey.grinev@oracle.com: area=awt.mixing
- * @library ../../regtesthelpers
+ * @library /java/awt/patchlib  ../../regtesthelpers
  * @modules java.desktop/sun.awt
  *          java.desktop/java.awt.peer
+ * @build java.desktop/java.awt.Helper
  * @build Util
  * @run main JInternalFrameOverlapping
  */
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/JScrollPaneOverlapping.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JScrollPaneOverlapping.java	Tue Jul 26 14:45:11 2016 -0700
@@ -43,9 +43,10 @@
  * @key headful
  * @summary Overlapping test for javax.swing.JScrollPane
  * @author sergey.grinev@oracle.com: area=awt.mixing
- * @library ../../regtesthelpers
+ * @library /java/awt/patchlib  ../../regtesthelpers
  * @modules java.desktop/sun.awt
  *          java.desktop/java.awt.peer
+ * @build java.desktop/java.awt.Helper
  * @build Util
  * @run main JScrollPaneOverlapping
  */
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/JSplitPaneOverlapping.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JSplitPaneOverlapping.java	Tue Jul 26 14:45:11 2016 -0700
@@ -50,9 +50,10 @@
  * @bug 6986109
  * @summary Overlapping test for javax.swing.JSplitPane
  * @author sergey.grinev@oracle.com: area=awt.mixing
- * @library ../../regtesthelpers
+ * @library /java/awt/patchlib  ../../regtesthelpers
  * @modules java.desktop/sun.awt
  *          java.desktop/java.awt.peer
+ * @build java.desktop/java.awt.Helper
  * @build Util
  * @run main JSplitPaneOverlapping
  */
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java	Tue Jul 26 14:45:11 2016 -0700
@@ -46,10 +46,11 @@
  * @key headful
  * @bug 6776743
  * @summary Opaque overlapping test for each AWT component
- * @library ../../regtesthelpers
+ * @library /java/awt/patchlib  ../../regtesthelpers
  * @modules java.desktop/com.sun.awt
  *          java.desktop/java.awt.peer
  *          java.desktop/sun.awt
+ * @build java.desktop/java.awt.Helper
  * @build Util
  * @run main OpaqueOverlapping
  */
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/OpaqueOverlappingChoice.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/OpaqueOverlappingChoice.java	Tue Jul 26 14:45:11 2016 -0700
@@ -32,10 +32,11 @@
  * @key headful
  * @bug 6994264
  * @summary Opaque overlapping test for Choice AWT component
- * @library ../../regtesthelpers
+ * @library /java/awt/patchlib  ../../regtesthelpers
  * @modules java.desktop/com.sun.awt
  *          java.desktop/java.awt.peer
  *          java.desktop/sun.awt
+ * @build java.desktop/java.awt.Helper
  * @build Util
  * @run main OpaqueOverlappingChoice
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mouse/8158205/MouseHandCursorTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2016, 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 8158205
+ * @summary HiDPI hand cursor broken on Windows
+ * @run main/manual/othervm -Dsun.java2d.uiScale=2 MouseHandCursorTest
+ */
+import java.awt.Cursor;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.concurrent.CountDownLatch;
+import javax.swing.JFrame;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+public class MouseHandCursorTest {
+
+    private static GridBagLayout layout;
+    private static JPanel mainControlPanel;
+    private static JPanel resultButtonPanel;
+    private static JLabel instructionText;
+    private static JButton passButton;
+    private static JButton failButton;
+    private static JFrame mainFrame;
+    private static CountDownLatch latch;
+
+    public static void main(String[] args) throws Exception {
+        latch = new CountDownLatch(1);
+        createUI();
+        latch.await();
+    }
+
+    public static void createUI() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                mainFrame = new JFrame("Hand Cursor Test");
+                layout = new GridBagLayout();
+                mainControlPanel = new JPanel(layout);
+                resultButtonPanel = new JPanel(layout);
+
+                GridBagConstraints gbc = new GridBagConstraints();
+                String instructions
+                        = "<html><center>INSTRUCTIONS:</center><br>"
+                        + "Check the mouse cursor type on frame.<br>"
+                        + "If mouse cursor is hand cursor test passed else failed"
+                        + "<br><br></html>";
+
+                instructionText = new JLabel();
+                instructionText.setText(instructions);
+
+                gbc.gridx = 0;
+                gbc.gridy = 0;
+                gbc.fill = GridBagConstraints.HORIZONTAL;
+                mainControlPanel.add(instructionText, gbc);
+
+                passButton = new JButton("Pass");
+                passButton.setActionCommand("Pass");
+                passButton.addActionListener((ActionEvent e) -> {
+                    latch.countDown();
+                    mainFrame.dispose();
+                });
+
+                failButton = new JButton("Fail");
+                failButton.setActionCommand("Fail");
+                failButton.addActionListener(new ActionListener() {
+                    @Override
+                    public void actionPerformed(ActionEvent e) {
+                        latch.countDown();
+                        mainFrame.dispose();
+                        throw new RuntimeException("Test Failed");
+                    }
+                });
+                gbc.gridx = 2;
+                gbc.gridy = 0;
+                resultButtonPanel.add(passButton, gbc);
+                gbc.gridx = 3;
+                gbc.gridy = 0;
+                resultButtonPanel.add(failButton, gbc);
+
+                gbc.gridx = 0;
+                gbc.gridy = 2;
+                mainControlPanel.add(resultButtonPanel, gbc);
+
+                mainFrame.add(mainControlPanel);
+                mainFrame.setSize(400, 200);
+                mainFrame.setLocationRelativeTo(null);
+                mainFrame.setVisible(true);
+
+                mainFrame.addWindowListener(new WindowAdapter() {
+                    @Override
+                    public void windowClosing(WindowEvent e) {
+                        latch.countDown();
+                        mainFrame.dispose();
+                    }
+                });
+                mainFrame.getContentPane().setCursor(Cursor.
+                        getPredefinedCursor(Cursor.HAND_CURSOR));
+            }
+        });
+    }
+}
--- a/jdk/test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java	Tue Jul 26 14:45:11 2016 -0700
@@ -24,7 +24,7 @@
 /*
  @test
  @key headful
- @bug 6180449
+ @bug 6180449 8160764
  @summary TextArea scrolls to its left when selecting the text from the end.
  @run main TextAreaScrolling
  */
@@ -42,6 +42,12 @@
     Robot robot;
 
     TextAreaScrolling() {
+        try {
+            robot = new Robot();
+        } catch (Exception ex) {
+            throw new RuntimeException("Robot Creation Failed");
+        }
+
         mainFrame = new Frame();
         mainFrame.setSize(200, 200);
         mainFrame.setLocation(200, 200);
@@ -49,19 +55,10 @@
         textArea = new TextArea();
         textArea.setText("1234 5678");
         textArea.setSelectionStart(3);
-        textArea.setSelectionStart(4);
+        textArea.setSelectionEnd(4);
         mainFrame.add(textArea);
         mainFrame.setVisible(true);
         textArea.requestFocusInWindow();
-
-        try {
-            robot = new Robot();
-            robot.setAutoWaitForIdle(true);
-        } catch (Exception ex) {
-            dispose();
-            System.exit(0);
-            throw new RuntimeException("Robot Creation Failed");
-        }
     }
 
     public void dispose() {
@@ -71,6 +68,8 @@
     }
 
     public void performTest() {
+        robot.waitForIdle();
+        robot.delay(200);
         Point loc = textArea.getLocationOnScreen();
         Rectangle textAreaBounds = new Rectangle();
         textArea.getBounds(textAreaBounds);
@@ -80,7 +79,7 @@
 
         // Perform selection by scrolling to left from end of char sequence.
         robot.mousePress(InputEvent.BUTTON1_MASK);
-        robot.mouseMove(textAreaBounds.x - 5, loc.y + 5);
+        robot.mouseMove(loc.x - 5, loc.y + 5);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
         // Perform double click on beginning word of TextArea
@@ -91,11 +90,12 @@
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
         robot.delay(100);
+        robot.waitForIdle();
 
         if (textArea.getSelectedText().contentEquals("5678")) {
             dispose();
-            throw new RuntimeException ("TextArea over scrolled towards left"
-                + "Expected selected text: '1234 ' and for mac '1234'"
+            throw new RuntimeException ("TextArea over scrolled towards left. "
+                + "Expected selected text: '1234 ' and for mac '1234' "
                 + "Actual selected text: 5678");
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/8159168/SetShapeTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2016, 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 8159168
+ * @summary [hidpi] Window.setShape() works incorrectly on HiDPI
+ * @run main/othervm -Dsun.java2d.uiScale=2 SetShapeTest
+ */
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Panel;
+import java.awt.Rectangle;
+import java.awt.Window;
+import java.awt.geom.Area;
+import java.awt.geom.Rectangle2D;
+import java.awt.Robot;
+import javax.swing.SwingUtilities;
+
+public class SetShapeTest {
+
+    private static Window window;
+    private static Frame background;
+
+    public static void main(String[] args) throws Exception {
+        createUI();
+        Robot robot = new Robot();
+        robot.waitForIdle();
+        Rectangle rect = window.getBounds();
+        rect.x += rect.width - 10;
+        rect.y += rect.height - 10;
+        Color c = robot.getPixelColor(rect.x, rect.y);
+        try {
+            if (!c.equals(Color.RED)) {
+                throw new RuntimeException("Test Failed");
+            }
+        } finally {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                @Override
+                public void run() {
+                    background.dispose();
+                    window.dispose();
+                }
+            });
+        }
+    }
+
+    private static void createUI() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                background = new Frame();
+                background.setUndecorated(true);
+                background.setBackground(Color.blue);
+                background.setSize(300, 300);
+                background.setLocation(100, 100);
+                background.setVisible(true);
+                window = new Window(background);
+                window.setBackground(Color.red);
+                window.add(new Panel(), BorderLayout.CENTER);
+                window.setLocation(200, 200);
+                window.setSize(100, 100);
+                Area a = new Area();
+                a.add(new Area(new Rectangle2D.Double(0, 0, 100, 100)));
+                window.setShape(a);
+                window.setVisible(true);
+                window.toFront();
+            }
+        });
+    }
+}
--- a/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.html	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.html	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2015, 2016, 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,7 +23,7 @@
 
   @test
   @key headful
-  @bug 8139227
+  @bug 8139227 8159460
   @summary Text fields in JPopupMenu structure do not receive focus in hosted
            Applets
   @author Semyon Sadetsky
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/GetScreenLocation/GetScreenLocationTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016, 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 @summary setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
+ * @bug 8036915
+ * @run main GetScreenLocationTest
+ */
+import java.awt.*;
+
+public class GetScreenLocationTest {
+
+    public static void main(String[] args) throws Exception {
+        Robot robot = new Robot();
+        Window frame = null;
+        for(int i = 0; i < 50; i++) {
+            if(frame != null) frame.dispose();
+            frame = new Dialog((Frame)null);
+            frame.setBounds(0, 0, 200, 200);
+            frame.setVisible(true);
+            robot.waitForIdle();
+            robot.delay(200);
+            frame.setLocation(321, 321);
+            robot.waitForIdle();
+            robot.delay(200);
+            Dimension size = frame.getSize();
+            if(size.width != 200 || size.height != 200) {
+                frame.dispose();
+                throw new RuntimeException("getSize() is wrong " + size);
+            }
+            Rectangle r = frame.getBounds();
+            frame.dispose();
+            if(r.x != 321 || r.y != 321) {
+                throw new RuntimeException("getLocation() returns " +
+                        "wrong coordinates " + r.getLocation());
+            }
+            if(r.width != 200 || r.height != 200) {
+                throw new RuntimeException("getSize() is wrong " + r.getSize());
+            }
+        }
+        System.out.println("ok");
+    }
+
+}
--- a/jdk/test/java/awt/font/JNICheck/LoadFontsJNICheck.sh	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/font/JNICheck/LoadFontsJNICheck.sh	Tue Jul 26 14:45:11 2016 -0700
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2016, 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,7 +23,7 @@
 
 #
 #   @test
-#   @bug        8138817
+#   @bug        8138817 8152971
 #   @summary    Tests that there are no JNI warnings about local references.
 #   @compile LoadFontsJNICheck.java
 #   @run shell/timeout=300 LoadFontsJNICheck.sh
@@ -37,11 +37,6 @@
   CP="${TESTCLASSES}"
 fi
 
-if [ $OS != Darwin ]
-then
-    exit 0
-fi
-
 if [ -z "${TESTJAVA}" ] ; then
    JAVACMD=java
 else
--- a/jdk/test/java/awt/print/PrinterJob/PrintTestLexmarkIQ.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/java/awt/print/PrinterJob/PrintTestLexmarkIQ.java	Tue Jul 26 14:45:11 2016 -0700
@@ -20,9 +20,9 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-/*
+ /*
  * @test
- * @bug 6966350
+ * @bug 6966350 8160882
  * @summary Verifies if Empty pages are printed on Lexmark E352dn PS3
  *           with "1200 IQ" setting
  * @run main/manual PrintTestLexmarkIQ
@@ -33,6 +33,8 @@
 import java.awt.Font;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
 import java.awt.geom.Rectangle2D;
 import java.awt.print.PageFormat;
 import java.awt.print.Paper;
@@ -145,6 +147,13 @@
         dialog.add(mainPanel);
         dialog.pack();
         dialog.setVisible(true);
+        dialog.addWindowListener(new WindowAdapter() {
+            public void windowClosing(WindowEvent e) {
+                System.out.println("main dialog closing");
+                testGeneratedInterrupt = false;
+                mainThread.interrupt();
+            }
+        });
     }
 
     public int print(Graphics g, PageFormat pf, int pi)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/regtesthelpers/VisibilityValidator.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 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.
+ *
+ * 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.
+ */
+
+ /*
+ * @summary Utility routines that wait for a window to be displayed or for
+colors to be visible
+ * @summary com.apple.junit.utils
+ */
+package test.java.awt.regtesthelpers;
+
+import java.awt.*;
+import java.awt.event.*;
+
+//import junit.framework.Assert;
+public class VisibilityValidator {
+
+    // Wait up to five seconds for our window events
+    static final int SETUP_PERIOD = 5000;
+    static final boolean DEBUG = false;
+
+    volatile Window win = null;
+    boolean activated = false;
+    boolean opened = false;
+    boolean focused = false;
+    volatile boolean valid = false;
+
+    //
+    // Utility functions that encapsulates normal usage patterns
+    //
+    public static void setVisibleAndConfirm(Frame testframe) throws Exception {
+        setVisibleAndConfirm(testframe, "Could not confirm test frame was "
+                + "visible");
+    }
+
+    public static void setVisibleAndConfirm(Frame testframe, String msg)
+            throws Exception {
+        if (testframe.isVisible()) {
+            throw new RuntimeException("Frame is already visible");
+        }
+
+        VisibilityValidator checkpoint = new VisibilityValidator(testframe);
+        testframe.setVisible(true);
+        checkpoint.requireVisible();
+        if (!checkpoint.isValid()) {
+            //System.err.println(msg);
+            throw new Exception("Frame not visible after " + SETUP_PERIOD
+                    + " milliseconds");
+        }
+    }
+
+    //
+    // Add listeners to the window
+    //
+    public VisibilityValidator(Window win) {
+        this.win = win;
+        WindowAdapter watcher = new WindowAdapter() {
+            public void windowOpened(WindowEvent e) {
+                doOpen();
+            }
+
+            public void windowActivated(WindowEvent e) {
+                doActivate();
+            }
+
+            public void windowGainedFocus(WindowEvent e) {
+                doGainedFocus();
+            }
+        };
+
+        win.addWindowListener(watcher);
+        win.addWindowFocusListener(watcher);
+    }
+
+    // Make the window visible
+    //
+    // The only way to make it through this routine is for the window to
+    // generate BOTH a windowOpened, a windowActivated event and a
+    // windowGainedFocus, or to timeout.
+    //
+    synchronized public void requireVisible() {
+        int tries = 0;
+
+        // wait for windowOpened and windowActivated events
+        try {
+            while ((opened == false)
+                    || (activated == false)
+                    || (focused == false)) {
+                if (tries < 4) {
+                    tries += 1;
+                    wait(SETUP_PERIOD);
+                } else {
+                    break;
+                }
+            }
+
+            if (opened && activated) {
+                valid = true;
+            } else {
+                valid = false;
+            }
+        } catch (InterruptedException ix) {
+            valid = false;
+        }
+
+        // Extra-super paranoid checks
+        if (win.isVisible() == false) {
+            valid = false;
+        }
+
+        if (win.isShowing() == false) {
+            valid = false;
+        }
+
+        if (win.isFocused() == false) {
+            valid = false;
+        }
+
+        if (DEBUG) {
+            if (!isValid()) {
+                System.out.println("\tactivated:" + new Boolean(activated));
+                System.out.println("\topened:" + new Boolean(opened));
+                System.out.println("\tfocused:" + new Boolean(focused));
+                System.out.println("\tvalid:" + new Boolean(valid));
+                System.out.println("\tisVisible():"
+                        + new Boolean(win.isVisible()));
+                System.out.println("\tisShowing():"
+                        + new Boolean(win.isShowing()));
+                System.out.println("\tisFocused():"
+                        + new Boolean(win.isFocused()));
+            }
+        }
+
+    }
+
+    synchronized void doOpen() {
+        opened = true;
+        notify();
+    }
+
+    synchronized void doActivate() {
+        activated = true;
+        notify();
+    }
+
+    synchronized void doGainedFocus() {
+        focused = true;
+        notify();
+    }
+
+    public boolean isValid() {
+        return valid;
+    }
+
+    public boolean isClear() {
+        return valid;
+    }
+
+    volatile static Robot robot = null;
+
+    // utility function that waits until a Component is shown with the
+    // appropriate color
+    public static boolean waitForColor(Component c,
+            Color expected) throws AWTException,
+            InterruptedException {
+        Dimension dim = c.getSize();
+        int xOff = dim.width / 2;
+        int yOff = dim.height / 2;
+        return waitForColor(c, xOff, yOff, expected);
+    }
+
+    // utility function that waits for 5 seconds for Component to be shown with
+    // the appropriate color
+    public static boolean waitForColor(Component c,
+            int xOff,
+            int yOff,
+            Color expected) throws AWTException, InterruptedException {
+        return waitForColor(c, xOff, yOff, expected, 5000L);
+    }
+
+    // utility function that waits until a Component is up with the appropriate
+    // color
+    public static boolean waitForColor(Component c,
+            int xOff,
+            int yOff,
+            Color expected,
+            long timeout) throws AWTException, InterruptedException {
+        Point p = c.getLocationOnScreen();
+        int x = (int) p.getX() + xOff;
+        int y = (int) p.getY() + yOff;
+        return waitForColor(x, y, expected, timeout);
+    }
+
+    // utility function that waits until specific screen coords have the
+    // appropriate color
+    public static boolean waitForColor(int locX,
+            int locY,
+            Color expected,
+            long timeout) throws AWTException, InterruptedException {
+        if (robot == null) {
+            robot = new Robot();
+        }
+
+        long endtime = System.currentTimeMillis() + timeout;
+        while (endtime > System.currentTimeMillis()) {
+            if (colorMatch(robot.getPixelColor(locX, locY), expected)) {
+                return true;
+            }
+            Thread.sleep(50);
+        }
+
+        return false;
+    }
+
+    // utility function that asserts that two colors are similar to each other
+    public static void assertColorEquals(final String message,
+            final Color actual,
+            final Color expected) {
+        System.out.println("actual color: " + actual);
+        System.out.println("expect color: " + expected);
+        //Assert.assertTrue(message, colorMatch(actual, expected));
+    }
+
+    // determines if two colors are close in hue and brightness
+    public static boolean colorMatch(final Color actual, final Color expected) {
+        final float[] actualHSB = getHSB(actual);
+        final float[] expectedHSB = getHSB(expected);
+
+        final float actualHue = actualHSB[0];
+        final float expectedHue = expectedHSB[0];
+        final boolean hueMatched = closeMatchHue(actualHue, expectedHue, 0.17f);
+        //System.out.println("hueMatched? " + hueMatched);
+        final float actualBrightness = actualHSB[2];
+        final float expectedBrightness = expectedHSB[2];
+        final boolean brightnessMatched = closeMatch(actualBrightness,
+                expectedBrightness, 0.15f);
+        //System.out.println("brightnessMatched? " + brightnessMatched);
+
+        // check to see if the brightness was so low or so high that the hue
+        // got clamped to red
+        if (brightnessMatched && !hueMatched) {
+            return (expectedBrightness < 0.15f);
+        }
+
+        return brightnessMatched && hueMatched;
+    }
+
+    static float[] getHSB(final Color color) {
+        final float[] hsb = new float[3];
+        Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);
+        return hsb;
+    }
+
+    // matches hues from 0.0 to 1.0, accounting for wrap-around at the 1.0/0.0
+    // boundry
+    static boolean closeMatchHue(final float actual,
+            final float expected,
+            final float tolerance) {
+        if (closeMatch(actual, expected, tolerance)) {
+            return true;
+        }
+
+        // all that remains is the overflow and underflow cases
+        final float expectedHigh = expected + tolerance;
+        final float expectedLow = expected - tolerance;
+
+        if (expectedHigh > 1.0f) {
+            // expected is too high, and actual was too low
+            //System.out.println("\thue expected too high, actual too low");
+            return closeMatch(actual + 0.5f, expected - 0.5f, tolerance);
+        }
+
+        if (expectedLow < 0.0f) {
+            // expected is too low, and actual was too high
+            //System.out.println("\thue expected too low, actual too high");
+            return closeMatch(actual - 0.5f, expected + 0.5f, tolerance);
+        }
+
+        //System.out.println("\tcloseMatchHue? " + false);
+        return false;
+    }
+
+    static boolean closeMatch(final float actual,
+            final float expected,
+            final float tolerance) {
+        return (expected + tolerance) > actual && (expected - tolerance) < actual;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/regtesthelpers/Waypoint.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 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.
+ *
+ * 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.
+ */
+
+ /*
+ * @summary This is a utility for coordinating the flow of events on different
+            threads.
+ * @summary com.apple.junit.utils
+ */
+package test.java.awt.regtesthelpers;
+
+public class Waypoint {
+
+    static final String MSG = "Waypoint timed out";
+    // Wait up to five seconds for our clear() to be called
+    static final int TIMEOUT = 5000;
+    boolean clear = false;
+
+    public Waypoint() {
+
+    }
+
+    //
+    //    Pause for either TIMEOUT millis or until clear() is called
+    //
+    synchronized public void requireClear() throws RuntimeException {
+        requireClear(MSG, TIMEOUT);
+    }
+
+    synchronized public void requireClear(long timeout)
+            throws RuntimeException {
+        requireClear(MSG, timeout);
+    }
+
+    synchronized public void requireClear(String timeOutMsg)
+            throws RuntimeException {
+        requireClear(timeOutMsg, TIMEOUT);
+    }
+
+    synchronized public void requireClear(String timeOutMsg, long timeout)
+            throws RuntimeException {
+        long endtime = System.currentTimeMillis() + timeout;
+        try {
+            while (isClear() == false) {
+                if (System.currentTimeMillis() < endtime) {
+                    wait(200);
+                } else {
+                    break;
+                }
+            }
+
+            if (!isClear()) {
+                throw new RuntimeException(timeOutMsg);
+            }
+        } catch (InterruptedException ix) {
+        }
+    }
+
+    //
+    //    Called when it is valid to procede past the waypoint
+    //
+    synchronized public void clear() {
+        clear = true;
+        notify();
+    }
+
+    //
+    //    Should be checked after a call to requireClear() to make
+    //    sure that we did not time out.
+    //
+    synchronized public boolean isClear() {
+        return clear;
+    }
+
+    synchronized public boolean isValid() {
+        return clear;
+    }
+
+    //
+    //    For re-use of a waypoint.  Be careful.
+    //
+    synchronized public void reset() {
+        clear = false;
+    }
+
+}
--- a/jdk/test/javax/imageio/plugins/png/ITXtTest.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/javax/imageio/plugins/png/ITXtTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, 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
@@ -21,16 +21,15 @@
  * questions.
  */
 
-/**
+/*
  * @test
- * @bug     6541476
- * @summary Test verifies that ImageIO PNG plugin correcly handles the
+ * @bug     6541476 7059970
+ * @summary Test verifies that ImageIO PNG plug-in correctly handles the
  *          iTxt chunk (International textual data).
  *
  * @run     main ITXtTest
  */
 
-
 import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.image.BufferedImage;
@@ -157,21 +156,22 @@
 
         File file = new File("test.png");
 
-        writeTo(file, src);
-        ITXtTest dst = readFrom(file);
-
-        if (dst == null || !dst.equals(src)) {
-            throw new RuntimeException("Test failed.");
+        try {
+            writeTo(file, src);
+            ITXtTest dst = readFrom(file);
+            if (dst == null || !dst.equals(src)) {
+                throw new RuntimeException("Test failed.");
+            }
+        } finally {
+            file.delete();
         }
-
         System.out.println("Test passed.");
     }
 
     private static void writeTo(File f, ITXtTest t) {
         BufferedImage src = createBufferedImage();
-        try {
-            ImageOutputStream imageOutputStream =
-                ImageIO.createImageOutputStream(f);
+        try (ImageOutputStream imageOutputStream =
+                ImageIO.createImageOutputStream(f)) {
 
             ImageTypeSpecifier imageTypeSpecifier =
                 new ImageTypeSpecifier(src);
@@ -191,7 +191,6 @@
             m.setFromTree(format, root);
 
             imageWriter.write(new IIOImage(src, null, m));
-            imageOutputStream.close();
             System.out.println("Writing done.");
         } catch (Throwable e) {
             throw new RuntimeException("Writing test failed.", e);
@@ -199,10 +198,11 @@
     }
 
     private static ITXtTest readFrom(File f) {
-        try {
-            ImageInputStream iis = ImageIO.createImageInputStream(f);
-            ImageReader r = ImageIO.getImageReaders(iis).next();
-            r.setInput(iis);
+        try (ImageInputStream imageInputStream =
+                ImageIO.createImageInputStream(f)) {
+
+            ImageReader r = ImageIO.getImageReaders(imageInputStream).next();
+            r.setInput(imageInputStream);
 
             IIOImage dst = r.readAll(0, null);
 
@@ -234,3 +234,4 @@
         return image;
     }
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2016, 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 5049012
+ * @summary Verify if PrintToFile option is disabled for flavors that do not
+ *          support Destination
+ * @requires (os.family == "linux")
+ * @run main/manual ServiceDialogValidateTest
+ */
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.io.File;
+import javax.print.DocFlavor;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.ServiceUI;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.standard.Destination;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+public class ServiceDialogValidateTest {
+    private static Thread mainThread;
+    private static boolean testPassed;
+    private static boolean testGeneratedInterrupt;
+
+    private static void printTest() {
+        PrintService defService = null, service[] = null;
+        HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
+        DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
+
+        service = PrintServiceLookup.lookupPrintServices(flavor, null);
+        defService = PrintServiceLookup.lookupDefaultPrintService();
+
+        if ((service == null) || (service.length == 0)) {
+            throw new RuntimeException("No Printer services found");
+        }
+        File f = new File("output.ps");
+        Destination d = new Destination(f.toURI());
+        prSet.add(d);
+        if (defService != null) {
+            System.out.println("isAttrCategory Supported? " +
+                    defService.isAttributeCategorySupported(Destination.class));
+            System.out.println("isAttrValue Supported? " +
+                    defService.isAttributeValueSupported(d, flavor, null));
+        }
+
+        defService = ServiceUI.printDialog(null, 100, 100, service, defService,
+                flavor, prSet);
+
+    }
+
+    /**
+     * Starts the application.
+     */
+    public static void main(java.lang.String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            doTest(ServiceDialogValidateTest::printTest);
+        });
+        mainThread = Thread.currentThread();
+        try {
+            Thread.sleep(60000);
+        } catch (InterruptedException e) {
+            if (!testPassed && testGeneratedInterrupt) {
+                throw new RuntimeException("PrintToFile option is not disabled "
+                        + "for flavors that do not support destination");
+            }
+        }
+        if (!testGeneratedInterrupt) {
+            throw new RuntimeException("user has not executed the test");
+        }
+    }
+
+    public static synchronized void pass() {
+        testPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public static synchronized void fail() {
+        testPassed = false;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    private static void doTest(Runnable action) {
+        String description
+                = " Visual inspection of print dialog is required.\n"
+                + " A print dialog will be shown.\n "
+                + " Please verify Print-To-File option is disabled.\n"
+                + " Press Cancel to close the print dialog.\n"
+                + " If Print-To-File option is disabled, press PASS else press FAIL";
+
+        final JDialog dialog = new JDialog();
+        dialog.setTitle("printSelectionTest");
+        JTextArea textArea = new JTextArea(description);
+        textArea.setEditable(false);
+        final JButton testButton = new JButton("Start Test");
+        final JButton passButton = new JButton("PASS");
+        passButton.setEnabled(false);
+        passButton.addActionListener((e) -> {
+            dialog.dispose();
+            pass();
+        });
+        final JButton failButton = new JButton("FAIL");
+        failButton.setEnabled(false);
+        failButton.addActionListener((e) -> {
+            dialog.dispose();
+            fail();
+        });
+        testButton.addActionListener((e) -> {
+            testButton.setEnabled(false);
+            action.run();
+            passButton.setEnabled(true);
+            failButton.setEnabled(true);
+        });
+        JPanel mainPanel = new JPanel(new BorderLayout());
+        mainPanel.add(textArea, BorderLayout.CENTER);
+        JPanel buttonPanel = new JPanel(new FlowLayout());
+        buttonPanel.add(testButton);
+        buttonPanel.add(passButton);
+        buttonPanel.add(failButton);
+        mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+        dialog.add(mainPanel);
+        dialog.pack();
+        dialog.setVisible(true);
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/attribute/ServiceDlgSheetCollateTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2016, 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 5080830
+ * @summary Verify if SheetCollate option is disabled for flavors that do not
+ *          support SheetCollate
+ * @run main/manual ServiceDlgSheetCollateTest
+ */
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import javax.print.DocFlavor;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.ServiceUI;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.standard.SheetCollate;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+public class ServiceDlgSheetCollateTest {
+    private static Thread mainThread;
+    private static boolean testPassed;
+    private static boolean testGeneratedInterrupt;
+
+    /**
+     * Starts the application.
+     */
+    public static void main(java.lang.String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            doTest(ServiceDlgSheetCollateTest::printTest);
+        });
+        mainThread = Thread.currentThread();
+        try {
+            Thread.sleep(600000);
+        } catch (InterruptedException e) {
+            if (!testPassed && testGeneratedInterrupt) {
+                throw new RuntimeException("SheetCollate option is not disabled "
+                        + "for flavors that do not support sheetCollate");
+            }
+        }
+        if (!testGeneratedInterrupt) {
+            throw new RuntimeException("user has not executed the test");
+        }
+    }
+
+    private static void printTest() {
+        ServiceDlgSheetCollateTest pd = new ServiceDlgSheetCollateTest();
+        DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
+        //DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
+        PrintService defService = null, service[] = null;
+        defService = PrintServiceLookup.lookupDefaultPrintService();
+        service = PrintServiceLookup.lookupPrintServices(flavor, null);
+
+        if ((service == null) || (service.length == 0)) {
+            throw new RuntimeException("No Printer services found");
+        }
+        if (defService != null) {
+            System.out.println("\nDefault print service: " + service );
+            System.out.println("is flavor: "+flavor+" supported? "+
+                            defService.isDocFlavorSupported(flavor));
+            System.out.println("is SheetCollate category supported? "+
+                  defService.isAttributeCategorySupported(SheetCollate.class));
+            System.out.println("is SheetCollate.COLLATED value supported ? "+
+                  defService.isAttributeValueSupported(SheetCollate.COLLATED,
+                                                            flavor, null));
+        }
+        HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
+        try {
+            PrintService selService = ServiceUI.printDialog(null, 200, 200, service, defService, flavor, prSet);
+        } catch (IllegalArgumentException ia) {
+            System.out.println("Exception thrown : " + ia);
+        }
+
+        System.out.println("\nSelected Values\n");
+        Attribute attr[] = prSet.toArray();
+        for (int x = 0; x < attr.length; x ++) {
+            System.out.println("Attribute: " + attr[x].getName() + " Value: " + attr[x]);
+        }
+
+    }
+
+    public static synchronized void pass() {
+        testPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public static synchronized void fail() {
+        testPassed = false;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    private static void doTest(Runnable action) {
+        String description
+                = " A print dialog would appear.\n"
+                + " Increase the no. of copies.\n"
+                + " If COLLATE checkbox gets enabled, press FAIL else press PASS.\n"
+                + " Press Cancel to close the dialog.";
+
+        final JDialog dialog = new JDialog();
+        dialog.setTitle("printSelectionTest");
+        JTextArea textArea = new JTextArea(description);
+        textArea.setEditable(false);
+        final JButton testButton = new JButton("Start Test");
+        final JButton passButton = new JButton("PASS");
+        passButton.setEnabled(false);
+        passButton.addActionListener((e) -> {
+            dialog.dispose();
+            pass();
+        });
+        final JButton failButton = new JButton("FAIL");
+        failButton.setEnabled(false);
+        failButton.addActionListener((e) -> {
+            dialog.dispose();
+            fail();
+        });
+        testButton.addActionListener((e) -> {
+            testButton.setEnabled(false);
+            action.run();
+            passButton.setEnabled(true);
+            failButton.setEnabled(true);
+        });
+        JPanel mainPanel = new JPanel(new BorderLayout());
+        mainPanel.add(textArea, BorderLayout.CENTER);
+        JPanel buttonPanel = new JPanel(new FlowLayout());
+        buttonPanel.add(testButton);
+        buttonPanel.add(passButton);
+        buttonPanel.add(failButton);
+        mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+        dialog.add(mainPanel);
+        dialog.pack();
+        dialog.setVisible(true);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JComboBox/6567433/UpdateUIRecursionTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2016, 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 6567433
+ *
+ * @summary  JComboBox.updateUI() invokes updateUI() on its cellrenderer via
+ * SwingUtilities.updateComponentTreeUI().
+ * If the cellrenderer is a parent of this JComboBox the method recurses
+ * endless.
+ * This test tests that the fix is effective in avoiding recursion.
+ *
+ * @run main/othervm UpdateUIRecursionTest
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.ListCellRenderer;
+import javax.swing.SwingUtilities;
+
+public class UpdateUIRecursionTest extends JFrame implements ListCellRenderer {
+    JComboBox combo;
+    DefaultListCellRenderer renderer;
+
+    public UpdateUIRecursionTest() {
+        super("UpdateUIRecursionTest");
+        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        setSize(400, 400);
+
+        String[] listData = {
+            "First", "Second", "Third", "Fourth", "Fifth", "Sixth"
+        };
+
+        combo = new JComboBox(listData);
+        combo.setRenderer(this);
+        renderer = new DefaultListCellRenderer();
+        getContentPane().add(new JScrollPane(combo), BorderLayout.CENTER);
+
+        setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                UpdateUIRecursionTest obj = new UpdateUIRecursionTest();
+
+                obj.test();
+
+                obj.disposeUI();
+            }
+        });
+    }
+
+    public void test() {
+        combo.updateUI();
+    }
+
+    public void disposeUI() {
+        setVisible(false);
+        dispose();
+    }
+
+    public Component getListCellRendererComponent(JList list, Object value,
+            int index, boolean isSelected, boolean cellHasFocus)
+    {
+        return renderer.getListCellRendererComponent(list, value, index,
+                                                     isSelected, cellHasFocus);
+    }
+}
+
--- a/jdk/test/javax/swing/JFileChooser/7199708/bug7199708.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/javax/swing/JFileChooser/7199708/bug7199708.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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,7 +40,7 @@
 
 /**
  * @test
- * @bug 7199708
+ * @bug 7199708 8159587
  * @author Alexander Scherbatiy
  * @summary FileChooser crashs when opening large folder
  * @run main bug7199708
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JList/6567433/UpdateUIRecursionTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2016, 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 6567433
+ *
+ * @summary  JList.updateUI() for invokes updateUI() on its cellrenderer via
+ * SwingUtilities.updateComponentTreeUI().
+ * If the cellrenderer is a parent of this JList the method recurses
+ * endless.
+ * This test tests that the fix is effective in avoiding recursion.
+ *
+ * @run main/othervm UpdateUIRecursionTest
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.ListCellRenderer;
+import javax.swing.SwingUtilities;
+
+public class UpdateUIRecursionTest extends JFrame implements ListCellRenderer {
+    JList list;
+    DefaultListCellRenderer renderer;
+
+    public UpdateUIRecursionTest() {
+        super("UpdateUIRecursionTest");
+        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        setSize(400, 400);
+
+        String[] listData = {
+            "First", "Second", "Third", "Fourth", "Fifth", "Sixth"
+        };
+
+        list = new JList(listData);
+        list.setCellRenderer(this);
+        renderer = new DefaultListCellRenderer();
+        getContentPane().add(new JScrollPane(list), BorderLayout.CENTER);
+
+        setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                UpdateUIRecursionTest obj = new UpdateUIRecursionTest();
+
+                obj.test();
+
+                obj.disposeUI();
+            }
+        });
+    }
+
+    public void test() {
+        list.updateUI();
+    }
+
+    public void disposeUI() {
+        setVisible(false);
+        dispose();
+    }
+
+    public Component getListCellRendererComponent(JList list, Object value,
+            int index, boolean isSelected, boolean cellHasFocus)
+    {
+        return renderer.getListCellRendererComponent(list, value, index,
+                                                     isSelected, cellHasFocus);
+    }
+}
+
--- a/jdk/test/javax/swing/JMenuItem/8031573/bug8031573.java	Tue Jul 26 12:56:26 2016 -0700
+++ b/jdk/test/javax/swing/JMenuItem/8031573/bug8031573.java	Tue Jul 26 14:45:11 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -26,9 +26,10 @@
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
 
 /* @test
- * @bug 8031573 8040279
+ * @bug 8031573 8040279 8143064
  * @summary [macosx] Checkmarks of JCheckBoxMenuItems aren't rendered
  *           in high resolution on Retina
  * @author Alexander Scherbatiy
@@ -39,6 +40,9 @@
     @Override
     public void init() {
         try {
+
+            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+
             SwingUtilities.invokeAndWait(new Runnable() {
 
                 @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTable/6567433/UpdateUIRecursionTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2016, 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 6567433
+ *
+ * @summary  JTable.updateUI() invokes updateUI() on its TableCellrenderer via
+ * SwingUtilities.updateRendererOrEditorUI().
+ * If the TableCellrenderer is a parent of this JTable the method recurses
+ * endless.
+ * This test tests that the fix is effective in avoiding recursion.
+ *
+ * @run main/othervm UpdateUIRecursionTest
+ */
+
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellRenderer;
+
+public class UpdateUIRecursionTest extends JFrame implements TableCellRenderer {
+    JTable table;
+    DefaultTableCellRenderer renderer;
+
+    public UpdateUIRecursionTest() {
+        super("UpdateUIRecursionTest");
+        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        setSize(400, 400);
+
+        String[] columnNames = {
+                "First Name",
+                "Last Name",
+                "Sport",
+                "# of Years",
+                "Vegetarian"};
+
+                Object[][] data = {
+                    {"Mary", "Campione",
+                    "Snowboarding", new Integer(5), new Boolean(false)},
+                    {"Alison", "Huml",
+                    "Rowing", new Integer(3), new Boolean(true)},
+                    {"Kathy", "Walrath",
+                    "Knitting", new Integer(2), new Boolean(false)},
+                    {"Sharon", "Zakhour",
+                    "Speed reading", new Integer(20), new Boolean(true)},
+                    {"Philip", "Milne",
+                    "Pool", new Integer(10), new Boolean(false)}
+                };
+
+
+        table = new JTable(data, columnNames);
+
+        renderer = new DefaultTableCellRenderer();
+        getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
+        table.setDefaultRenderer(table.getColumnClass(1), this);
+
+        setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                UpdateUIRecursionTest obj = new UpdateUIRecursionTest();
+
+                obj.test();
+
+                obj.disposeUI();
+            }
+        });
+    }
+
+    public void test() {
+        table.updateUI();
+    }
+
+    public void disposeUI() {
+        setVisible(false);
+        dispose();
+    }
+
+    @Override
+    public Component getTableCellRendererComponent(JTable table, Object value,
+                                         boolean isSelected, boolean hasFocus,
+                                         int row, int column)
+    {
+         return renderer.getTableCellRendererComponent(table, value, isSelected,
+                                                       hasFocus, row, column);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTableHeader/6567433/UpdateUIRecursionTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016, 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 6567433
+ *
+ * @summary  JTableHeader.updateUI() invokes updateUI() on its TableCellrenderer via
+ * SwingUtilities.updateComponentTreeUI().
+ * If the Tablecellrenderer is a parent of this JTableHeader, the method recurses
+ * endless.
+ * This test tests that the fix is effective in avoiding recursion.
+ *
+ * @run main/othervm UpdateUIRecursionTest
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
+import javax.swing.table.JTableHeader;
+import javax.swing.table.TableCellRenderer;
+
+public class UpdateUIRecursionTest extends JFrame implements TableCellRenderer {
+    JTable table;
+
+    public UpdateUIRecursionTest() {
+        super("UpdateUIRecursionTest");
+        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        setSize(400, 400);
+
+         String[] columnNames = {
+                "First Name",
+                "Last Name",
+                "Sport",
+                "# of Years",
+                "Vegetarian"};
+
+                Object[][] data = {
+                    {"Mary", "Campione",
+                    "Snowboarding", new Integer(5), new Boolean(false)},
+                    {"Alison", "Huml",
+                    "Rowing", new Integer(3), new Boolean(true)},
+                    {"Kathy", "Walrath",
+                    "Knitting", new Integer(2), new Boolean(false)},
+                    {"Sharon", "Zakhour",
+                    "Speed reading", new Integer(20), new Boolean(true)},
+                    {"Philip", "Milne",
+                    "Pool", new Integer(10), new Boolean(false)}
+                };
+
+        JTableHeader tableHeader =  new JTableHeader();
+        table = new JTable(data, columnNames);
+        table.setTableHeader(tableHeader);
+        tableHeader.setDefaultRenderer(this);
+
+        getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
+
+        setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                UpdateUIRecursionTest obj = new UpdateUIRecursionTest();
+
+                obj.test();
+
+                obj.disposeUI();
+            }
+        });
+    }
+
+    public void test() {
+        SwingUtilities.updateComponentTreeUI(this);
+    }
+
+    public void disposeUI() {
+        setVisible(false);
+        dispose();
+    }
+
+    public Component getTableCellRendererComponent(JTable table, Object value,
+        boolean isSelected, boolean hasFocus, int row, int col) {
+        return new JLabel(String.valueOf(value));
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/6567433/UpdateUIRecursionTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2016, 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 6567433
+ *
+ * @summary  JTree.updateUI() invokes updateUI() on its TreeCellrenderer via
+ * SwingUtilities.updateRendererOrEditorUI().
+ * If the TreeCellrenderer is a parent of this JTree, the method recurses
+ * endless.
+ * This test tests that the fix is effective in avoiding recursion.
+ *
+ * @run main/othervm UpdateUIRecursionTest
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.tree.TreeCellRenderer;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+public class UpdateUIRecursionTest extends JFrame implements TreeCellRenderer {
+    JTree tree;
+    DefaultTreeCellRenderer renderer;
+
+    public UpdateUIRecursionTest() {
+        super("UpdateUIRecursionTest");
+        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        setSize(400, 400);
+
+        String[] listData = {
+            "First", "Second", "Third", "Fourth", "Fifth", "Sixth"
+        };
+
+        tree = new JTree(listData);
+        renderer = new DefaultTreeCellRenderer();
+        getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
+        tree.setCellRenderer(this);
+
+        setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                UpdateUIRecursionTest obj = new UpdateUIRecursionTest();
+
+                obj.test();
+
+                obj.disposeUI();
+            }
+        });
+    }
+
+    public void test() {
+        tree.updateUI();
+    }
+
+    public void disposeUI() {
+        setVisible(false);
+        dispose();
+    }
+
+    @Override
+    public Component getTreeCellRendererComponent(JTree tree, Object value,
+                              boolean selected, boolean expanded, boolean leaf,
+                              int row, boolean hasFocus)
+    {
+        return renderer.getTreeCellRendererComponent(tree, value, leaf,
+                                                expanded, leaf, row, hasFocus);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/awt/image/OffScreenImageSource/ImageConsumerUnregisterTest.java	Tue Jul 26 14:45:11 2016 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016, 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 8160421
+ * @summary Test to check OffScreenImageSource handles case where
+ *          imageComplete(ImageConsumer.SINGLEFRAMEDONE) unregisters.
+ * @run main/othervm ImageConsumerUnregisterTest
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+public class ImageConsumerUnregisterTest extends javax.swing.JFrame {
+
+    public static void main(String[] args) throws Exception {
+
+        final java.awt.Component component = new TestBug8160421();
+
+        // Redirect the System.err stream and verify there is no
+        // stacktrace printed
+        ByteArrayOutputStream rs = new ByteArrayOutputStream();
+        PrintStream obj = System.err;
+        System.setErr(new PrintStream(rs));
+
+        String str = "";
+
+        try {
+            // Test call
+            component.getToolkit().createCustomCursor(
+                    component.getGraphicsConfiguration().createCompatibleImage(
+                            16, 16, java.awt.Transparency.BITMASK),
+                            new java.awt.Point(0, 0), "Hidden");
+
+            // Convert the redirected System.err contents to a string
+            str = rs.toString();
+        } finally {
+            // Reset System.err
+            System.setErr(obj);
+
+            if (!str.isEmpty()) {
+                throw new RuntimeException("Invalid imageComplete(STATICIMAGEDONE) call");
+            }
+        }
+    }
+}
+