Merge
authorprr
Mon, 25 Apr 2016 09:25:26 -0700
changeset 37713 a3c34538726f
parent 37712 a34269e72fe1 (diff)
parent 37646 84aba7335005 (current diff)
child 37714 7a0b1c7e7054
Merge
hotspot/src/share/vm/utilities/top.hpp
hotspot/test/stress/gc/TestGCOld.java
hotspot/test/stress/gc/TestMultiThreadStressRSet.java
hotspot/test/stress/gc/TestStressIHOPMultiThread.java
hotspot/test/stress/gc/TestStressRSetCoarsening.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/ExtractedImage.java
jdk/src/jdk.unsupported/share/classes/sun/misc/ManagedLocalsThread.java
langtools/test/tools/javac/SerialWarn.java
langtools/test/tools/javac/SerialWarn.out
langtools/test/tools/javac/positions/T6253161.java
langtools/test/tools/javac/positions/T6253161.out
langtools/test/tools/javac/positions/T6253161a.java
langtools/test/tools/javac/positions/T6253161a.out
--- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers	Mon Apr 25 09:25:26 2016 -0700
@@ -179,6 +179,7 @@
         Java_sun_awt_UNIXToolkit_load_1gtk_1icon;
         Java_sun_awt_UNIXToolkit_nativeSync;
         Java_sun_awt_UNIXToolkit_gtkCheckVersionImpl;
+        Java_sun_awt_UNIXToolkit_get_1gtk_1version;
         Java_java_awt_AWTEvent_initIDs;
         Java_java_awt_event_InputEvent_initIDs;
         Java_java_awt_event_KeyEvent_initIDs;
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, 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
@@ -903,7 +903,7 @@
     @Override
     public boolean requestFocus(Component lightweightChild, boolean temporary,
                                 boolean focusedWindowChangeAllowed, long time,
-                                CausedFocusEvent.Cause cause)
+                                FocusEvent.Cause cause)
     {
         if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
             focusLog.finest("lightweightChild=" + lightweightChild + ", temporary=" + temporary +
@@ -1278,7 +1278,7 @@
         assert (e.getSource() == target);
 
         if (!target.isFocusOwner() && LWKeyboardFocusManagerPeer.shouldFocusOnClick(target)) {
-            LWKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
+            LWKeyboardFocusManagerPeer.requestFocusFor(target, FocusEvent.Cause.MOUSE_EVENT);
         }
     }
 
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java	Mon Apr 25 09:25:26 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
@@ -31,8 +31,8 @@
 import java.awt.Rectangle;
 import java.awt.Window;
 import java.awt.dnd.DropTarget;
+import java.awt.event.FocusEvent;
 
-import sun.awt.CausedFocusEvent;
 import sun.awt.LightweightFrame;
 import sun.swing.JLightweightFrame;
 import sun.swing.SwingAccessor;
@@ -60,7 +60,7 @@
     }
 
     @Override
-    public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
+    public boolean requestWindowFocus(FocusEvent.Cause cause) {
         if (!focusAllowedFor()) {
             return false;
         }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java	Mon Apr 25 09:25:26 2016 -0700
@@ -404,6 +404,10 @@
     public final PrintJob getPrintJob(Frame frame, String doctitle,
                                       JobAttributes jobAttributes,
                                       PageAttributes pageAttributes) {
+        if (frame == null) {
+            throw new NullPointerException("frame must not be null");
+        }
+
         if (GraphicsEnvironment.isHeadless()) {
             throw new IllegalArgumentException();
         }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java	Mon Apr 25 09:25:26 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
@@ -256,14 +256,14 @@
                 if (!getTarget().isAutoRequestFocus()) {
                     return;
                 } else {
-                    requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
+                    requestWindowFocus(FocusEvent.Cause.ACTIVATION);
                 }
             // Focus the owner in case this window is focused.
             } else if (kfmPeer.getCurrentFocusedWindow() == getTarget()) {
                 // Transfer focus to the owner.
                 LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this);
                 if (owner != null) {
-                    owner.requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
+                    owner.requestWindowFocus(FocusEvent.Cause.ACTIVATION);
                 }
             }
         }
@@ -295,7 +295,7 @@
         if (f == null) {
             f = DEFAULT_FONT;
         }
-        return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f));
+        return new SunGraphics2D(getSurfaceData(), fg, bg, f);
     }
 
     @Override
@@ -848,7 +848,7 @@
                 // 2. An active but not focused owner frame/dialog is clicked.
                 // The mouse event then will trigger a focus request "in window" to the component, so the window
                 // should gain focus before.
-                requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
+                requestWindowFocus(FocusEvent.Cause.MOUSE_EVENT);
 
                 mouseDownTarget[targetIdx] = targetPeer;
             } else if (id == MouseEvent.MOUSE_DRAGGED) {
@@ -1199,7 +1199,7 @@
      * Requests platform to set native focus on a frame/dialog.
      * In case of a simple window, triggers appropriate java focus change.
      */
-    public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
+    public boolean requestWindowFocus(FocusEvent.Cause cause) {
         if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
             focusLog.fine("requesting native focus to " + this);
         }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java	Mon Apr 25 09:25:26 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
@@ -26,8 +26,8 @@
 package sun.lwawt;
 
 import java.awt.*;
+import java.awt.event.FocusEvent;
 
-import sun.awt.CausedFocusEvent;
 import sun.java2d.SurfaceData;
 
 // TODO Is it worth to generify this interface, like that:
@@ -114,7 +114,7 @@
 
     public void updateFocusableWindowState();
 
-    public boolean rejectFocusRequest(CausedFocusEvent.Cause cause);
+    public boolean rejectFocusRequest(FocusEvent.Cause cause);
 
     public boolean requestWindowFocus();
 
@@ -130,12 +130,6 @@
      */
     public void setSizeConstraints(int minW, int minH, int maxW, int maxH);
 
-    /**
-     * Transforms the given Graphics object according to the native
-     * implementation traits (insets, etc.).
-     */
-    public Graphics transformGraphics(Graphics g);
-
     /*
      * Installs the images for particular window.
      */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,253 @@
+/*
+ * 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/CAccessible.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java	Mon Apr 25 09:25:26 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
@@ -26,20 +26,18 @@
 package sun.lwawt.macosx;
 
 import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 import java.lang.reflect.Field;
 
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.swing.JProgressBar;
 import javax.swing.JSlider;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.text.JTextComponent;
 
+import sun.lwawt.macosx.CFRetainedResource;
 
 class CAccessible extends CFRetainedResource implements Accessible {
     static Field getNativeAXResourceField() {
@@ -99,13 +97,10 @@
         return accessible.getAccessibleContext();
     }
 
-    // currently only supports text components
     public void addNotificationListeners(Component c) {
-        if (c instanceof JTextComponent) {
-            JTextComponent tc = (JTextComponent) c;
-            AXTextChangeNotifier listener = new AXTextChangeNotifier();
-            tc.getDocument().addDocumentListener(listener);
-            tc.addCaretListener(listener);
+        AXTextChangeNotifier listener = new AXTextChangeNotifier();
+        if (c instanceof Accessible) {
+            AccessibilityEventMonitor.addPropertyChangeListener(listener, (Accessible)c);
         }
         if (c instanceof JProgressBar) {
             JProgressBar pb = (JProgressBar) c;
@@ -117,29 +112,23 @@
     }
 
 
-    private class AXTextChangeNotifier implements DocumentListener, CaretListener {
-        @Override
-        public void changedUpdate(DocumentEvent e) {
-            if (ptr != 0) valueChanged(ptr);
-        }
+    private class AXTextChangeNotifier implements PropertyChangeListener {
 
         @Override
-        public void insertUpdate(DocumentEvent e) {
-            if (ptr != 0) valueChanged(ptr);
-        }
-
-        @Override
-        public void removeUpdate(DocumentEvent e) {
-            if (ptr != 0) valueChanged(ptr);
-        }
-
-        @Override
-        public void caretUpdate(CaretEvent e) {
-            if (ptr != 0) selectionChanged(ptr);
+        public void propertyChange(PropertyChangeEvent e) {
+            String name = e.getPropertyName();
+            if ( ptr != 0 ) {
+                if (name.compareTo(AccessibleContext.ACCESSIBLE_CARET_PROPERTY) == 0) {
+                    selectionChanged(ptr);
+                } else if (name.compareTo(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY) == 0 ) {
+                    valueChanged(ptr);
+                }
+            }
         }
     }
 
     private class AXProgressChangeNotifier implements ChangeListener {
+        @Override
         public void stateChanged(ChangeEvent e) {
             if (ptr != 0) valueChanged(ptr);
         }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java	Mon Apr 25 09:25:26 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
@@ -26,6 +26,7 @@
 package sun.lwawt.macosx;
 
 import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
 import java.awt.peer.*;
 import java.awt.BufferCapabilities.FlipContents;
 import java.awt.event.*;
@@ -34,7 +35,6 @@
 import java.util.List;
 import java.io.*;
 
-import sun.awt.CausedFocusEvent.Cause;
 import sun.awt.AWTAccessor;
 import sun.java2d.pipe.Region;
 import sun.security.action.GetBooleanAction;
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Mon Apr 25 09:25:26 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
@@ -26,11 +26,11 @@
 package sun.lwawt.macosx;
 
 import java.awt.*;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent;
+
 import sun.java2d.SurfaceData;
 import sun.java2d.opengl.CGLLayer;
 import sun.lwawt.LWWindowPeer;
-import sun.lwawt.LWWindowPeer.PeerType;
 import sun.lwawt.PlatformWindow;
 import sun.util.logging.PlatformLogger;
 
@@ -39,7 +39,8 @@
  */
 public class CPlatformEmbeddedFrame implements PlatformWindow {
 
-    private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformEmbeddedFrame");
+    private static final PlatformLogger focusLogger = PlatformLogger.getLogger(
+            "sun.lwawt.macosx.focus.CPlatformEmbeddedFrame");
 
     private CGLLayer windowLayer;
     private LWWindowPeer peer;
@@ -133,9 +134,9 @@
     public void updateFocusableWindowState() {}
 
     @Override
-    public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+    public boolean rejectFocusRequest(FocusEvent.Cause cause) {
         // Cross-app activation requests are not allowed.
-        if (cause != CausedFocusEvent.Cause.MOUSE_EVENT &&
+        if (cause != FocusEvent.Cause.MOUSE_EVENT &&
             !target.isParentWindowActive())
         {
             focusLogger.fine("the embedder is inactive, so the request is rejected");
@@ -161,11 +162,6 @@
     public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {}
 
     @Override
-    public Graphics transformGraphics(Graphics g) {
-        return g;
-    }
-
-    @Override
     public void updateIconImages() {}
 
     @Override
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, 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
@@ -27,7 +27,6 @@
 
 import java.awt.Font;
 import java.awt.FontMetrics;
-import java.awt.Graphics;
 import java.awt.GraphicsDevice;
 import java.awt.GraphicsEnvironment;
 import java.awt.Insets;
@@ -37,7 +36,7 @@
 import java.awt.Window;
 import sun.awt.CGraphicsDevice;
 import sun.awt.CGraphicsEnvironment;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent;
 import sun.awt.LightweightFrame;
 import sun.java2d.SurfaceData;
 import sun.lwawt.LWLightweightFramePeer;
@@ -134,7 +133,7 @@
     }
 
     @Override
-    public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+    public boolean rejectFocusRequest(FocusEvent.Cause cause) {
         return false;
     }
 
@@ -153,11 +152,6 @@
     }
 
     @Override
-    public Graphics transformGraphics(Graphics g) {
-        return null;
-    }
-
-    @Override
     public void setAlwaysOnTop(boolean isAlwaysOnTop) {
     }
 
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Mon Apr 25 09:25:26 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
@@ -706,9 +706,9 @@
     }
 
     @Override
-    public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+    public boolean rejectFocusRequest(FocusEvent.Cause cause) {
         // Cross-app activation requests are not allowed.
-        if (cause != CausedFocusEvent.Cause.MOUSE_EVENT &&
+        if (cause != FocusEvent.Cause.MOUSE_EVENT &&
             !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
         {
             focusLogger.fine("the app is inactive, so the request is rejected");
@@ -741,12 +741,6 @@
     }
 
     @Override
-    public Graphics transformGraphics(Graphics g) {
-        // is this where we can inject a transform for HiDPI?
-        return g;
-    }
-
-    @Override
     public void setAlwaysOnTop(boolean isAlwaysOnTop) {
         setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
     }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Mon Apr 25 09:25:26 2016 -0700
@@ -98,15 +98,26 @@
     private native long nativeCreate();
 
     //invocation from the AWTTrayIcon.m
-    public long getPopupMenuModel(){
-        if(popup == null) {
-            PopupMenu popupMenu = target.getPopupMenu();
-            if (popupMenu != null) {
-                popup = popupMenu;
+    public long getPopupMenuModel() {
+        PopupMenu newPopup = target.getPopupMenu();
+
+        if (popup == newPopup) {
+            if (popup == null) {
+                return 0L;
+            }
+        } else {
+            if (newPopup != null) {
+                if (popup != null) {
+                    popup.removeNotify();
+                    popup = newPopup;
+                } else {
+                    popup = newPopup;
+                }
             } else {
                 return 0L;
             }
         }
+
         return checkAndCreatePopupPeer().getModel();
     }
 
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java	Mon Apr 25 09:25:26 2016 -0700
@@ -87,23 +87,22 @@
         }
     }
 
-    /*
+    /**
      * Initializes the embedded frame bounds and validates a component.
-     * Designed to be called from the main thread
-     * This method should be called once from the initialization of the SWT_AWT Bridge
+     * Designed to be called from the main thread. This method should be called
+     * once from the initialization of the SWT_AWT Bridge.
      */
-    public void validateWithBounds(final int x, final int y, final int width, final int height) {
+    public void validateWithBounds(final int x, final int y, final int width,
+                                   final int height) {
         try {
-            final LWWindowPeer peer = AWTAccessor.getComponentAccessor()
-                                                 .getPeer(this);
-            LWCToolkit.invokeAndWait(new Runnable() {
-                @Override
-                public void run() {
-                    peer.setBoundsPrivate(0, 0, width, height);
-                    validate();
-                    setVisible(true);
-                }
+            LWCToolkit.invokeAndWait(() -> {
+                final LWWindowPeer peer = AWTAccessor.getComponentAccessor()
+                                                     .getPeer(this);
+                peer.setBoundsPrivate(0, 0, width, height);
+                validate();
+                setVisible(true);
             }, this);
-        } catch (InvocationTargetException ex) {}
+        } catch (InvocationTargetException ex) {
+        }
     }
 }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -27,13 +27,12 @@
 
 import java.awt.Font;
 import java.awt.FontMetrics;
-import java.awt.Graphics;
 import java.awt.GraphicsDevice;
 import java.awt.Insets;
 import java.awt.MenuBar;
 import java.awt.Point;
 import java.awt.Window;
-import sun.awt.CausedFocusEvent.Cause;
+import java.awt.event.FocusEvent.Cause;
 import sun.java2d.SurfaceData;
 import sun.lwawt.LWWindowPeer;
 import sun.lwawt.PlatformWindow;
@@ -171,11 +170,6 @@
     }
 
     @Override
-    public Graphics transformGraphics(Graphics g) {
-        return g;
-    }
-
-    @Override
     public void updateIconImages() {
     }
 
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, 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
@@ -364,8 +364,8 @@
             return null;
         }
 
-        return transformGraphics(new SunGraphics2D(sd, SystemColor.windowText,
-                SystemColor.window, ownerWindow.getFont()));
+        return new SunGraphics2D(sd, SystemColor.windowText, SystemColor.window,
+                                 ownerWindow.getFont());
     }
 
 
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -158,8 +158,8 @@
             int widgetType, int state, int shadowType, String detail,
             int x, int y, int width, int height, int synthState, int dir);
     private native void native_paint_slider(
-            int widgetType, int state, int shadowType, String detail,
-            int x, int y, int width, int height, int orientation);
+            int widgetType, int state, int shadowType, String detail, int x,
+            int y, int width, int height, int orientation, boolean hasFocus);
     private native void native_paint_vline(
             int widgetType, int state, String detail,
             int x, int y, int width, int height);
@@ -491,6 +491,14 @@
         int gtkState =
             GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
         int synthState = context.getComponentState();
+        Container parent = context.getComponent().getParent();
+        if(GTKLookAndFeel.is3()) {
+            if (parent != null && parent.getParent() instanceof JComboBox) {
+                if (parent.getParent().hasFocus()) {
+                    synthState |= SynthConstants.FOCUSED;
+                }
+            }
+        }
         int dir = getTextDirection(context);
         int widget = getWidgetType(context.getComponent(), id).ordinal();
         native_paint_shadow(widget, gtkState, shadowType.ordinal(), detail,
@@ -498,13 +506,13 @@
     }
 
     public void paintSlider(Graphics g, SynthContext context,
-            Region id, int state, ShadowType shadowType, String detail,
-            int x, int y, int w, int h, Orientation orientation) {
+            Region id, int state, ShadowType shadowType, String detail, int x,
+            int y, int w, int h, Orientation orientation, boolean hasFocus) {
 
         state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
         int widget = getWidgetType(context.getComponent(), id).ordinal();
         native_paint_slider(widget, state, shadowType.ordinal(), detail,
-                            x - x0, y - y0, w, h, orientation.ordinal());
+                         x - x0, y - y0, w, h, orientation.ordinal(), hasFocus);
     }
 
     public void paintVline(Graphics g, SynthContext context,
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, 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
@@ -54,7 +54,8 @@
  */
 @SuppressWarnings("serial") // Superclass not serializable
 public class GTKLookAndFeel extends SynthLookAndFeel {
-    private static final boolean IS_22;
+    private static boolean IS_22;
+    private static boolean IS_3;
 
     /**
      * Whether or not text is drawn antialiased.  This keys off the
@@ -107,17 +108,6 @@
     private static String gtkThemeName = "Default";
 
     static {
-        // Backup for specifying the version, this isn't currently documented.
-        // If you pass in anything but 2.2 you got the 2.0 colors/look.
-        String version = AccessController.doPrivileged(
-               new GetPropertyAction("swing.gtk.version"));
-        if (version != null) {
-            IS_22 = version.equals("2.2");
-        }
-        else {
-            IS_22 = true;
-        }
-
         String language = Locale.getDefault().getLanguage();
         boolean cjkLocale =
             (Locale.CHINESE.getLanguage().equals(language) ||
@@ -158,6 +148,10 @@
         return IS_22;
     }
 
+    static boolean is3() {
+        return IS_3;
+    }
+
     /**
      * Maps a swing constant to a GTK constant.
      */
@@ -1460,6 +1454,19 @@
             throw new InternalError("Unable to load native GTK libraries");
         }
 
+        if (UNIXToolkit.getGtkVersion() == UNIXToolkit.GtkVersions.GTK2) {
+            String version = AccessController.doPrivileged(
+                    new GetPropertyAction("jdk.gtk.version"));
+            if (version != null) {
+                IS_22 = version.equals("2.2");
+            } else {
+                IS_22 = true;
+            }
+        } else if (UNIXToolkit.getGtkVersion() ==
+                                UNIXToolkit.GtkVersions.GTK3) {
+            IS_3 = true;
+        }
+
         super.initialize();
         inInitialize = true;
         loadStyles();
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Mon Apr 25 09:25:26 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
@@ -576,12 +576,11 @@
                     ShadowType.OUT, "menu", x, y, w, h);
 
             GTKStyle style = (GTKStyle)context.getStyle();
-            int xThickness = style.getXThickness();
-            int yThickness = style.getYThickness();
+            Insets insets = style.getInsets(context, null);
             ENGINE.paintBackground(g, context, id, gtkState,
-                    style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
-                    x + xThickness, y + yThickness,
-                    w - xThickness - xThickness, h - yThickness - yThickness);
+                style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
+                x + insets.left, y + insets.top, w - insets.left - insets.right,
+                h - insets.top - insets.bottom);
             ENGINE.finishPainting();
         }
     }
@@ -640,6 +639,34 @@
         int state = context.getComponentState();
         JComponent c = context.getComponent();
 
+        GTKStyle style = (GTKStyle) context.getStyle();
+        String detail;
+        // wide-separators are painted using box not line
+        if (style.getClassSpecificBoolValue(context,
+                                          "wide-separators", false)) {
+            Insets insets = c.getInsets();
+            x += insets.left;
+            y += insets.top;
+            if (orientation == JSeparator.HORIZONTAL) {
+                w -= (insets.left + insets.right);
+                detail = "hseparator";
+            } else {
+                h -= (insets.top + insets.bottom);
+                detail = "vseparator";
+            }
+            synchronized (UNIXToolkit.GTK_LOCK) {
+                if (! ENGINE.paintCachedImage(g, x, y, w, h, id, state,
+                            detail, orientation)) {
+                    ENGINE.startPainting(g, x, y, w, h, id, state,
+                            detail, orientation);
+                    ENGINE.paintBox(g, context, id, state,
+                            ShadowType.ETCHED_OUT, detail, x, y, w, h);
+                    ENGINE.finishPainting();
+                }
+            }
+            return;
+        }
+
         /*
          * Note: In theory, the style's x/y thickness values would determine
          * the width of the separator content.  In practice, however, some
@@ -650,7 +677,6 @@
          * the w/h values below too much, so that the full thickness of the
          * rendered line will be captured by our image caching code.
          */
-        String detail;
         if (c instanceof JToolBar.Separator) {
             /*
              * GTK renders toolbar separators differently in that an
@@ -678,7 +704,6 @@
             float pct = 0.2f;
             JToolBar.Separator sep = (JToolBar.Separator)c;
             Dimension size = sep.getSeparatorSize();
-            GTKStyle style = (GTKStyle)context.getStyle();
             if (orientation == JSeparator.HORIZONTAL) {
                 x += (int)(w * pct);
                 w -= (int)(w * pct * 2);
@@ -743,6 +768,15 @@
         // The ubuntulooks engine paints slider troughs differently depending
         // on the current slider value and its component orientation.
         JSlider slider = (JSlider)context.getComponent();
+        if (GTKLookAndFeel.is3()) {
+            if (slider.getOrientation() == JSlider.VERTICAL) {
+                y += 1;
+                h -= 2;
+            } else {
+                x += 1;
+                w -= 2;
+            }
+        }
         double value = slider.getValue();
         double min = slider.getMinimum();
         double max = slider.getMaximum();
@@ -776,15 +810,19 @@
         Region id = context.getRegion();
         int gtkState = GTKLookAndFeel.synthStateToGTKState(
                 id, context.getComponentState());
+        boolean hasFocus = GTKLookAndFeel.is3() &&
+                ((context.getComponentState() & SynthConstants.FOCUSED) != 0);
         synchronized (UNIXToolkit.GTK_LOCK) {
-            if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, dir)) {
+            if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, dir,
+                                                                    hasFocus)) {
                 Orientation orientation = (dir == JSlider.HORIZONTAL ?
                     Orientation.HORIZONTAL : Orientation.VERTICAL);
                 String detail = (dir == JSlider.HORIZONTAL ?
                     "hscale" : "vscale");
                 ENGINE.startPainting(g, x, y, w, h, id, gtkState, dir);
                 ENGINE.paintSlider(g, context, id, gtkState,
-                        ShadowType.OUT, detail, x, y, w, h, orientation);
+                        ShadowType.OUT, detail, x, y, w, h, orientation,
+                                                                     hasFocus);
                 ENGINE.finishPainting();
             }
         }
@@ -963,15 +1001,21 @@
             int yThickness = style.getYThickness();
 
             ENGINE.startPainting(g, x, y, w, h, id, state);
+            if (GTKLookAndFeel.is3()) {
+                ENGINE.paintBackground(g, context, id, gtkState, null,
+                                                                    x, y, w, h);
+            }
             ENGINE.paintShadow(g, context, id, gtkState,
                                ShadowType.IN, "entry", x, y, w, h);
-            ENGINE.paintFlatBox(g, context, id,
-                                gtkState, ShadowType.NONE, "entry_bg",
-                                x + xThickness,
-                                y + yThickness,
-                                w - (2 * xThickness),
-                                h - (2 * yThickness),
-                                ColorType.TEXT_BACKGROUND);
+            if (!GTKLookAndFeel.is3()) {
+                ENGINE.paintFlatBox(g, context, id,
+                        gtkState, ShadowType.NONE, "entry_bg",
+                        x + xThickness,
+                        y + yThickness,
+                        w - (2 * xThickness),
+                        h - (2 * yThickness),
+                        ColorType.TEXT_BACKGROUND);
+            }
 
             if (focusSize > 0 && (state & SynthConstants.FOCUSED) != 0) {
                 if (!interiorFocus) {
@@ -982,14 +1026,14 @@
                 } else {
                     if (containerParent instanceof JComboBox) {
                         x += (focusSize + 2);
-                        y += (focusSize + 1);
-                        w -= (2 * focusSize + 1);
-                        h -= (2 * focusSize + 2);
+                        y += focusSize + (GTKLookAndFeel.is3() ? 3 : 1);
+                        w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 1);
+                        h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 6 : 2);
                     } else {
-                        x += focusSize;
-                        y += focusSize;
-                        w -= 2 * focusSize;
-                        h -= 2 * focusSize;
+                        x += focusSize + (GTKLookAndFeel.is3() ? 2 : 0);
+                        y += focusSize + (GTKLookAndFeel.is3() ? 2 :0 );
+                        w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0);
+                        h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0);
                     }
                 }
                 ENGINE.paintFocus(g, context, id, gtkState,
@@ -1138,8 +1182,8 @@
                 Orientation orientation = (dir == JScrollBar.HORIZONTAL ?
                     Orientation.HORIZONTAL : Orientation.VERTICAL);
                 ENGINE.setRangeValue(context, id, value, min, max, visible);
-                ENGINE.paintSlider(g, context, id, gtkState,
-                        ShadowType.OUT, "slider", x, y, w, h, orientation);
+                ENGINE.paintSlider(g, context, id, gtkState, ShadowType.OUT,
+                                      "slider", x, y, w, h, orientation, false);
                 ENGINE.finishPainting();
             }
         }
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, 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
@@ -715,29 +715,33 @@
         if (region == Region.COMBO_BOX ||
               region == Region.DESKTOP_PANE ||
               region == Region.DESKTOP_ICON ||
-              region == Region.EDITOR_PANE ||
-              region == Region.FORMATTED_TEXT_FIELD ||
               region == Region.INTERNAL_FRAME ||
               region == Region.LIST ||
               region == Region.MENU_BAR ||
               region == Region.PANEL ||
-              region == Region.PASSWORD_FIELD ||
               region == Region.POPUP_MENU ||
               region == Region.PROGRESS_BAR ||
               region == Region.ROOT_PANE ||
               region == Region.SCROLL_PANE ||
-              region == Region.SPINNER ||
               region == Region.SPLIT_PANE_DIVIDER ||
               region == Region.TABLE ||
               region == Region.TEXT_AREA ||
-              region == Region.TEXT_FIELD ||
-              region == Region.TEXT_PANE ||
               region == Region.TOOL_BAR_DRAG_WINDOW ||
               region == Region.TOOL_TIP ||
               region == Region.TREE ||
               region == Region.VIEWPORT) {
             return true;
         }
+        if (!GTKLookAndFeel.is3()) {
+            if (region == Region.EDITOR_PANE ||
+                  region == Region.FORMATTED_TEXT_FIELD ||
+                  region == Region.PASSWORD_FIELD ||
+                  region == Region.SPINNER ||
+                  region == Region.TEXT_FIELD ||
+                  region == Region.TEXT_PANE) {
+                return true;
+            }
+        }
         Component c = context.getComponent();
         String name = c.getName();
         if (name == "ComboBox.renderer" || name == "ComboBox.listRenderer") {
@@ -776,6 +780,15 @@
         }
         else if (key == "Separator.thickness") {
             JSeparator sep = (JSeparator)context.getComponent();
+            if (getClassSpecificBoolValue(context, "wide-separators", false)) {
+                if (sep.getOrientation() == JSeparator.HORIZONTAL) {
+                    return getClassSpecificIntValue(context,
+                            "separator-height", 0);
+                } else {
+                    return getClassSpecificIntValue(context,
+                            "separator-width", 0);
+                }
+            }
             if (sep.getOrientation() == JSeparator.HORIZONTAL) {
                 return getYThickness();
             } else {
@@ -783,6 +796,12 @@
             }
         }
         else if (key == "ToolBar.separatorSize") {
+            if (getClassSpecificBoolValue(context, "wide-separators", false)) {
+                return new DimensionUIResource(
+                    getClassSpecificIntValue(context, "separator-width", 2),
+                    getClassSpecificIntValue(context, "separator-height", 2)
+                );
+            }
             int size = getClassSpecificIntValue(WidgetType.TOOL_BAR,
                                                 "space-size", 12);
             return new DimensionUIResource(size, size);
@@ -833,6 +852,8 @@
             int focusPad =
                 getClassSpecificIntValue(context, "focus-padding", 1);
             return indicatorSpacing + focusSize + focusPad;
+        } else if (GTKLookAndFeel.is3() && "ComboBox.forceOpaque".equals(key)) {
+            return true;
         }
 
         // Is it a stock icon ?
@@ -1112,6 +1133,7 @@
     static {
         CLASS_SPECIFIC_MAP = new HashMap<String,String>();
         CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width");
+        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");
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -37,7 +37,6 @@
 
 
 
-import sun.swing.UIClientPropertyKey;
 import com.sun.java.swing.plaf.windows.TMSchema.State;
 import static com.sun.java.swing.plaf.windows.TMSchema.State.*;
 import com.sun.java.swing.plaf.windows.TMSchema.Part;
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -68,7 +68,6 @@
 import sun.awt.ConstrainableGraphics;
 import sun.awt.SubRegionShowable;
 import sun.awt.SunToolkit;
-import sun.awt.CausedFocusEvent;
 import sun.awt.EmbeddedFrame;
 import sun.awt.dnd.SunDropTargetEvent;
 import sun.awt.im.CompositionArea;
@@ -878,7 +877,7 @@
             {
                 comp.setGraphicsConfiguration(gc);
             }
-            public boolean requestFocus(Component comp, CausedFocusEvent.Cause cause) {
+            public boolean requestFocus(Component comp, FocusEvent.Cause cause) {
                 return comp.requestFocus(cause);
             }
             public boolean canBeFocusOwner(Component comp) {
@@ -7538,7 +7537,7 @@
         requestFocusHelper(false, true);
     }
 
-    boolean requestFocus(CausedFocusEvent.Cause cause) {
+    boolean requestFocus(FocusEvent.Cause cause) {
         return requestFocusHelper(false, true, cause);
     }
 
@@ -7605,7 +7604,7 @@
         return requestFocusHelper(temporary, true);
     }
 
-    boolean requestFocus(boolean temporary, CausedFocusEvent.Cause cause) {
+    boolean requestFocus(boolean temporary, FocusEvent.Cause cause) {
         return requestFocusHelper(temporary, true, cause);
     }
     /**
@@ -7656,7 +7655,7 @@
         return requestFocusHelper(false, false);
     }
 
-    boolean requestFocusInWindow(CausedFocusEvent.Cause cause) {
+    boolean requestFocusInWindow(FocusEvent.Cause cause) {
         return requestFocusHelper(false, false, cause);
     }
 
@@ -7721,18 +7720,18 @@
         return requestFocusHelper(temporary, false);
     }
 
-    boolean requestFocusInWindow(boolean temporary, CausedFocusEvent.Cause cause) {
+    boolean requestFocusInWindow(boolean temporary, FocusEvent.Cause cause) {
         return requestFocusHelper(temporary, false, cause);
     }
 
     final boolean requestFocusHelper(boolean temporary,
                                      boolean focusedWindowChangeAllowed) {
-        return requestFocusHelper(temporary, focusedWindowChangeAllowed, CausedFocusEvent.Cause.UNKNOWN);
+        return requestFocusHelper(temporary, focusedWindowChangeAllowed, FocusEvent.Cause.UNKNOWN);
     }
 
     final boolean requestFocusHelper(boolean temporary,
                                      boolean focusedWindowChangeAllowed,
-                                     CausedFocusEvent.Cause cause)
+                                     FocusEvent.Cause cause)
     {
         // 1) Check if the event being dispatched is a system-generated mouse event.
         AWTEvent currentEvent = EventQueue.getCurrentEvent();
@@ -7820,7 +7819,7 @@
 
     private boolean isRequestFocusAccepted(boolean temporary,
                                            boolean focusedWindowChangeAllowed,
-                                           CausedFocusEvent.Cause cause)
+                                           FocusEvent.Cause cause)
     {
         if (!isFocusable() || !isVisible()) {
             if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
@@ -7867,7 +7866,7 @@
             return true;
         }
 
-        if (CausedFocusEvent.Cause.ACTIVATION == cause) {
+        if (FocusEvent.Cause.ACTIVATION == cause) {
             // we shouldn't call RequestFocusController in case we are
             // in activation.  We do request focus on component which
             // has got temporary focus lost and then on component which is
@@ -7899,7 +7898,7 @@
     private static class DummyRequestFocusController implements RequestFocusController {
         public boolean acceptRequestFocus(Component from, Component to,
                                           boolean temporary, boolean focusedWindowChangeAllowed,
-                                          CausedFocusEvent.Cause cause)
+                                          FocusEvent.Cause cause)
         {
             return true;
         }
@@ -7983,7 +7982,7 @@
         Component toFocus = getNextFocusCandidate();
         boolean res = false;
         if (toFocus != null && !toFocus.isFocusOwner() && toFocus != this) {
-            res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_FORWARD);
+            res = toFocus.requestFocusInWindow(FocusEvent.Cause.TRAVERSAL_FORWARD);
         }
         if (clearOnFailure && !res) {
             if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
@@ -8063,7 +8062,7 @@
                 toFocus = policy.getDefaultComponent(rootAncestor);
             }
             if (toFocus != null) {
-                res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_BACKWARD);
+                res = toFocus.requestFocusInWindow(FocusEvent.Cause.TRAVERSAL_BACKWARD);
             }
         }
         if (clearOnFailure && !res) {
@@ -8108,7 +8107,7 @@
 
             KeyboardFocusManager.getCurrentKeyboardFocusManager().
                 setGlobalCurrentFocusCycleRootPriv(fcr);
-            rootAncestor.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
+            rootAncestor.requestFocus(FocusEvent.Cause.TRAVERSAL_UP);
         } else {
             Window window = getContainingWindow();
 
@@ -8118,7 +8117,7 @@
                 if (toFocus != null) {
                     KeyboardFocusManager.getCurrentKeyboardFocusManager().
                         setGlobalCurrentFocusCycleRootPriv(window);
-                    toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
+                    toFocus.requestFocus(FocusEvent.Cause.TRAVERSAL_UP);
                 }
             }
         }
--- a/jdk/src/java.desktop/share/classes/java/awt/Container.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/Container.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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,7 +55,6 @@
 
 import sun.awt.AppContext;
 import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
 import sun.awt.PeerEvent;
 import sun.awt.SunToolkit;
 
@@ -3515,7 +3514,7 @@
             Component toFocus = getFocusTraversalPolicy().
                 getDefaultComponent(this);
             if (toFocus != null) {
-                toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_DOWN);
+                toFocus.requestFocus(FocusEvent.Cause.TRAVERSAL_DOWN);
             }
         }
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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,6 @@
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
 import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
 import sun.awt.TimedWindowEvent;
 
 /**
@@ -165,13 +164,13 @@
                                    boolean clearOnFailure)
     {
         if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
-            toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
+            toFocus.requestFocus(false, FocusEvent.Cause.ROLLBACK))
         {
             return true;
         } else {
             Component nextFocus = toFocus.getNextFocusCandidate();
             if (nextFocus != null && nextFocus != vetoedComponent &&
-                nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
+                nextFocus.requestFocusInWindow(FocusEvent.Cause.ROLLBACK))
             {
                 return true;
             } else if (clearOnFailure) {
@@ -431,13 +430,13 @@
                                        tempLost, toFocus);
                     }
                     if (tempLost != null) {
-                        tempLost.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
+                        tempLost.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
                     }
 
                     if (toFocus != null && toFocus != tempLost) {
                         // If there is a component which requested focus when this window
                         // was inactive it expects to receive focus after activation.
-                        toFocus.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
+                        toFocus.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
                     }
                 }
 
@@ -490,8 +489,6 @@
 
             case FocusEvent.FOCUS_GAINED: {
                 FocusEvent fe = (FocusEvent)e;
-                CausedFocusEvent.Cause cause = (fe instanceof CausedFocusEvent) ?
-                    ((CausedFocusEvent)fe).getCause() : CausedFocusEvent.Cause.UNKNOWN;
                 Component oldFocusOwner = getGlobalFocusOwner();
                 Component newFocusOwner = fe.getComponent();
                 if (oldFocusOwner == newFocusOwner) {
@@ -509,10 +506,10 @@
                 if (oldFocusOwner != null) {
                     boolean isEventDispatched =
                         sendMessage(oldFocusOwner,
-                                    new CausedFocusEvent(oldFocusOwner,
+                                    new FocusEvent(oldFocusOwner,
                                                    FocusEvent.FOCUS_LOST,
                                                    fe.isTemporary(),
-                                                   newFocusOwner, cause));
+                                                   newFocusOwner, fe.getCause()));
                     // Failed to dispatch, clear by ourselves
                     if (!isEventDispatched) {
                         setGlobalFocusOwner(null);
@@ -552,7 +549,7 @@
                     // Refuse focus on a disabled component if the focus event
                     // isn't of UNKNOWN reason (i.e. not a result of a direct request
                     // but traversal, activation or system generated).
-                    (newFocusOwner.isEnabled() || cause.equals(CausedFocusEvent.Cause.UNKNOWN))))
+                    (newFocusOwner.isEnabled() || fe.getCause().equals(FocusEvent.Cause.UNKNOWN))))
                 {
                     // we should not accept focus on such component, so reject it.
                     dequeueKeyEvents(-1, newFocusOwner);
@@ -601,10 +598,10 @@
                 Component realOppositeComponent = this.realOppositeComponentWR.get();
                 if (realOppositeComponent != null &&
                     realOppositeComponent != fe.getOppositeComponent()) {
-                    fe = new CausedFocusEvent(newFocusOwner,
+                    fe = new FocusEvent(newFocusOwner,
                                         FocusEvent.FOCUS_GAINED,
                                         fe.isTemporary(),
-                                        realOppositeComponent, cause);
+                                        realOppositeComponent, fe.getCause());
                     ((AWTEvent) fe).isPosted = true;
                 }
                 return typeAheadAssertions(newFocusOwner, fe);
@@ -729,10 +726,10 @@
                         oppositeComp = oppositeWindow;
                     }
                     sendMessage(currentFocusOwner,
-                                new CausedFocusEvent(currentFocusOwner,
+                                new FocusEvent(currentFocusOwner,
                                                FocusEvent.FOCUS_LOST,
                                                true,
-                                               oppositeComp, CausedFocusEvent.Cause.ACTIVATION));
+                                               oppositeComp, FocusEvent.Cause.ACTIVATION));
                 }
 
                 setGlobalFocusedWindow(null);
--- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -57,7 +57,6 @@
 
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
-import sun.awt.CausedFocusEvent;
 import sun.awt.KeyboardFocusManagerPeerProvider;
 import sun.awt.AWTAccessor;
 
@@ -124,7 +123,7 @@
                                                    boolean temporary,
                                                    boolean focusedWindowChangeAllowed,
                                                    long time,
-                                                   CausedFocusEvent.Cause cause)
+                                                   FocusEvent.Cause cause)
                 {
                     return KeyboardFocusManager.shouldNativelyFocusHeavyweight(
                         heavyweight, descendant, temporary, focusedWindowChangeAllowed, time, cause);
@@ -2164,9 +2163,9 @@
     private static final class LightweightFocusRequest {
         final Component component;
         final boolean temporary;
-        final CausedFocusEvent.Cause cause;
+        final FocusEvent.Cause cause;
 
-        LightweightFocusRequest(Component component, boolean temporary, CausedFocusEvent.Cause cause) {
+        LightweightFocusRequest(Component component, boolean temporary, FocusEvent.Cause cause) {
             this.component = component;
             this.temporary = temporary;
             this.cause = cause;
@@ -2190,7 +2189,7 @@
         }
 
         HeavyweightFocusRequest(Component heavyweight, Component descendant,
-                                boolean temporary, CausedFocusEvent.Cause cause) {
+                                boolean temporary, FocusEvent.Cause cause) {
             if (log.isLoggable(PlatformLogger.Level.FINE)) {
                 if (heavyweight == null) {
                     log.fine("Assertion (heavyweight != null) failed");
@@ -2202,7 +2201,7 @@
             addLightweightRequest(descendant, temporary, cause);
         }
         boolean addLightweightRequest(Component descendant,
-                                      boolean temporary, CausedFocusEvent.Cause cause) {
+                                      boolean temporary, FocusEvent.Cause cause) {
             if (log.isLoggable(PlatformLogger.Level.FINE)) {
                 if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) {
                     log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
@@ -2314,7 +2313,7 @@
 
                 hwFocusRequest =
                     new HeavyweightFocusRequest(heavyweight, descendant,
-                                                temporary, CausedFocusEvent.Cause.UNKNOWN);
+                                                temporary, FocusEvent.Cause.UNKNOWN);
                 heavyweightRequests.add(hwFocusRequest);
 
                 if (currentFocusOwner != null) {
@@ -2379,7 +2378,7 @@
      */
     static int shouldNativelyFocusHeavyweight
         (Component heavyweight, Component descendant, boolean temporary,
-         boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
+         boolean focusedWindowChangeAllowed, long time, FocusEvent.Cause cause)
     {
         if (log.isLoggable(PlatformLogger.Level.FINE)) {
             if (heavyweight == null) {
@@ -2445,7 +2444,7 @@
 
                 if (currentFocusOwner != null) {
                     FocusEvent currentFocusOwnerEvent =
-                        new CausedFocusEvent(currentFocusOwner,
+                        new FocusEvent(currentFocusOwner,
                                        FocusEvent.FOCUS_LOST,
                                        temporary, descendant, cause);
                     // Fix 5028014. Rolled out.
@@ -2454,7 +2453,7 @@
                                          currentFocusOwnerEvent);
                 }
                 FocusEvent newFocusOwnerEvent =
-                    new CausedFocusEvent(descendant, FocusEvent.FOCUS_GAINED,
+                    new FocusEvent(descendant, FocusEvent.FOCUS_GAINED,
                                    temporary, currentFocusOwner, cause);
                 // Fix 5028014. Rolled out.
                 // SunToolkit.postPriorityEvent(newFocusOwnerEvent);
@@ -2670,13 +2669,13 @@
                      * lw requests.
                      */
                     if (currentFocusOwner != null) {
-                        currentFocusOwnerEvent = new CausedFocusEvent(currentFocusOwner,
+                        currentFocusOwnerEvent = new FocusEvent(currentFocusOwner,
                                        FocusEvent.FOCUS_LOST,
                                        lwFocusRequest.temporary,
                                        lwFocusRequest.component, lwFocusRequest.cause);
                     }
                     FocusEvent newFocusOwnerEvent =
-                        new CausedFocusEvent(lwFocusRequest.component,
+                        new FocusEvent(lwFocusRequest.component,
                                        FocusEvent.FOCUS_GAINED,
                                        lwFocusRequest.temporary,
                                        currentFocusOwner == null ? lastFocusOwner : currentFocusOwner,
@@ -2726,8 +2725,8 @@
             {
                 temporary = true;
             }
-            return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
-                                        CausedFocusEvent.Cause.NATIVE_SYSTEM);
+            return new FocusEvent(source, fe.getID(), temporary, opposite,
+                                        FocusEvent.Cause.UNEXPECTED);
         }
     }
 
@@ -2802,7 +2801,7 @@
 
                 // 'opposite' will be fixed by
                 // DefaultKeyboardFocusManager.realOppositeComponent
-                return new CausedFocusEvent(newSource,
+                return new FocusEvent(newSource,
                                       FocusEvent.FOCUS_GAINED, temporary,
                                       opposite, lwFocusRequest.cause);
             }
@@ -2815,8 +2814,8 @@
                 // If it arrives as the result of activation we should skip it
                 // This event will not have appropriate request record and
                 // on arrival there will be already some focus owner set.
-                return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false,
-                                            null, CausedFocusEvent.Cause.ACTIVATION);
+                return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false,
+                                            null, FocusEvent.Cause.ACTIVATION);
             }
 
             return retargetUnexpectedFocusEvent(fe);
@@ -2839,9 +2838,9 @@
                 if (currentFocusOwner != null) {
                     // Call to KeyboardFocusManager.clearGlobalFocusOwner()
                     heavyweightRequests.removeFirst();
-                    return new CausedFocusEvent(currentFocusOwner,
+                    return new FocusEvent(currentFocusOwner,
                                                 FocusEvent.FOCUS_LOST, false, null,
-                                                CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
+                                                FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
                 }
 
                 // Otherwise, fall through to failure case below
@@ -2850,9 +2849,9 @@
             {
                 // Focus leaving application
                 if (currentFocusOwner != null) {
-                    return new CausedFocusEvent(currentFocusOwner,
+                    return new FocusEvent(currentFocusOwner,
                                                 FocusEvent.FOCUS_LOST,
-                                                true, null, CausedFocusEvent.Cause.ACTIVATION);
+                                                true, null, FocusEvent.Cause.ACTIVATION);
                 } else {
                     return fe;
                 }
@@ -2878,15 +2877,15 @@
                     ? true
                     : lwFocusRequest.temporary;
 
-                return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
+                return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
                                             temporary, lwFocusRequest.component, lwFocusRequest.cause);
             } else if (focusedWindowChanged(opposite, currentFocusOwner)) {
                 // If top-level changed there might be no focus request in a list
                 // But we know the opposite, we now it is temporary - dispatch the event.
                 if (!fe.isTemporary() && currentFocusOwner != null) {
                     // Create copy of the event with only difference in temporary parameter.
-                    fe = new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
-                                              true, opposite, CausedFocusEvent.Cause.ACTIVATION);
+                    fe = new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
+                                              true, opposite, FocusEvent.Cause.ACTIVATION);
                 }
                 return fe;
             }
--- a/jdk/src/java.desktop/share/classes/java/awt/Window.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -52,7 +52,6 @@
 import sun.awt.AWTAccessor;
 import sun.awt.AWTPermissions;
 import sun.awt.AppContext;
-import sun.awt.CausedFocusEvent;
 import sun.awt.DebugSettings;
 import sun.awt.SunToolkit;
 import sun.awt.util.IdentityArrayList;
@@ -2599,7 +2598,7 @@
                 {
                     Component toFocus =
                         KeyboardFocusManager.getMostRecentFocusOwner(owner);
-                    if (toFocus != null && toFocus.requestFocus(false, CausedFocusEvent.Cause.ACTIVATION)) {
+                    if (toFocus != null && toFocus.requestFocus(false, FocusEvent.Cause.ACTIVATION)) {
                         return;
                     }
                 }
--- a/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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,6 +26,9 @@
 package java.awt.event;
 
 import java.awt.Component;
+import java.io.ObjectStreamException;
+
+import sun.awt.AWTAccessor;
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
 
@@ -51,6 +54,10 @@
  * the FOCUS_GAINED and FOCUS_LOST event ids; the level may be distinguished in
  * the event using the isTemporary() method.
  * <p>
+ * Every {@code FocusEvent} records its cause - the reason why this event was
+ * generated. The cause is assigned during the focus event creation and may be
+ * retrieved by calling {@link #getCause}.
+ * <p>
  * An unspecified behavior will be caused if the {@code id} parameter
  * of any particular {@code FocusEvent} instance is not
  * in the range from {@code FOCUS_FIRST} to {@code FOCUS_LAST}.
@@ -66,6 +73,61 @@
 public class FocusEvent extends ComponentEvent {
 
     /**
+     * This enum represents the cause of a {@code FocusEvent}- the reason why it
+     * occurred. Possible reasons include mouse events, keyboard focus
+     * traversal, window activation.
+     * If no cause is provided then the reason is {@code UNKNOWN}.
+     *
+     * @since 9
+     */
+    public enum Cause {
+        /**
+         * The default value.
+         */
+        UNKNOWN,
+        /**
+         * An activating mouse event.
+         */
+        MOUSE_EVENT,
+        /**
+         * A focus traversal action with unspecified direction.
+         */
+        TRAVERSAL,
+        /**
+         * An up-cycle focus traversal action.
+         */
+        TRAVERSAL_UP,
+        /**
+         * A down-cycle focus traversal action.
+         */
+        TRAVERSAL_DOWN,
+        /**
+         * A forward focus traversal action.
+         */
+        TRAVERSAL_FORWARD,
+        /**
+         * A backward focus traversal action.
+         */
+        TRAVERSAL_BACKWARD,
+        /**
+         * Restoring focus after a focus request has been rejected.
+         */
+        ROLLBACK,
+        /**
+         * A system action causing an unexpected focus change.
+         */
+        UNEXPECTED,
+        /**
+         * An activation of a toplevel window.
+         */
+        ACTIVATION,
+        /**
+         * Clearing global focus owner.
+         */
+        CLEAR_GLOBAL_FOCUS_OWNER
+    }
+
+    /**
      * The first number in the range of ids used for focus events.
      */
     public static final int FOCUS_FIRST         = 1004;
@@ -86,6 +148,16 @@
     public static final int FOCUS_LOST = 1 + FOCUS_FIRST; //Event.LOST_FOCUS
 
     /**
+     * A focus event has the reason why this event was generated.
+     * The cause is set during the focus event creation.
+     *
+     * @serial
+     * @see #getCause()
+     * @since 9
+     */
+    private final Cause cause;
+
+    /**
      * A focus event can have two different levels, permanent and temporary.
      * It will be set to true if some operation takes away the focus
      * temporarily and intends on getting it back once the event is completed.
@@ -115,7 +187,8 @@
 
     /**
      * Constructs a {@code FocusEvent} object with the
-     * specified temporary state and opposite {@code Component}.
+     * specified temporary state, opposite {@code Component} and the
+     * {@code Cause.UNKNOWN} cause.
      * The opposite {@code Component} is the other
      * {@code Component} involved in this focus change.
      * For a {@code FOCUS_GAINED} event, this is the
@@ -142,13 +215,57 @@
      * @see #getID()
      * @see #isTemporary()
      * @see #getOppositeComponent()
+     * @see Cause#UNKNOWN
      * @since 1.4
      */
     public FocusEvent(Component source, int id, boolean temporary,
                       Component opposite) {
+        this(source, id, temporary, opposite, Cause.UNKNOWN);
+    }
+
+    /**
+     * Constructs a {@code FocusEvent} object with the
+     * specified temporary state, opposite {@code Component} and the cause.
+     * The opposite {@code Component} is the other
+     * {@code Component} involved in this focus change.
+     * For a {@code FOCUS_GAINED} event, this is the
+     * {@code Component} that lost focus. For a
+     * {@code FOCUS_LOST} event, this is the {@code Component}
+     * that gained focus. If this focus change occurs with a native
+     * application, with a Java application in a different VM,
+     * or with no other {@code Component}, then the opposite
+     * {@code Component} is {@code null}.
+     * <p> This method throws an
+     * {@code IllegalArgumentException} if {@code source} or {@code cause}
+     * is {@code null}.
+     *
+     * @param source    The {@code Component} that originated the event
+     * @param id        An integer indicating the type of event.
+     *                  For information on allowable values, see
+     *                  the class description for {@link FocusEvent}
+     * @param temporary Equals {@code true} if the focus change is temporary;
+     *                  {@code false} otherwise
+     * @param opposite  The other Component involved in the focus change,
+     *                  or {@code null}
+     * @param cause     The focus event cause.
+     * @throws IllegalArgumentException if {@code source} equals {@code null}
+     *                                  or if {@code cause} equals {@code null}
+     * @see #getSource()
+     * @see #getID()
+     * @see #isTemporary()
+     * @see #getOppositeComponent()
+     * @see Cause
+     * @since 9
+     */
+    public FocusEvent(Component source, int id, boolean temporary,
+                      Component opposite, Cause cause) {
         super(source, id);
+        if (cause == null) {
+            throw new IllegalArgumentException("null cause");
+        }
         this.temporary = temporary;
         this.opposite = opposite;
+        this.cause = cause;
     }
 
     /**
@@ -220,8 +337,8 @@
 
         return (SunToolkit.targetToAppContext(opposite) ==
                 AppContext.getAppContext())
-            ? opposite
-            : null;
+                ? opposite
+                : null;
     }
 
     /**
@@ -233,17 +350,56 @@
     public String paramString() {
         String typeStr;
         switch(id) {
-          case FOCUS_GAINED:
-              typeStr = "FOCUS_GAINED";
-              break;
-          case FOCUS_LOST:
-              typeStr = "FOCUS_LOST";
-              break;
-          default:
-              typeStr = "unknown type";
+            case FOCUS_GAINED:
+                typeStr = "FOCUS_GAINED";
+                break;
+            case FOCUS_LOST:
+                typeStr = "FOCUS_LOST";
+                break;
+            default:
+                typeStr = "unknown type";
         }
         return typeStr + (temporary ? ",temporary" : ",permanent") +
-            ",opposite=" + getOppositeComponent();
+                ",opposite=" + getOppositeComponent() + ",cause=" + getCause();
+    }
+
+    /**
+     * Returns the event cause.
+     *
+     * @return one of {@link Cause} values
+     * @since 9
+     */
+    public final Cause getCause() {
+        return cause;
     }
 
-}
+    /**
+     * Checks if this deserialized {@code FocusEvent} instance is compatible
+     * with the current specification which implies that focus event has
+     * non-null {@code cause} value. If the check fails a new {@code FocusEvent}
+     * instance is returned which {@code cause} field equals to
+     * {@link Cause#UNKNOWN} and its other fields have the same values as in
+     * this {@code FocusEvent} instance.
+     *
+     * @serial
+     * @see #cause
+     * @since 9
+     */
+    @SuppressWarnings("serial")
+    Object readResolve() throws ObjectStreamException {
+        if (cause != null) {
+            return this;
+        }
+        FocusEvent focusEvent = new FocusEvent(new Component(){}, getID(),
+                isTemporary(), getOppositeComponent());
+        focusEvent.setSource(null);
+        focusEvent.consumed = consumed;
+
+        AWTAccessor.AWTEventAccessor accessor =
+                AWTAccessor.getAWTEventAccessor();
+        accessor.setBData(focusEvent, accessor.getBData(this));
+        return focusEvent;
+    }
+
+
+}
\ No newline at end of file
--- a/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -27,12 +27,12 @@
 
 import java.awt.*;
 import java.awt.event.PaintEvent;
+import java.awt.event.FocusEvent.Cause;
 import java.awt.image.ColorModel;
 import java.awt.image.ImageObserver;
 import java.awt.image.ImageProducer;
 import java.awt.image.VolatileImage;
 
-import sun.awt.CausedFocusEvent;
 import sun.java2d.pipe.Region;
 
 
@@ -343,7 +343,7 @@
      */
     boolean requestFocus(Component lightweightChild, boolean temporary,
                          boolean focusedWindowChangeAllowed, long time,
-                         CausedFocusEvent.Cause cause);
+                         Cause cause);
 
     /**
      * Returns {@code true} when the component takes part in the focus
--- a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java	Mon Apr 25 09:25:26 2016 -0700
@@ -577,6 +577,8 @@
     /**
      * Gets the name of the printing user.
      * @return the name of the printing user
+     * @throws SecurityException if a security manager exists and
+     *         PropertyPermission - user.name is not given in the policy file
      */
     public abstract String getUserName();
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Mon Apr 25 09:25:26 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
@@ -36,7 +36,6 @@
 
 import java.awt.*;
 import java.awt.event.*;
-import java.awt.peer.LightweightPeer;
 
 import java.applet.Applet;
 
@@ -57,7 +56,6 @@
 import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
 import sun.swing.SwingUtilities2;
-import sun.swing.UIClientPropertyKey;
 
 /**
  * The base class for all Swing components except top-level containers.
@@ -3558,7 +3556,7 @@
         new sun.awt.RequestFocusController() {
             public boolean acceptRequestFocus(Component from, Component to,
                                               boolean temporary, boolean focusedWindowChangeAllowed,
-                                              sun.awt.CausedFocusEvent.Cause cause)
+                                              FocusEvent.Cause cause)
             {
                 if ((to == null) || !(to instanceof JComponent)) {
                     return true;
--- a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java	Mon Apr 25 09:25:26 2016 -0700
@@ -846,14 +846,46 @@
     }
 
     /**
+     * Check whether MouseEvent contains speficied mouse button or
+     * mouse button down mask based on MouseEvent ID.
+     *
+     * @param anEvent  a MouseEvent object
+     * @param mouseButton mouse button type
+     * @param mouseButtonDownMask mouse button down mask event modifier
+     *
+     * @return true if the anEvent contains speficied mouseButton or
+     * mouseButtonDownMask based on MouseEvent ID.
+     */
+    private static boolean checkMouseButton(MouseEvent anEvent,
+                                            int mouseButton,
+                                            int mouseButtonDownMask)
+    {
+        switch (anEvent.getID()) {
+        case MouseEvent.MOUSE_PRESSED:
+        case MouseEvent.MOUSE_RELEASED:
+        case MouseEvent.MOUSE_CLICKED:
+            return (anEvent.getButton() == mouseButton);
+
+        case MouseEvent.MOUSE_ENTERED:
+        case MouseEvent.MOUSE_EXITED:
+        case MouseEvent.MOUSE_DRAGGED:
+            return ((anEvent.getModifiersEx() & mouseButtonDownMask) != 0);
+
+        default:
+            return ((anEvent.getModifiersEx() & mouseButtonDownMask) != 0 ||
+                    anEvent.getButton() == mouseButton);
+        }
+    }
+
+    /**
      * Returns true if the mouse event specifies the left mouse button.
      *
      * @param anEvent  a MouseEvent object
      * @return true if the left mouse button was active
      */
     public static boolean isLeftMouseButton(MouseEvent anEvent) {
-         return ((anEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0 ||
-                 anEvent.getButton() == MouseEvent.BUTTON1);
+        return checkMouseButton(anEvent, MouseEvent.BUTTON1,
+                                InputEvent.BUTTON1_DOWN_MASK);
     }
 
     /**
@@ -863,8 +895,8 @@
      * @return true if the middle mouse button was active
      */
     public static boolean isMiddleMouseButton(MouseEvent anEvent) {
-        return ((anEvent.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0 ||
-                anEvent.getButton() == MouseEvent.BUTTON2);
+        return checkMouseButton(anEvent, MouseEvent.BUTTON2,
+                                InputEvent.BUTTON2_DOWN_MASK);
     }
 
     /**
@@ -874,8 +906,8 @@
      * @return true if the right mouse button was active
      */
     public static boolean isRightMouseButton(MouseEvent anEvent) {
-        return ((anEvent.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0 ||
-                anEvent.getButton() == MouseEvent.BUTTON3);
+        return checkMouseButton(anEvent, MouseEvent.BUTTON3,
+                                InputEvent.BUTTON3_DOWN_MASK);
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIClientPropertyKey.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2006, 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 javax.swing;
+
+/**
+ * This interface is used only for tagging keys for client properties for
+ * {@code JComponent} set by UI which needs to be cleared on {@literal L&F}
+ * change and serialization.
+ * <p>
+ * All such keys are removed from client properties in
+ * {@code JComponent.setUI()} method after uninstalling old UI and before
+ * installing the new one. They are also removed prior to serialization.
+ *
+ * @author Igor Kushnirskiy
+ * @since 9
+ */
+public interface UIClientPropertyKey {
+}
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java	Mon Apr 25 09:25:26 2016 -0700
@@ -139,7 +139,6 @@
                 }
             }
 
-            context.dispose();
             return dim;
         }
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java	Mon Apr 25 09:25:26 2016 -0700
@@ -61,7 +61,6 @@
             return;
         }
         ui.paintBorder(context, g, x, y, width, height);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -105,7 +105,6 @@
             }
 
         }
-        context.dispose();
     }
 
     /**
@@ -125,7 +124,6 @@
         SynthContext context = getContext(b, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -226,7 +224,6 @@
         else {
             baseline = textRect.y + fm.getAscent();
         }
-        context.dispose();
         return baseline;
     }
 
@@ -253,7 +250,6 @@
         SynthLookAndFeel.update(context, g);
         paintBackground(context, g, c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -270,7 +266,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -321,7 +316,6 @@
     protected Icon getDefaultIcon(AbstractButton b) {
         SynthContext context = getContext(b);
         Icon icon = context.getStyle().getIcon(context, getPropertyPrefix() + "icon");
-        context.dispose();
         return icon;
     }
 
@@ -473,7 +467,6 @@
                b.getVerticalTextPosition(), b.getIconTextGap(),
                b.getDisplayedMnemonicIndex());
 
-        ss.dispose();
         return size;
     }
 
@@ -494,7 +487,6 @@
                b.getVerticalTextPosition(), b.getIconTextGap(),
                b.getDisplayedMnemonicIndex());
 
-        ss.dispose();
         return size;
     }
 
@@ -516,7 +508,6 @@
                b.getVerticalTextPosition(), b.getIconTextGap(),
                b.getDisplayedMnemonicIndex());
 
-        ss.dispose();
         return size;
     }
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -65,7 +65,6 @@
         SynthContext context = getContext(chooser, ENABLED);
         AbstractColorChooserPanel[] panels = (AbstractColorChooserPanel[])
                      context.getStyle().get(context, "ColorChooser.panels");
-        context.dispose();
 
         if (panels == null) {
             panels = ColorChooserComponentFactory.getDefaultChooserPanels();
@@ -85,7 +84,6 @@
     private void updateStyle(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -96,7 +94,6 @@
         SynthContext context = getContext(chooser, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         super.uninstallDefaults();
     }
@@ -155,7 +152,6 @@
         context.getPainter().paintColorChooserBackground(context, g, 0, 0,
                                                   c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -172,7 +168,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -144,7 +144,6 @@
             forceOpaque = style.getBoolean(context,
                     "ComboBox.forceOpaque", false);
         }
-        context.dispose();
 
         if(listBox != null) {
             SynthLookAndFeel.updateStyles(listBox);
@@ -182,7 +181,6 @@
         SynthContext context = getContext(comboBox, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -323,7 +321,6 @@
         context.getPainter().paintComboBoxBackground(context, g, 0, 0,
                                                   c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -340,7 +337,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java	Mon Apr 25 09:25:26 2016 -0700
@@ -24,8 +24,6 @@
  */
 package javax.swing.plaf.synth;
 
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
 import javax.swing.JComponent;
 
 /**
@@ -40,7 +38,6 @@
  * @author Scott Violet
  */
 public class SynthContext {
-    private static final Queue<SynthContext> queue = new ConcurrentLinkedQueue<>();
 
     private JComponent component;
     private Region region;
@@ -54,19 +51,15 @@
     static SynthContext getContext(JComponent component,
                                    Region region, SynthStyle style,
                                    int state) {
-        SynthContext context = queue.poll();
-        if (context == null) {
-            context = new SynthContext();
-        }
-        context.reset(component, region, style, state);
+        SynthContext context = new SynthContext();
+        context.component = component;
+        context.region = region;
+        context.style = style;
+        context.state = state;
         return context;
     }
 
-    static void releaseContext(SynthContext context) {
-        queue.offer(context);
-    }
-
-    SynthContext() {
+    private SynthContext() {
     }
 
     /**
@@ -86,7 +79,11 @@
             throw new NullPointerException(
                 "You must supply a non-null component, region and style");
         }
-        reset(component, region, style, state);
+
+        this.component = component;
+        this.region = region;
+        this.style = style;
+        this.state = state;
     }
 
 
@@ -147,23 +144,6 @@
     }
 
     /**
-     * Resets the state of the Context.
-     */
-    void reset(JComponent component, Region region, SynthStyle style,
-               int state) {
-        this.component = component;
-        this.region = region;
-        this.style = style;
-        this.state = state;
-    }
-
-    void dispose() {
-        this.component = null;
-        this.style = null;
-        releaseContext(this);
-    }
-
-    /**
      * Convenience method to get the Painter from the current SynthStyle.
      * This will NEVER return null.
      */
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java	Mon Apr 25 09:25:26 2016 -0700
@@ -41,7 +41,6 @@
         }
         SynthContext context = ((SynthUI)ui).getContext(c);
         Object value = context.getStyle().get(context, key);
-        context.dispose();
         return value;
     }
 }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -121,7 +121,6 @@
     private void updateStyle(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -131,7 +130,6 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(desktopIcon, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -171,7 +169,6 @@
         context.getPainter().paintDesktopIconBackground(context, g, 0, 0,
                                                   c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -188,7 +185,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -119,7 +119,6 @@
             uninstallKeyboardActions();
             installKeyboardActions();
         }
-        context.dispose();
     }
 
     /**
@@ -143,7 +142,6 @@
         SynthContext context = getContext(desktop, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         if (taskBar != null) {
@@ -460,7 +458,6 @@
         context.getPainter().paintDesktopPaneBackground(context, g, 0, 0,
                                                   c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -477,7 +474,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -83,7 +83,6 @@
         c.putClientProperty("caretAspectRatio", null);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         Object clientProperty =
@@ -127,7 +126,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -165,7 +163,6 @@
         SynthLookAndFeel.update(context, g);
         paintBackground(context, g, c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java	Mon Apr 25 09:25:26 2016 -0700
@@ -138,7 +138,6 @@
                 }
             }
         }
-        context.dispose();
     }
 
     protected void installDefaults() {
@@ -149,7 +148,6 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(this, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
         if(di != null && di.getComponentPopupMenu() == systemPopupMenu) {
@@ -235,7 +233,6 @@
         context.getPainter().paintInternalFrameTitlePaneBackground(context,
                           g, 0, 0, getWidth(), getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     protected void paint(SynthContext context, Graphics g) {
@@ -321,7 +318,6 @@
         SynthContext context = getContext(this);
         LayoutManager lm =
             (LayoutManager)style.get(context, "InternalFrameTitlePane.titlePaneLayout");
-        context.dispose();
         return (lm != null) ? lm : new SynthTitlePaneLayout();
     }
 
@@ -362,7 +358,6 @@
                              Image.SCALE_SMOOTH));
             }
         }
-        context.dispose();
         menuButton.setIcon(frameIcon);
     }
 
@@ -433,7 +428,6 @@
             Insets insets = getInsets();
             height += insets.top + insets.bottom;
             width += insets.left + insets.right;
-            context.dispose();
             return new Dimension(width, height);
         }
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -118,7 +118,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -128,7 +127,6 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(frame, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         if(frame.getLayout() == internalFrameLayout) {
             frame.setLayout(null);
@@ -216,7 +214,6 @@
         context.getPainter().paintInternalFrameBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -233,7 +230,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -67,7 +67,6 @@
     void updateStyle(JLabel c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -78,7 +77,6 @@
         SynthContext context = getContext(c, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -150,7 +148,6 @@
         else {
             baseline = textRect.y + fm.getAscent();
         }
-        context.dispose();
         return baseline;
     }
 
@@ -174,7 +171,6 @@
         context.getPainter().paintLabelBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -191,7 +187,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -242,7 +237,6 @@
                label.getVerticalTextPosition(), label.getIconTextGap(),
                label.getDisplayedMnemonicIndex());
 
-        context.dispose();
         return size;
     }
 
@@ -263,7 +257,6 @@
                label.getVerticalTextPosition(), label.getIconTextGap(),
                label.getDisplayedMnemonicIndex());
 
-        context.dispose();
         return size;
     }
 
@@ -284,7 +277,6 @@
                label.getVerticalTextPosition(), label.getIconTextGap(),
                label.getDisplayedMnemonicIndex());
 
-        context.dispose();
         return size;
     }
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -75,7 +75,6 @@
         SynthLookAndFeel.update(context, g);
         context.getPainter().paintListBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
-        context.dispose();
         paint(g, c);
     }
 
@@ -162,7 +161,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -175,7 +173,6 @@
         SynthContext context = getContext(list, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java	Mon Apr 25 09:25:26 2016 -0700
@@ -976,7 +976,6 @@
                 if (currBG != null && !currBG.equals(lastBG)) {
                     comp.repaint();
                 }
-                context.dispose();
             }
         }
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -83,7 +83,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -94,7 +93,6 @@
         SynthContext context = getContext(menuBar, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -143,7 +141,6 @@
         context.getPainter().paintMenuBarBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -160,7 +157,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -124,13 +124,11 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
         SynthContext accContext = getContext(mi, Region.MENU_ITEM_ACCELERATOR,
                                              ENABLED);
 
         accStyle = SynthLookAndFeel.updateStyle(accContext, this);
-        accContext.dispose();
     }
 
     /**
@@ -140,13 +138,11 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(menuItem, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         SynthContext accContext = getContext(menuItem,
                                      Region.MENU_ITEM_ACCELERATOR, ENABLED);
         accStyle.uninstallDefaults(accContext);
-        accContext.dispose();
         accStyle = null;
 
         super.uninstallDefaults();
@@ -218,8 +214,6 @@
                 defaultTextIconGap, acceleratorDelimiter,
                 MenuItemLayoutHelper.useCheckAndArrow(menuItem),
                 getPropertyPrefix());
-        context.dispose();
-        accContext.dispose();
         return value;
     }
 
@@ -243,7 +237,6 @@
         SynthLookAndFeel.update(context, g);
         paintBackground(context, g, c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -260,7 +253,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -280,7 +272,6 @@
         Icon arrowIcon = style.getIcon(context, prefix + ".arrowIcon");
         SynthGraphicsUtils.paint(context, accContext, g, checkIcon, arrowIcon,
               acceleratorDelimiter, defaultTextIconGap, getPropertyPrefix());
-        accContext.dispose();
     }
 
     void paintBackground(SynthContext context, Graphics g, JComponent c) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -110,13 +110,11 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
         SynthContext accContext = getContext(mi, Region.MENU_ITEM_ACCELERATOR,
                                              ENABLED);
 
         accStyle = SynthLookAndFeel.updateStyle(accContext, this);
-        accContext.dispose();
     }
 
     /**
@@ -140,13 +138,11 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(menuItem, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         SynthContext accContext = getContext(menuItem,
                                      Region.MENU_ITEM_ACCELERATOR, ENABLED);
         accStyle.uninstallDefaults(accContext);
-        accContext.dispose();
         accStyle = null;
 
         super.uninstallDefaults();
@@ -218,8 +214,6 @@
                 defaultTextIconGap, acceleratorDelimiter,
                 MenuItemLayoutHelper.useCheckAndArrow(menuItem),
                 getPropertyPrefix());
-        context.dispose();
-        accContext.dispose();
         return value;
     }
 
@@ -243,7 +237,6 @@
         context.getPainter().paintMenuBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -260,7 +253,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -279,7 +271,6 @@
         Icon arrowIcon = style.getIcon(context, prefix + ".arrowIcon");
         SynthGraphicsUtils.paint(context, accContext, g, checkIcon, arrowIcon,
               acceleratorDelimiter, defaultTextIconGap, getPropertyPrefix());
-        accContext.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -88,7 +88,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -99,7 +98,6 @@
         SynthContext context = getContext(optionPane, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -125,7 +123,6 @@
             SynthContext context = getContext(optionPane, ENABLED);
             optionPane.add(Box.createVerticalStrut(context.getStyle().
                        getInt(context, "OptionPane.separatorPadding", 6)));
-            context.dispose();
         }
         optionPane.add(createButtonArea());
         optionPane.applyComponentOrientation(optionPane.getComponentOrientation());
@@ -167,7 +164,6 @@
         context.getPainter().paintOptionPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -184,7 +180,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -259,7 +254,6 @@
         SynthContext context = getContext(optionPane, ENABLED);
         cons.anchor = context.getStyle().getInt(context,
                       "OptionPane.messageAnchor", GridBagConstraints.CENTER);
-        context.dispose();
 
         cons.insets = new Insets(0,0,3,0);
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -108,14 +108,12 @@
         SynthContext context = getContext(p, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
     private void updateStyle(JPanel c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -154,7 +152,6 @@
         context.getPainter().paintPanelBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -171,7 +168,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -77,7 +77,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -97,7 +96,6 @@
         SynthContext context = getContext(popupMenu, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         if (popupMenu.getLayout() instanceof UIResource) {
@@ -150,7 +148,6 @@
         context.getPainter().paintPopupMenuBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -167,7 +164,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -118,7 +118,6 @@
         }
         minBarSize = (Dimension)style.get(context, "ProgressBar.minBarSize");
         glowWidth = style.getInt(context, "ProgressBar.glowWidth", 0);
-        context.dispose();
     }
 
     /**
@@ -129,7 +128,6 @@
         SynthContext context = getContext(progressBar, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -160,7 +158,6 @@
             SynthContext context = getContext(c);
             Font font = context.getStyle().getFont(context);
             FontMetrics metrics = progressBar.getFontMetrics(font);
-            context.dispose();
             return (height - metrics.getAscent() - metrics.getDescent()) / 2 +
                     metrics.getAscent();
         }
@@ -216,7 +213,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           progressBar.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -233,7 +229,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -67,7 +67,6 @@
         SynthContext context = getContext(root, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -97,7 +96,6 @@
                 installKeyboardActions((JRootPane)c);
             }
         }
-        context.dispose();
     }
 
     /**
@@ -120,7 +118,6 @@
         context.getPainter().paintRootPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -137,7 +134,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -129,15 +129,12 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
         context = getContext(c, Region.SCROLL_BAR_TRACK, ENABLED);
         trackStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(c, Region.SCROLL_BAR_THUMB, ENABLED);
         thumbStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -165,17 +162,14 @@
     protected void uninstallDefaults(){
         SynthContext context = getContext(scrollbar, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         context = getContext(scrollbar, Region.SCROLL_BAR_TRACK, ENABLED);
         trackStyle.uninstallDefaults(context);
-        context.dispose();
         trackStyle = null;
 
         context = getContext(scrollbar, Region.SCROLL_BAR_THUMB, ENABLED);
         thumbStyle.uninstallDefaults(context);
-        context.dispose();
         thumbStyle = null;
 
         super.uninstallDefaults();
@@ -222,7 +216,6 @@
         SynthContext context = getContext(scrollbar);
         boolean value = style.getBoolean(context,
                       "ScrollBar.allowsAbsolutePositioning", false);
-        context.dispose();
         return value;
     }
 
@@ -247,7 +240,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           scrollbar.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -264,7 +256,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -278,11 +269,9 @@
         SynthContext subcontext = getContext(scrollbar,
                                              Region.SCROLL_BAR_TRACK);
         paintTrack(subcontext, g, getTrackBounds());
-        subcontext.dispose();
 
         subcontext = getContext(scrollbar, Region.SCROLL_BAR_THUMB);
         paintThumb(subcontext, g, getThumbBounds());
-        subcontext.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -83,7 +83,6 @@
         context.getPainter().paintScrollPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -100,7 +99,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -150,7 +148,6 @@
                 installKeyboardActions(c);
             }
         }
-        context.dispose();
     }
 
     /**
@@ -178,7 +175,6 @@
         SynthContext context = getContext(c, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
 
         if (scrollpane.getViewportBorder() instanceof UIResource) {
             scrollpane.setViewportBorder(null);
@@ -254,7 +250,6 @@
             }
             context.getPainter().paintViewportBorder(context, g, x, y, width,
                                                      height);
-            context.dispose();
         }
 
         @Override
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -106,7 +106,6 @@
             }
         }
 
-        context.dispose();
     }
 
     /**
@@ -120,7 +119,6 @@
         SynthContext context = getContext(c, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -168,7 +166,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           separator.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -185,7 +182,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -231,7 +227,6 @@
             size = new Dimension(insets.left + insets.right,
                                  insets.top + insets.bottom + thickness);
         }
-        context.dispose();
         return size;
     }
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -116,17 +116,14 @@
     protected void uninstallDefaults(JSlider slider) {
         SynthContext context = getContext(slider, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         context = getContext(slider, Region.SLIDER_TRACK, ENABLED);
         sliderTrackStyle.uninstallDefaults(context);
-        context.dispose();
         sliderTrackStyle = null;
 
         context = getContext(slider, Region.SLIDER_THUMB, ENABLED);
         sliderThumbStyle.uninstallDefaults(context);
-        context.dispose();
         sliderThumbStyle = null;
     }
 
@@ -190,17 +187,14 @@
                 installKeyboardActions(c);
             }
         }
-        context.dispose();
 
         context = getContext(c, Region.SLIDER_TRACK, ENABLED);
         sliderTrackStyle =
             SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(c, Region.SLIDER_THUMB, ENABLED);
         sliderThumbStyle =
             SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -252,14 +246,12 @@
             SynthContext trackContext = getContext(slider,
                                                    Region.SLIDER_TRACK);
             style.getInsets(trackContext, trackInsets);
-            trackContext.dispose();
             if (slider.getOrientation() == JSlider.HORIZONTAL) {
                 int valueHeight = 0;
                 if (paintValue) {
                     SynthContext context = getContext(slider);
                     valueHeight = context.getStyle().getGraphicsUtils(context).
                             getMaximumCharHeight(context);
-                    context.dispose();
                 }
                 int tickHeight = 0;
                 if (slider.getPaintTicks()) {
@@ -287,7 +279,6 @@
                         SynthContext context = getContext(slider);
                         valueHeight = context.getStyle().getGraphicsUtils(
                                 context).getMaximumCharHeight(context);
-                        context.dispose();
                     }
                     int contentHeight = height - insetCache.top -
                             insetCache.bottom;
@@ -359,7 +350,6 @@
         Insets trackInsets = new Insets(0, 0, 0, 0);
         SynthContext trackContext = getContext(slider, Region.SLIDER_TRACK);
         style.getInsets(trackContext, trackInsets);
-        trackContext.dispose();
 
         if (slider.getOrientation() == JSlider.HORIZONTAL) {
             // Calculate the height of all the subcomponents so we can center
@@ -509,7 +499,6 @@
                 trackRect.x = startX + tickRect.width + trackInsets.left;
             }
         }
-        context.dispose();
         lastSize = slider.getSize();
     }
 
@@ -715,7 +704,6 @@
             insetCache = newInsets;
             calculateGeometry();
         }
-        context.dispose();
     }
 
     /**
@@ -774,7 +762,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           slider.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -790,7 +777,6 @@
     public void paint(Graphics g, JComponent c) {
         SynthContext context = getContext(c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -835,13 +821,11 @@
         if (slider.getPaintTrack() && clip.intersects(trackRect)) {
             SynthContext subcontext = getContext(slider, Region.SLIDER_TRACK);
             paintTrack(subcontext, g, trackRect);
-            subcontext.dispose();
         }
 
         if (clip.intersects(thumbRect)) {
             SynthContext subcontext = getContext(slider, Region.SLIDER_THUMB);
             paintThumb(subcontext, g, thumbRect);
-            subcontext.dispose();
         }
 
         if (slider.getPaintTicks() && clip.intersects(tickRect)) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -131,7 +131,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
 
@@ -151,7 +150,6 @@
         SynthContext context = getContext(spinner, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -301,7 +299,6 @@
         context.getPainter().paintSpinnerBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
 
@@ -319,7 +316,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java	Mon Apr 25 09:25:26 2016 -0700
@@ -81,7 +81,6 @@
 
         context.getPainter().paintSplitPaneDividerForeground(context, g, 0, 0,
                 getWidth(), getHeight(), splitPane.getOrientation());
-        context.dispose();
 
         // super.paint(g2);
         for (int counter = 0; counter < getComponentCount(); counter++) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -121,7 +121,6 @@
                                           ENABLED);
         SynthStyle oldDividerStyle = dividerStyle;
         dividerStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(splitPane, ENABLED);
         SynthStyle oldStyle = style;
@@ -160,7 +159,6 @@
             divider.setBasicSplitPaneUI(this);
             splitPane.add(divider, JSplitPane.DIVIDER);
         }
-        context.dispose();
     }
 
     /**
@@ -180,12 +178,10 @@
         SynthContext context = getContext(splitPane, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER, ENABLED);
         dividerStyle.uninstallDefaults(context);
-        context.dispose();
         dividerStyle = null;
 
         super.uninstallDefaults();
@@ -287,7 +283,6 @@
         context.getPainter().paintSplitPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -304,7 +299,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -338,7 +332,6 @@
         context.getPainter().paintSplitPaneDragDivider(context, g, x, y, w, h,
                                            splitPane.getOrientation());
         g.setClip(oldClip);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -154,27 +154,17 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
-        if (tabContext != null) {
-            tabContext.dispose();
-        }
         tabContext = getContext(c, Region.TABBED_PANE_TAB, ENABLED);
         this.tabStyle = SynthLookAndFeel.updateStyle(tabContext, this);
         tabInsets = tabStyle.getInsets(tabContext, null);
 
 
-        if (tabAreaContext != null) {
-            tabAreaContext.dispose();
-        }
         tabAreaContext = getContext(c, Region.TABBED_PANE_TAB_AREA, ENABLED);
         this.tabAreaStyle = SynthLookAndFeel.updateStyle(tabAreaContext, this);
         tabAreaInsets = tabAreaStyle.getInsets(tabAreaContext, null);
 
 
-        if (tabContentContext != null) {
-            tabContentContext.dispose();
-        }
         tabContentContext = getContext(c, Region.TABBED_PANE_CONTENT, ENABLED);
         this.tabContentStyle = SynthLookAndFeel.updateStyle(tabContentContext,
                                                             this);
@@ -207,21 +197,17 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(tabPane, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         tabStyle.uninstallDefaults(tabContext);
-        tabContext.dispose();
         tabContext = null;
         tabStyle = null;
 
         tabAreaStyle.uninstallDefaults(tabAreaContext);
-        tabAreaContext.dispose();
         tabAreaContext = null;
         tabAreaStyle = null;
 
         tabContentStyle.uninstallDefaults(tabContentContext);
-        tabContentContext.dispose();
         tabContentContext = null;
         tabContentStyle = null;
     }
@@ -374,7 +360,6 @@
         context.getPainter().paintTabbedPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -424,7 +409,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -85,7 +85,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -109,7 +108,6 @@
         SynthContext context = getContext(header, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -142,7 +140,6 @@
         context.getPainter().paintTableHeaderBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -159,7 +156,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -189,7 +189,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -220,7 +219,6 @@
         }
         SynthContext context = getContext(table, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -273,7 +271,6 @@
         context.getPainter().paintTableBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -299,7 +296,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -88,7 +88,6 @@
         getComponent().removeFocusListener(handler);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         super.uninstallDefaults();
     }
@@ -107,7 +106,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -142,7 +140,6 @@
         context.getPainter().paintTextAreaBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -79,7 +79,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     static void updateStyle(JTextComponent comp, SynthContext context,
@@ -179,7 +178,6 @@
         SynthLookAndFeel.update(context, g);
         paintBackground(context, g, c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -262,7 +260,6 @@
         getComponent().removeFocusListener(handler);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         super.uninstallDefaults();
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -98,11 +98,9 @@
         SynthContext context = getContext(
                 c, Region.TOOL_BAR_CONTENT, null, ENABLED);
         contentStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(c, Region.TOOL_BAR_DRAG_WINDOW, null, ENABLED);
         dragWindowStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(c, ENABLED);
         SynthStyle oldStyle = style;
@@ -116,7 +114,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -127,7 +124,6 @@
         SynthContext context = getContext(toolBar, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         handleIcon = null;
@@ -135,13 +131,11 @@
         context = getContext(toolBar, Region.TOOL_BAR_CONTENT,
                              contentStyle, ENABLED);
         contentStyle.uninstallDefaults(context);
-        context.dispose();
         contentStyle = null;
 
         context = getContext(toolBar, Region.TOOL_BAR_DRAG_WINDOW,
                              dragWindowStyle, ENABLED);
         dragWindowStyle.uninstallDefaults(context);
-        context.dispose();
         dragWindowStyle = null;
 
         toolBar.setLayout(null);
@@ -215,7 +209,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           toolBar.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -232,7 +225,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -289,7 +281,6 @@
         SynthContext subcontext = getContext(
                 toolBar, Region.TOOL_BAR_CONTENT, contentStyle);
         paintContent(subcontext, g, contentRect);
-        subcontext.dispose();
     }
 
     /**
@@ -326,7 +317,6 @@
                                                            dragWindow.getOrientation());
         context.getPainter().paintToolBarDragWindowBorder(context, g, 0, 0, w, h,
                                                           dragWindow.getOrientation());
-        context.dispose();
     }
 
     //
@@ -383,7 +373,6 @@
             dim.width += insets.left + insets.right;
             dim.height += insets.top + insets.bottom;
 
-            context.dispose();
             return dim;
         }
 
@@ -421,7 +410,6 @@
             dim.width += insets.left + insets.right;
             dim.height += insets.top + insets.bottom;
 
-            context.dispose();
             return dim;
         }
 
@@ -543,7 +531,6 @@
                     }
                 }
             }
-            context.dispose();
         }
 
         private boolean isGlue(Component c) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -68,7 +68,6 @@
     private void updateStyle(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -78,7 +77,6 @@
     protected void uninstallDefaults(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -139,7 +137,6 @@
         context.getPainter().paintToolTipBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -165,7 +162,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -218,7 +214,6 @@
                 prefSize.height += fm.getHeight();
             }
         }
-        context.dispose();
         return prefSize;
     }
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -147,11 +147,9 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
         context = getContext(tree, Region.TREE_CELL, ENABLED);
         cellStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -223,12 +221,10 @@
         SynthContext context = getContext(tree, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         context = getContext(tree, Region.TREE_CELL, ENABLED);
         cellStyle.uninstallDefaults(context);
-        context.dispose();
         cellStyle = null;
 
 
@@ -266,7 +262,6 @@
         context.getPainter().paintTreeBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -292,7 +287,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -425,7 +419,6 @@
                 row++;
             }
         }
-        cellContext.dispose();
 
         paintDropLine(g);
 
@@ -743,7 +736,6 @@
                     context.getPainter().paintTreeCellFocus(context, g,
                             0, 0, getWidth() - imageOffset, getHeight());
                 }
-                context.dispose();
             }
             SynthLookAndFeel.resetSelectedUI();
         }
@@ -785,7 +777,6 @@
             if (context == null) {
                 context = getContext(tree);
                 SynthGraphicsUtils.paintIcon(expandedIcon, context, g, x, y, w, h);
-                context.dispose();
             }
             else {
                 SynthGraphicsUtils.paintIcon(expandedIcon, context, g, x, y, w, h);
@@ -797,7 +788,6 @@
             if (context == null) {
                 context = getContext(tree);
                 width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
-                context.dispose();
             }
             else {
                 width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
@@ -810,7 +800,6 @@
             if (context == null) {
                 context = getContext(tree);
                 height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
-                context.dispose();
             }
             else {
                 height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java	Mon Apr 25 09:25:26 2016 -0700
@@ -99,7 +99,6 @@
             newStyle.installDefaults(context);
         }
         this.style = newStyle;
-        context.dispose();
     }
 
     /**
@@ -128,7 +127,6 @@
     protected void uninstallDefaults(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -168,7 +166,6 @@
         context.getPainter().paintViewportBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -202,7 +199,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, 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
@@ -29,6 +29,7 @@
 
 import javax.accessibility.AccessibleContext;
 import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
 import java.awt.dnd.DragSourceContext;
 import java.awt.dnd.DropTargetContext;
 import java.awt.dnd.peer.DragSourceContextPeer;
@@ -104,7 +105,7 @@
         /*
          * Requests focus to the component.
          */
-        boolean requestFocus(Component comp, CausedFocusEvent.Cause cause);
+        boolean requestFocus(Component comp, Cause cause);
         /*
          * Determines if the component can gain focus.
          */
@@ -438,7 +439,7 @@
                                            boolean temporary,
                                            boolean focusedWindowChangeAllowed,
                                            long time,
-                                           CausedFocusEvent.Cause cause);
+                                           Cause cause);
         /**
          * Delivers focus for the lightweight descendant of the heavyweight
          * synchronously.
--- a/jdk/src/java.desktop/share/classes/sun/awt/CausedFocusEvent.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/awt/CausedFocusEvent.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, 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
@@ -27,17 +27,18 @@
 
 import java.awt.event.FocusEvent;
 import java.awt.Component;
+import java.io.ObjectStreamException;
+import java.lang.reflect.Field;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /**
- * This class represents FocusEvents with a known "cause" - reason why this event happened. It can
- * be mouse press, traversal, activation, and so on - all causes are described as Cause enum. The
- * event with the cause can be constructed in two ways - explicitly through constructor of
- * CausedFocusEvent class or implicitly, by calling appropriate requestFocusXXX method with "cause"
- * parameter. The default cause is UNKNOWN.
+ * This class exists for deserialization compatibility only.
  */
-@SuppressWarnings("serial")
-public class CausedFocusEvent extends FocusEvent {
-    public enum Cause {
+class CausedFocusEvent extends FocusEvent {
+    private static final long serialVersionUID = -3647309088427840738L;
+
+    private enum Cause {
         UNKNOWN,
         MOUSE_EVENT,
         TRAVERSAL,
@@ -51,39 +52,82 @@
         NATIVE_SYSTEM,
         ACTIVATION,
         CLEAR_GLOBAL_FOCUS_OWNER,
-        RETARGETED
+        RETARGETED;
     };
 
+    @SuppressWarnings("serial")
+    private static final Component dummy = new Component(){};
+
     private final Cause cause;
 
-    public Cause getCause() {
-        return cause;
-    }
-
-    public String toString() {
-        return "java.awt.FocusEvent[" + super.paramString() + ",cause=" + cause + "] on " + getSource();
-    }
-
-    public CausedFocusEvent(Component source, int id, boolean temporary,
+    private CausedFocusEvent(Component source, int id, boolean temporary,
                             Component opposite, Cause cause) {
         super(source, id, temporary, opposite);
-        if (cause == null) {
-            cause = Cause.UNKNOWN;
-        }
-        this.cause = cause;
+        throw new IllegalStateException();
     }
 
-    /**
-     * Retargets the original focus event to the new target.  If the
-     * original focus event is CausedFocusEvent, it remains such and
-     * cause is copied.  Otherwise, new CausedFocusEvent is created,
-     * with cause as RETARGETED.
-     * @return retargeted event, or null if e is null
-     */
-    public static FocusEvent retarget(FocusEvent e, Component newSource) {
-        if (e == null) return null;
+    Object readResolve() throws ObjectStreamException {
+        FocusEvent.Cause newCause;
+        switch (cause) {
+            case UNKNOWN:
+                newCause = FocusEvent.Cause.UNKNOWN;
+                break;
+            case MOUSE_EVENT:
+                newCause = FocusEvent.Cause.MOUSE_EVENT;
+                break;
+            case TRAVERSAL:
+                newCause = FocusEvent.Cause.TRAVERSAL;
+                break;
+            case TRAVERSAL_UP:
+                newCause = FocusEvent.Cause.TRAVERSAL_UP;
+                break;
+            case TRAVERSAL_DOWN:
+                newCause = FocusEvent.Cause.TRAVERSAL_DOWN;
+                break;
+            case TRAVERSAL_FORWARD:
+                newCause = FocusEvent.Cause.TRAVERSAL_FORWARD;
+                break;
+            case TRAVERSAL_BACKWARD:
+                newCause = FocusEvent.Cause.TRAVERSAL_BACKWARD;
+                break;
+            case ROLLBACK:
+                newCause = FocusEvent.Cause.ROLLBACK;
+                break;
+            case NATIVE_SYSTEM:
+                newCause = FocusEvent.Cause.UNEXPECTED;
+                break;
+            case ACTIVATION:
+                newCause = FocusEvent.Cause.ACTIVATION;
+                break;
+            case CLEAR_GLOBAL_FOCUS_OWNER:
+                newCause = FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER;
+                break;
+            default:
+                newCause = FocusEvent.Cause.UNKNOWN;
+        }
 
-        return new CausedFocusEvent(newSource, e.getID(), e.isTemporary(), e.getOppositeComponent(),
-                                    (e instanceof CausedFocusEvent) ? ((CausedFocusEvent)e).getCause() : Cause.RETARGETED);
+        FocusEvent focusEvent = new FocusEvent(dummy, getID(), isTemporary(),
+                        getOppositeComponent(), newCause);
+        focusEvent.setSource(null);
+        try {
+            final Field consumedField = FocusEvent.class.getField("consumed");
+            AccessController.doPrivileged(new PrivilegedAction<Object>() {
+                @Override
+                public Object run() {
+                    consumedField.setAccessible(true);
+                    try {
+                        consumedField.set(focusEvent, consumed);
+                    } catch (IllegalAccessException e) {
+                    }
+                    return null;
+                }
+            });
+        } catch (NoSuchFieldException e) {
+        }
+
+        AWTAccessor.AWTEventAccessor accessor =
+                                           AWTAccessor.getAWTEventAccessor();
+        accessor.setBData(focusEvent, accessor.getBData(this));
+        return focusEvent;
     }
 }
--- a/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, 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
@@ -60,8 +60,8 @@
                 focusLog.fine("Clearing global focus owner " + focusOwner);
             }
             if (focusOwner != null) {
-                FocusEvent fl = new CausedFocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
-                                                     CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
+                FocusEvent fl = new FocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
+                                                     FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
                 SunToolkit.postPriorityEvent(fl);
             }
         }
@@ -110,7 +110,7 @@
                                        boolean temporary,
                                        boolean focusedWindowChangeAllowed,
                                        long time,
-                                       CausedFocusEvent.Cause cause,
+                                       FocusEvent.Cause cause,
                                        Component currentFocusOwner) // provided by the descendant peers
     {
         if (lightweightChild == null) {
@@ -122,7 +122,7 @@
             currentOwner = null;
         }
         if (currentOwner != null) {
-            FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
+            FocusEvent fl = new FocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
                                                  false, lightweightChild, cause);
 
             if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
@@ -131,7 +131,7 @@
             SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl);
         }
 
-        FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
+        FocusEvent fg = new FocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
                                              false, currentOwner, cause);
 
         if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
@@ -142,7 +142,7 @@
     }
 
     // WARNING: Don't call it on the Toolkit thread.
-    public static boolean requestFocusFor(Component target, CausedFocusEvent.Cause cause) {
+    public static boolean requestFocusFor(Component target, FocusEvent.Cause cause) {
         return AWTAccessor.getComponentAccessor().requestFocus(target, cause);
     }
 
@@ -152,7 +152,7 @@
                                                      boolean temporary,
                                                      boolean focusedWindowChangeAllowed,
                                                      long time,
-                                                     CausedFocusEvent.Cause cause)
+                                                     FocusEvent.Cause cause)
     {
         return KfmAccessor.instance.shouldNativelyFocusHeavyweight(
             heavyweight, descendant, temporary, focusedWindowChangeAllowed,
--- a/jdk/src/java.desktop/share/classes/sun/awt/NullComponentPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/awt/NullComponentPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -37,7 +37,7 @@
 import java.awt.GraphicsConfiguration;
 import java.awt.Image;
 import java.awt.Insets;
-import java.awt.MenuBar;
+import java.awt.event.FocusEvent.Cause;
 import java.awt.Point;
 import java.awt.Event;
 import java.awt.event.PaintEvent;
@@ -178,7 +178,7 @@
 
     public boolean requestFocus
         (Component lightweightChild, boolean temporary,
-         boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause) {
+         boolean focusedWindowChangeAllowed, long time, Cause cause) {
         return false;
     }
 
--- a/jdk/src/java.desktop/share/classes/sun/awt/RequestFocusController.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/awt/RequestFocusController.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -25,10 +25,11 @@
 package sun.awt;
 
 import java.awt.Component;
+import java.awt.event.FocusEvent.Cause;
 
 public interface RequestFocusController
 {
     public boolean acceptRequestFocus(Component from, Component to,
                                       boolean temporary, boolean focusedWindowChangeAllowed,
-                                      CausedFocusEvent.Cause cause);
+                                      Cause cause);
 }
--- a/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1843,7 +1843,7 @@
 
     private PhysicalFont registerFontFile(String file) {
         if (new File(file).isAbsolute() &&
-            !registeredFonts.contains(file)) {
+            !registeredFonts.containsKey(file)) {
             int fontFormat = FONTFORMAT_NONE;
             int fontRank = Font2D.UNKNOWN_RANK;
             if (ttFilter.accept(null, file)) {
--- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1388,6 +1388,8 @@
         Doc doc = new PageableDoc(getPageable());
         if (attributes == null) {
             attributes = new HashPrintRequestAttributeSet();
+            attributes.add(new Copies(getCopies()));
+            attributes.add(new JobName(getJobName(), null));
         }
         try {
             job.print(doc, attributes);
--- a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1422,13 +1422,13 @@
             topMargin.addActionListener(this);
             topMargin.getAccessibleContext().setAccessibleName(
                                               getMsg("label.topmargin"));
-            topMargin = new JFormattedTextField(nf);
+
             bottomMargin = new JFormattedTextField(nf);
             bottomMargin.addFocusListener(this);
             bottomMargin.addActionListener(this);
             bottomMargin.getAccessibleContext().setAccessibleName(
                                               getMsg("label.bottommargin"));
-            topMargin = new JFormattedTextField(nf);
+
             c.gridwidth = GridBagConstraints.RELATIVE;
             lblLeft = new JLabel(getMsg("label.leftmargin") + " " + unitsMsg,
                                  JLabel.LEADING);
--- a/jdk/src/java.desktop/share/classes/sun/swing/StringUIClientPropertyKey.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/swing/StringUIClientPropertyKey.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -25,6 +25,8 @@
 
 package sun.swing;
 
+import javax.swing.UIClientPropertyKey;
+
 /**
  * An implementation of {@code UIClientPropertyKey} that wraps a {@code String}.
  *
--- a/jdk/src/java.desktop/share/classes/sun/swing/UIClientPropertyKey.java	Wed Jul 05 21:38:12 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2006, 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.swing;
-
-/**
- * This interface is used only for tagging keys for client properties
- * for {@code JComponent} set by UI which needs to be cleared on {@literal L&F}
- * change and serialization.
- *
- * All such keys are removed from client properties in {@code
- * JComponent.setUI()} method after uninstalling old UI and before
- * intalling the new one. They are also removed prior to serialization.
- *
- * @author Igor Kushnirskiy
- */
-public interface UIClientPropertyKey {
-}
--- a/jdk/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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,9 +29,12 @@
 import java.awt.color.ColorSpace;
 import java.awt.image.*;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 import sun.security.action.GetIntegerAction;
 import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection;
 import sun.java2d.opengl.OGLRenderQueue;
+import sun.security.action.GetPropertyAction;
 
 public abstract class UNIXToolkit extends SunToolkit
 {
@@ -42,6 +45,40 @@
     private static final int[] BAND_OFFSETS_ALPHA = { 0, 1, 2, 3 };
     private static final int DEFAULT_DATATRANSFER_TIMEOUT = 10000;
 
+    // Allowed GTK versions
+    public enum GtkVersions {
+        ANY(0),
+        GTK2(Constants.GTK2_MAJOR_NUMBER),
+        GTK3(Constants.GTK3_MAJOR_NUMBER);
+
+        static class Constants {
+            static final int GTK2_MAJOR_NUMBER = 2;
+            static final int GTK3_MAJOR_NUMBER = 3;
+        }
+
+        final int number;
+
+        GtkVersions(int number) {
+            this.number = number;
+        }
+
+        public static GtkVersions getVersion(int number) {
+            switch (number) {
+                case Constants.GTK2_MAJOR_NUMBER:
+                    return GTK2;
+                case Constants.GTK3_MAJOR_NUMBER:
+                    return GTK3;
+                default:
+                    return ANY;
+            }
+        }
+
+        // major GTK version number
+        public int getNumber() {
+            return number;
+        }
+    };
+
     private Boolean nativeGTKAvailable;
     private Boolean nativeGTKLoaded;
     private BufferedImage tmpImage = null;
@@ -79,7 +116,7 @@
                 return nativeGTKAvailable;
 
             } else {
-                boolean success = check_gtk();
+                boolean success = check_gtk(getEnabledGtkVersion().getNumber());
                 nativeGTKAvailable = success;
                 return success;
             }
@@ -97,7 +134,8 @@
     public boolean loadGTK() {
         synchronized (GTK_LOCK) {
             if (nativeGTKLoaded == null) {
-                nativeGTKLoaded = load_gtk();
+                nativeGTKLoaded = load_gtk(getEnabledGtkVersion().getNumber(),
+                                                                isGtkVerbose());
             }
         }
         return nativeGTKLoaded;
@@ -241,14 +279,15 @@
         tmpImage = new BufferedImage(colorModel, raster, false, null);
     }
 
-    private static native boolean check_gtk();
-    private static native boolean load_gtk();
+    private static native boolean check_gtk(int version);
+    private static native boolean load_gtk(int version, boolean verbose);
     private static native boolean unload_gtk();
     private native boolean load_gtk_icon(String filename);
     private native boolean load_stock_icon(int widget_type, String stock_id,
             int iconSize, int textDirection, String detail);
 
     private native void nativeSync();
+    private static native int get_gtk_version();
 
     @Override
     public void sync() {
@@ -338,4 +377,26 @@
         }
         return false;
     }
+
+    public static GtkVersions getEnabledGtkVersion() {
+        String version = AccessController.doPrivileged(
+                new GetPropertyAction("jdk.gtk.version"));
+        if (version == null) {
+            return GtkVersions.ANY;
+        } else if (version.startsWith("2")) {
+            return GtkVersions.GTK2;
+        } else if("3".equals(version) ){
+            return GtkVersions.GTK3;
+        }
+        return GtkVersions.ANY;
+    }
+
+    public static GtkVersions getGtkVersion() {
+        return GtkVersions.getVersion(get_gtk_version());
+    }
+
+    public static boolean isGtkVerbose() {
+        return AccessController.doPrivileged((PrivilegedAction<Boolean>)()
+                -> Boolean.getBoolean("jdk.gtk.verbose"));
+    }
 }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, 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
@@ -287,7 +287,7 @@
     @SuppressWarnings("deprecation")
     public final boolean requestFocus(Component lightweightChild, boolean temporary,
                                       boolean focusedWindowChangeAllowed, long time,
-                                      CausedFocusEvent.Cause cause)
+                                      FocusEvent.Cause cause)
     {
         if (XKeyboardFocusManagerPeer.
             processSynchronousLightweightTransfer(target, lightweightChild, temporary,
@@ -527,7 +527,7 @@
 //                       WindowEvent wfg = new WindowEvent(parentWindow, WindowEvent.WINDOW_GAINED_FOCUS);
 //                       parentWindow.dispatchEvent(wfg);
 //                   }
-                  XKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
+                  XKeyboardFocusManagerPeer.requestFocusFor(target, FocusEvent.Cause.MOUSE_EVENT);
               }
               break;
         }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDesktopPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDesktopPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,6 +26,8 @@
 package sun.awt.X11;
 
 
+import sun.awt.UNIXToolkit;
+
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -57,7 +59,8 @@
         XToolkit.awtLock();
         try {
             if (!initExecuted) {
-                nativeLibraryLoaded = init();
+                nativeLibraryLoaded = init(UNIXToolkit.getEnabledGtkVersion()
+                        .ordinal(), UNIXToolkit.isGtkVerbose());
             }
         } finally {
             initExecuted = true;
@@ -123,5 +126,5 @@
     }
 
     private native boolean gnome_url_show(byte[] url);
-    private static native boolean init();
+    private static native boolean init(int gtkVersion, boolean verbose);
 }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java	Mon Apr 25 09:25:26 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
@@ -430,13 +430,10 @@
         if (isXEmbedActive()) {
             xembedLog.fine("Forwarding FOCUS_GAINED");
             int flavor = XEMBED_FOCUS_CURRENT;
-            if (e instanceof CausedFocusEvent) {
-                CausedFocusEvent ce = (CausedFocusEvent)e;
-                if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_FORWARD) {
-                    flavor = XEMBED_FOCUS_FIRST;
-                } else if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_BACKWARD) {
-                    flavor = XEMBED_FOCUS_LAST;
-                }
+            if (e.getCause() == FocusEvent.Cause.TRAVERSAL_FORWARD) {
+                flavor = XEMBED_FOCUS_FIRST;
+            } else if (e.getCause() == FocusEvent.Cause.TRAVERSAL_BACKWARD) {
+                flavor = XEMBED_FOCUS_LAST;
             }
             xembed.sendMessage(xembed.handle, XEMBED_FOCUS_IN, flavor, 0, 0);
         }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, 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
@@ -195,7 +195,7 @@
                                 boolean temporary,
                                 boolean focusedWindowChangeAllowed,
                                 long time,
-                                CausedFocusEvent.Cause cause)
+                                FocusEvent.Cause cause)
     {
         int result = XKeyboardFocusManagerPeer
             .shouldNativelyFocusHeavyweight(proxy, lightweightChild,
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, 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
@@ -28,7 +28,7 @@
 import java.awt.Window;
 
 import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent;
 import sun.awt.KeyboardFocusManagerPeerImpl;
 import sun.util.logging.PlatformLogger;
 
@@ -101,7 +101,7 @@
                                        boolean temporary,
                                        boolean focusedWindowChangeAllowed,
                                        long time,
-                                       CausedFocusEvent.Cause cause)
+                                       FocusEvent.Cause cause)
     {
         return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
                                                          target,
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -29,6 +29,8 @@
 import java.awt.Taskbar.Feature;
 import java.awt.peer.TaskbarPeer;
 import java.awt.event.ActionEvent;
+
+import sun.awt.UNIXToolkit;
 import java.security.AccessController;
 import sun.security.action.GetPropertyAction;
 
@@ -45,7 +47,9 @@
             if (!initExecuted) {
                 String dname = AccessController.doPrivileged(
                                 new GetPropertyAction("java.desktop.appName", ""));
-                nativeLibraryLoaded = init(dname);
+                nativeLibraryLoaded = init(dname,
+                        UNIXToolkit.getEnabledGtkVersion().ordinal(),
+                        UNIXToolkit.isGtkVerbose());
                 if (nativeLibraryLoaded) {
                     Thread t = new Thread(null, () -> { runloop(); },
                                           "TaskBar", 0, false);
@@ -147,7 +151,8 @@
         }
     }
 
-    private static native boolean init(String name);
+    private static native boolean init(String name, int version,
+                                                               boolean verbose);
 
     private static native void runloop();
 
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextAreaPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextAreaPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, 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
@@ -59,7 +59,6 @@
 
 import javax.swing.plaf.BorderUIResource;
 import java.awt.im.InputMethodRequests;
-import sun.awt.CausedFocusEvent;
 import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
 
@@ -945,14 +944,16 @@
 
         void forwardFocusGained( FocusEvent e) {
             isFocused = true;
-            FocusEvent fe = CausedFocusEvent.retarget(e, this);
+            FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
+                    e.getOppositeComponent(), e.getCause());
             super.processFocusEvent(fe);
         }
 
 
         void forwardFocusLost( FocusEvent e) {
             isFocused = false;
-            FocusEvent fe = CausedFocusEvent.retarget(e, this);
+            FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
+                    e.getOppositeComponent(), e.getCause());
             super.processFocusEvent(fe);
         }
 
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, 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
@@ -54,7 +54,6 @@
 
 import sun.util.logging.PlatformLogger;
 
-import sun.awt.CausedFocusEvent;
 import sun.awt.AWTAccessor;
 
 final class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
@@ -618,13 +617,15 @@
 
         void forwardFocusGained( FocusEvent e) {
             isFocused = true;
-            FocusEvent fe = CausedFocusEvent.retarget(e, this);
+            FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
+                    e.getOppositeComponent(), e.getCause());
             super.processFocusEvent(fe);
         }
 
         void forwardFocusLost( FocusEvent e) {
             isFocused = false;
-            FocusEvent fe = CausedFocusEvent.retarget(e, this);
+            FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
+                    e.getOppositeComponent(), e.getCause());
             super.processFocusEvent(fe);
 
         }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1144,7 +1144,8 @@
     public FileDialogPeer createFileDialog(FileDialog target) {
         FileDialogPeer peer = null;
         // The current GtkFileChooser is available from GTK+ 2.4
-        if (!getSunAwtDisableGtkFileDialogs() && checkGtkVersion(2, 4, 0)) {
+        if (!getSunAwtDisableGtkFileDialogs() &&
+                      (checkGtkVersion(2, 4, 0) || checkGtkVersion(3, 0, 0))) {
             peer = new GtkFileDialogPeer(target);
         } else {
             peer = new XFileDialogPeer(target);
--- a/jdk/src/java.desktop/unix/native/common/awt/awt.h	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/common/awt/awt.h	Mon Apr 25 09:25:26 2016 -0700
@@ -35,7 +35,9 @@
 #include "debug_util.h"
 
 #if !defined(HEADLESS) && !defined(MACOSX)
-#include <X11/Intrinsic.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+typedef char Boolean;
 #endif /* !HEADLESS && !MACOSX */
 
 
--- a/jdk/src/java.desktop/unix/native/common/awt/awt_p.h	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/common/awt/awt_p.h	Mon Apr 25 09:25:26 2016 -0700
@@ -41,13 +41,6 @@
 #include <string.h>
 #include <unistd.h>
 #ifndef HEADLESS
-#include <X11/Intrinsic.h>
-#include <X11/IntrinsicP.h>
-#include <X11/Shell.h>
-#include <X11/StringDefs.h>
-#include <X11/Xatom.h>
-#include <X11/keysym.h>
-#include <X11/keysymdef.h>
 #include <X11/extensions/Xrender.h>
 #endif /* !HEADLESS */
 #include "awt.h"
--- a/jdk/src/java.desktop/unix/native/common/awt/extutil.h	Wed Jul 05 21:38:12 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * $Xorg: extutil.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
- *
-Copyright 1989, 1998  The Open Group
-
-All Rights Reserved.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
- *
- * Author:  Jim Fulton, MIT The Open Group
- *
- *                     Xlib Extension-Writing Utilities
- *
- * This package contains utilities for writing the client API for various
- * protocol extensions.  THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
- * ARE SUBJECT TO CHANGE!
- */
-/* $XFree86: xc/include/extensions/extutil.h,v 1.5 2001/01/17 17:53:20 dawes Exp $ */
-
-#if defined(__linux__) || defined(MACOSX)
-
-#ifndef _EXTUTIL_H_
-#define _EXTUTIL_H_
-
-/*
- * We need to keep a list of open displays since the Xlib display list isn't
- * public.  We also have to per-display info in a separate block since it isn't
- * stored directly in the Display structure.
- */
-typedef struct _XExtDisplayInfo {
-    struct _XExtDisplayInfo *next;      /* keep a linked list */
-    Display *display;                   /* which display this is */
-    XExtCodes *codes;                   /* the extension protocol codes */
-    XPointer data;                      /* extra data for extension to use */
-} XExtDisplayInfo;
-
-typedef struct _XExtensionInfo {
-    XExtDisplayInfo *head;              /* start of list */
-    XExtDisplayInfo *cur;               /* most recently used */
-    int ndisplays;                      /* number of displays */
-} XExtensionInfo;
-
-typedef struct _XExtensionHooks {
-    int (*create_gc)(
-#if NeedNestedPrototypes
-              Display*                  /* display */,
-              GC                        /* gc */,
-              XExtCodes*                /* codes */
-#endif
-);
-    int (*copy_gc)(
-#if NeedNestedPrototypes
-              Display*                  /* display */,
-              GC                        /* gc */,
-              XExtCodes*                /* codes */
-#endif
-);
-    int (*flush_gc)(
-#if NeedNestedPrototypes
-              Display*                  /* display */,
-              GC                        /* gc */,
-              XExtCodes*                /* codes */
-#endif
-);
-    int (*free_gc)(
-#if NeedNestedPrototypes
-              Display*                  /* display */,
-              GC                        /* gc */,
-              XExtCodes*                /* codes */
-#endif
-);
-    int (*create_font)(
-#if NeedNestedPrototypes
-              Display*                  /* display */,
-              XFontStruct*              /* fs */,
-              XExtCodes*                /* codes */
-#endif
-);
-    int (*free_font)(
-#if NeedNestedPrototypes
-              Display*                  /* display */,
-              XFontStruct*              /* fs */,
-              XExtCodes*                /* codes */
-#endif
-);
-    int (*close_display)(
-#if NeedNestedPrototypes
-              Display*                  /* display */,
-              XExtCodes*                /* codes */
-#endif
-);
-    Bool (*wire_to_event)(
-#if NeedNestedPrototypes
-               Display*                 /* display */,
-               XEvent*                  /* re */,
-               xEvent*                  /* event */
-#endif
-);
-    Status (*event_to_wire)(
-#if NeedNestedPrototypes
-              Display*                  /* display */,
-              XEvent*                   /* re */,
-              xEvent*                   /* event */
-#endif
-);
-    int (*error)(
-#if NeedNestedPrototypes
-              Display*                  /* display */,
-              xError*                   /* err */,
-              XExtCodes*                /* codes */,
-              int*                      /* ret_code */
-#endif
-);
-    char *(*error_string)(
-#if NeedNestedPrototypes
-                Display*                /* display */,
-                int                     /* code */,
-                XExtCodes*              /* codes */,
-                char*                   /* buffer */,
-                int                     /* nbytes */
-#endif
-);
-} XExtensionHooks;
-
-extern XExtensionInfo *XextCreateExtension(
-#if NeedFunctionPrototypes
-    void
-#endif
-);
-extern void XextDestroyExtension(
-#if NeedFunctionPrototypes
-    XExtensionInfo*     /* info */
-#endif
-);
-extern XExtDisplayInfo *XextAddDisplay(
-#if NeedFunctionPrototypes
-    XExtensionInfo*     /* extinfo */,
-    Display*            /* dpy */,
-    char*               /* ext_name */,
-    XExtensionHooks*    /* hooks */,
-    int                 /* nevents */,
-    XPointer            /* data */
-#endif
-);
-extern int XextRemoveDisplay(
-#if NeedFunctionPrototypes
-    XExtensionInfo*     /* extinfo */,
-    Display*            /* dpy */
-#endif
-);
-extern XExtDisplayInfo *XextFindDisplay(
-#if NeedFunctionPrototypes
-    XExtensionInfo*     /* extinfo */,
-    Display*            /* dpy */
-#endif
-);
-
-#define XextHasExtension(i) ((i) && ((i)->codes))
-#define XextCheckExtension(dpy,i,name,val) \
-  if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
-#define XextSimpleCheckExtension(dpy,i,name) \
-  if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
-
-
-/*
- * helper macros to generate code that is common to all extensions; caller
- * should prefix it with static if extension source is in one file; this
- * could be a utility function, but have to stack 6 unused arguments for
- * something that is called many, many times would be bad.
- */
-#define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
-XExtDisplayInfo *proc (Display *dpy) \
-{ \
-    XExtDisplayInfo *dpyinfo; \
-    if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
-    if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
-      dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
-    return dpyinfo; \
-}
-
-#define XEXT_FIND_DISPLAY_PROTO(proc) \
-        XExtDisplayInfo *proc(Display *dpy)
-
-#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
-int proc (Display *dpy, XExtCodes *codes) \
-{ \
-    return XextRemoveDisplay (extinfo, dpy); \
-}
-
-#define XEXT_CLOSE_DISPLAY_PROTO(proc) \
-        int proc(Display *dpy, XExtCodes *codes)
-
-#define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
-char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
-{  \
-    code -= codes->first_error;  \
-    if (code >= 0 && code < nerr) { \
-        char tmp[256]; \
-        sprintf (tmp, "%s.%d", extname, code); \
-        XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
-        return buf; \
-    } \
-    return (char *)0; \
-}
-
-#define XEXT_ERROR_STRING_PROTO(proc) \
-        char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
-#endif
-
-#endif /* __linux__ || MACOSX */
--- a/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c	Mon Apr 25 09:25:26 2016 -0700
@@ -270,7 +270,6 @@
     xsdo->sdOps.Dispose = X11SD_Dispose;
     xsdo->GetPixmapWithBg = X11SD_GetPixmapWithBg;
     xsdo->ReleasePixmapWithBg = X11SD_ReleasePixmapWithBg;
-    xsdo->widget = NULL;
     if (peer != NULL) {
         xsdo->drawable = JNU_CallMethodByName(env, &hasException, peer, "getWindow", "()J").j;
         if (hasException) {
@@ -1087,7 +1086,7 @@
 X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
                  X11SDOps *xsdo)
 {
-    Position x1=0, y1=0, x2=0, y2=0;
+    short x1=0, y1=0, x2=0, y2=0;
     int tmpx, tmpy;
     Window tmpchild;
 
--- a/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h	Mon Apr 25 09:25:26 2016 -0700
@@ -101,7 +101,6 @@
     jboolean            isPixmap;
     jobject             peer;
     Drawable            drawable;
-    Widget              widget;
     GC                  javaGC;        /* used for Java-level GC validation */
     GC                  cachedGC;      /* cached for use in X11SD_Unlock() */
     jint                depth;
--- a/jdk/src/java.desktop/unix/native/include/jawt_md.h	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/include/jawt_md.h	Mon Apr 25 09:25:26 2016 -0700
@@ -28,7 +28,6 @@
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
-#include <X11/Intrinsic.h>
 #include "jawt.h"
 
 #ifdef __cplusplus
--- a/jdk/src/java.desktop/unix/native/libawt_headless/awt/VDrawingArea.c	Wed Jul 05 21:38:12 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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.
- */
-
-#ifndef HEADLESS
-
-#include <X11/IntrinsicP.h>
-#include "VDrawingAreaP.h"
-
-#endif /* !HEADLESS */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef __linux__
-/* XXX: Shouldn't be necessary. */
-#include "awt_p.h"
-#endif /* __linux__ */
-
-
-/******************************************************************
- *
- * Provides Canvas widget which allows the X11 visual to be
- * changed (the Motif DrawingArea restricts the visual to that
- * of the parent widget).
- *
- ******************************************************************/
-
-
-/******************************************************************
- *
- * VDrawingArea Widget Resources
- *
- ******************************************************************/
-
-#ifndef HEADLESS
-#define Offset(x)       (XtOffsetOf(VDrawingAreaRec, x))
-static XtResource resources[]=
-{
-        { XtNvisual, XtCVisual, XtRVisual, sizeof(Visual*),
-          Offset(vdrawing_area.visual), XtRImmediate, CopyFromParent}
-};
-
-
-static void Realize();
-static Boolean SetValues();
-static void Destroy ();
-
-static XmBaseClassExtRec baseClassExtRec = {
-    NULL,
-    NULLQUARK,
-    XmBaseClassExtVersion,
-    sizeof(XmBaseClassExtRec),
-    NULL,                               /* InitializePrehook    */
-    NULL,                               /* SetValuesPrehook     */
-    NULL,                               /* InitializePosthook   */
-    NULL,                               /* SetValuesPosthook    */
-    NULL,                               /* secondaryObjectClass */
-    NULL,                               /* secondaryCreate      */
-    NULL,                               /* getSecRes data       */
-    { 0 },                              /* fastSubclass flags   */
-    NULL,                               /* getValuesPrehook     */
-    NULL,                               /* getValuesPosthook    */
-    NULL,                               /* classPartInitPrehook */
-    NULL,                               /* classPartInitPosthook*/
-    NULL,                               /* ext_resources        */
-    NULL,                               /* compiled_ext_resources*/
-    0,                                  /* num_ext_resources    */
-    FALSE,                              /* use_sub_resources    */
-    NULL,                               /* widgetNavigable      */
-    NULL,                               /* focusChange          */
-    NULL                                /* wrapper_data         */
-};
-
-VDrawingAreaClassRec vDrawingAreaClassRec = {
-{
-    /* Core class part */
-
-    /* superclass         */    (WidgetClass)&xmDrawingAreaClassRec,
-    /* class_name         */    "VDrawingArea",
-    /* widget_size        */    sizeof(VDrawingAreaRec),
-    /* class_initialize   */    NULL,
-    /* class_part_initialize*/  NULL,
-    /* class_inited       */    FALSE,
-    /* initialize         */    NULL,
-    /* initialize_hook    */    NULL,
-    /* realize            */    Realize,
-    /* actions            */    NULL,
-    /* num_actions        */    0,
-    /* resources          */    resources,
-    /* num_resources      */    XtNumber(resources),
-    /* xrm_class          */    NULLQUARK,
-    /* compress_motion    */    FALSE,
-    /* compress_exposure  */    FALSE,
-    /* compress_enterleave*/    FALSE,
-    /* visible_interest   */    FALSE,
-    /* destroy            */    Destroy,
-    /* resize             */    XtInheritResize,
-    /* expose             */    XtInheritExpose,
-    /* set_values         */    SetValues,
-    /* set_values_hook    */    NULL,
-    /* set_values_almost  */    XtInheritSetValuesAlmost,
-    /* get_values_hook    */    NULL,
-    /* accept_focus       */    NULL,
-    /* version            */    XtVersion,
-    /* callback_offsets   */    NULL,
-    /* tm_table           */    NULL,
-    /* query_geometry       */  NULL,
-    /* display_accelerator  */  NULL,
-    /* extension            */  NULL
-  },
-
-   {            /* composite_class fields */
-      XtInheritGeometryManager,                 /* geometry_manager   */
-      XtInheritChangeManaged,                   /* change_managed     */
-      XtInheritInsertChild,                     /* insert_child       */
-      XtInheritDeleteChild,                     /* delete_child       */
-      NULL,                                     /* extension          */
-   },
-
-   {            /* constraint_class fields */
-      NULL,                                     /* resource list        */
-      0,                                        /* num resources        */
-      0,                                        /* constraint size      */
-      NULL,                                     /* init proc            */
-      NULL,                                     /* destroy proc         */
-      NULL,                                     /* set values proc      */
-      NULL,                                     /* extension            */
-   },
-
-   {            /* manager_class fields */
-      XtInheritTranslations,                    /* translations           */
-      NULL,                                     /* syn_resources          */
-      0,                                        /* num_get_resources      */
-      NULL,                                     /* syn_cont_resources     */
-      0,                                        /* num_get_cont_resources */
-      XmInheritParentProcess,                   /* parent_process         */
-      NULL,                                     /* extension           */
-   },
-
-   {            /* drawingArea class */
-           /* extension */      NULL
-   },
-
-   /* VDrawingArea class part */
-   {
-        /* extension    */      NULL
-   }
-};
-
-WidgetClass vDrawingAreaClass = (WidgetClass)&vDrawingAreaClassRec;
-
-static Boolean
-SetValues(cw, rw, nw, args, num_args)
-    Widget cw;
-    Widget rw;
-    Widget nw;
-    ArgList args;
-    Cardinal *num_args;
-{
-    VDrawingAreaWidget current = (VDrawingAreaWidget)cw;
-    VDrawingAreaWidget new_w = (VDrawingAreaWidget)nw;
-
-    if (new_w->vdrawing_area.visual != current->vdrawing_area.visual) {
-        new_w->vdrawing_area.visual = current->vdrawing_area.visual;
-#ifdef DEBUG
-        fprintf(stdout, "VDrawingArea.SetValues: can't change visual from: visualID=%ld to visualID=%ld\n",
-                     current->vdrawing_area.visual->visualid,
-                     new_w->vdrawing_area.visual->visualid);
-#endif
-
-    }
-
-    return (False);
-}
-
-int
-FindWindowInList (Window parentWindow, Window *colormap_windows, int count)
-{
-    int i;
-
-    for (i = 0; i < count; i++)
-        if (colormap_windows [i] == parentWindow)
-           return i;
-    return -1;
-}
-
-static void
-Realize(w, value_mask, attributes)
-    Widget               w;
-    XtValueMask          *value_mask;
-    XSetWindowAttributes *attributes;
-{
-    Widget parent;
-    Status status;
-    Window *colormap_windows;
-    Window *new_colormap_windows;
-    int count;
-    int i;
-    VDrawingAreaWidget vd = (VDrawingAreaWidget)w;
-
-#ifdef DEBUG
-    fprintf(stdout, "VDrawingArea.Realize: visualID=%ld, depth=%d\n",
-                        vd->vdrawing_area.visual->visualid, w->core.depth);
-#endif
-
-    /* 4328588:
-     * Since we have our own Realize() function, we don't execute the one for
-     * our super-super class, XmManager, and miss the code which checks that
-     * height and width != 0.  I've added that here.  -bchristi
-     */
-    if (!XtWidth(w)) XtWidth(w) = 1 ;
-    if (!XtHeight(w)) XtHeight(w) = 1 ;
-
-    w->core.window = XCreateWindow (XtDisplay (w), XtWindow (w->core.parent),
-                        w->core.x, w->core.y, w->core.width, w->core.height,
-                        0, w->core.depth, InputOutput,
-                        vd->vdrawing_area.visual,
-                        *value_mask, attributes );
-
-    /* Need to add this window to the list of Colormap windows */
-    parent = XtParent (w);
-    while ((parent != NULL) && (!(XtIsShell (parent))))
-        parent = XtParent (parent);
-    if (parent == NULL) {
-        fprintf (stderr, "NO TopLevel widget?!\n");
-        return;
-    }
-
-    status = XGetWMColormapWindows (XtDisplay (w), XtWindow (parent),
-                                    &colormap_windows, &count);
-
-    /* If status is zero, add this window and shell to the list
-       of colormap Windows */
-    if (status == 0) {
-        new_colormap_windows = (Window *) calloc (2, sizeof (Window));
-        new_colormap_windows [0] = XtWindow (w);
-        new_colormap_windows [1] = XtWindow (parent);
-        XSetWMColormapWindows (XtDisplay (w), XtWindow (parent),
-                               new_colormap_windows, 2);
-        free (new_colormap_windows);
-    } else {
-        /* Check if parent is already in the list */
-        int parent_entry = -1;
-
-        if (count > 0)
-            parent_entry = FindWindowInList (XtWindow (parent),
-                                        colormap_windows, count);
-        if (parent_entry == -1) {  /*  Parent not in list  */
-            new_colormap_windows = (Window *) calloc (count + 2,
-                                                sizeof (Window));
-            new_colormap_windows [0] = XtWindow (w);
-            new_colormap_windows [1] = XtWindow (parent);
-            for (i = 0; i < count; i++)
-                new_colormap_windows [i + 2] = colormap_windows [i];
-            XSetWMColormapWindows (XtDisplay (w), XtWindow (parent),
-                                   new_colormap_windows, count + 2);
-
-        } else {        /* parent already in list, just add new window */
-            new_colormap_windows = (Window *) calloc (count + 1,
-                                                sizeof (Window));
-            new_colormap_windows [0] = XtWindow (w);
-            for (i = 0; i < count; i++)
-                new_colormap_windows [i + 1] = colormap_windows [i];
-            XSetWMColormapWindows (XtDisplay (w), XtWindow (parent),
-                                   new_colormap_windows, count + 1);
-        }
-        free (new_colormap_windows);
-        XFree (colormap_windows);
-    }
-
-
-}
-
-static void
-Destroy(Widget widget)
-{
-    Status status;
-    Widget parent;
-    Window *colormap_windows;
-    Window *new_colormap_windows;
-    int count;
-    int listEntry;
-    int i;
-    int j;
-
-    /* Need to get this window's parent shell first */
-    parent = XtParent (widget);
-    while ((parent != NULL) && (!(XtIsShell (parent))))
-        parent = XtParent (parent);
-    if (parent == NULL) {
-        fprintf (stderr, "NO TopLevel widget?!\n");
-        return;
-    }
-
-    status = XGetWMColormapWindows (XtDisplay (widget), XtWindow (parent),
-                                    &colormap_windows, &count);
-
-    /* If status is zero, then there were no colormap windows for
-       the parent ?? */
-
-    if (status == 0)
-        return;
-
-    /* Remove this window from the list of colormap windows */
-    listEntry = FindWindowInList (XtWindow (widget), colormap_windows,
-                                  count);
-
-    new_colormap_windows = (Window *) calloc (count - 1, sizeof (Window));
-    j = 0;
-    for (i = 0; i < count; i++) {
-        if (i == listEntry)
-           continue;
-        new_colormap_windows [j] = colormap_windows [i];
-        j++;
-    }
-    XSetWMColormapWindows (XtDisplay (widget), XtWindow (parent),
-                           new_colormap_windows, count - 1);
-    free (new_colormap_windows);
-    XFree (colormap_windows);
-
-}
-#endif /* !HEADLESS */
--- a/jdk/src/java.desktop/unix/native/libawt_headless/awt/VDrawingArea.h	Wed Jul 05 21:38:12 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 1997, 2001, 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.
- */
-
-#ifndef _VDrawingArea_h_
-#define _VDrawingArea_h_
-
-#ifndef HEADLESS
-extern WidgetClass vDrawingAreaClass;
-
-typedef struct _VDrawingAreaClassRec    *VDrawingAreaWidgetClass;
-typedef struct _VDrawingAreaRec         *VDrawingAreaWidget;
-#endif /* !HEADLESS */
-
-#endif /* !_VDrawingArea_h_ */
--- a/jdk/src/java.desktop/unix/native/libawt_headless/awt/VDrawingAreaP.h	Wed Jul 05 21:38:12 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1997, 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.
- */
-
-#ifndef _VDrawingAreaP_h_
-#define _VDrawingAreaP_h_
-
-#include <Xm/DrawingAP.h>
-#include "VDrawingArea.h"
-
-
-/***************************************************************
- * VDrawingArea Widget Data Structures
- *
- *
- **************************************************************/
-
-/* Define part class structure */
-typedef struct _VDrawingAreaClass {
-        XtPointer                       extension;
-} VDrawingAreaClassPart;
-
-/* Define the full class record */
-typedef struct _VDrawingAreaClassRec {
-        CoreClassPart           core_class;
-        CompositeClassPart      composite_class;
-        ConstraintClassPart     constraint_class;
-        XmManagerClassPart      manager_class;
-        XmDrawingAreaClassPart  drawing_area_class;
-        VDrawingAreaClassPart   vdrawingarea_class;
-} VDrawingAreaClassRec;
-
-/* External definition for class record */
-extern VDrawingAreaClassRec vDrawingAreaClassRec;
-
-typedef struct {
-        Visual *visual;
-} VDrawingAreaPart;
-
-/****************************************************************
- *
- * Full instance record declaration
- *
- ****************************************************************/
-
-typedef struct _VDrawingAreaRec
-{
-        CorePart                core;
-        CompositePart           composite;
-        ConstraintPart          constraint;
-        XmManagerPart           manager;
-        XmDrawingAreaPart       drawing_area;
-        VDrawingAreaPart        vdrawing_area;
-} VDrawingAreaRec;
-
-
-
-#endif /* !_VDrawingAreaP_h_ */
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c	Mon Apr 25 09:25:26 2016 -0700
@@ -40,7 +40,6 @@
 
 #define THROW_OUT_OF_MEMORY_ERROR() \
         JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL)
-#define SETARG(name, value)     XtSetArg(args[argc], name, value); argc++
 
 struct X11InputMethodIDs {
   jfieldID pData;
@@ -590,7 +589,7 @@
     char **mclr;
     int  mccr = 0;
     char *dsr;
-    Pixel bg, fg, light, dim;
+    unsigned long bg, fg, light, dim;
     int x, y, off_x, off_y, xx, yy;
     unsigned int w, h, bw, depth;
     XGCValues values;
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -31,7 +31,6 @@
 #include "awt_GraphicsEnv.h"
 #define XK_MISCELLANY
 #include <X11/keysymdef.h>
-#include <X11/Intrinsic.h>
 #include <X11/Xutil.h>
 #include <X11/Xmd.h>
 #include <X11/extensions/xtestext1.h>
@@ -45,7 +44,7 @@
 #include "wsutils.h"
 #include "list.h"
 #include "multiVis.h"
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
 
 #if defined(__linux__) || defined(MACOSX)
 #include <sys/socket.h>
@@ -264,70 +263,10 @@
     int index;
 
     if (isGtkSupported) {
-        GdkPixbuf *pixbuf;
-        (*fp_gdk_threads_enter)();
-        GdkWindow *root = (*fp_gdk_get_default_root_window)();
-
-        pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(NULL, root, NULL,
-                                                    x, y, 0, 0, width, height);
-        if (pixbuf && scale != 1) {
-            GdkPixbuf *scaledPixbuf;
-            x /= scale;
-            y /= scale;
-            width /= scale;
-            height /= scale;
-            dx /= scale;
-            dy /= scale;
-            scaledPixbuf = (*fp_gdk_pixbuf_scale_simple)(pixbuf, width, height,
-                                                         GDK_INTERP_BILINEAR);
-            (*fp_g_object_unref)(pixbuf);
-            pixbuf = scaledPixbuf;
-        }
-
-        if (pixbuf) {
-            int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
-            int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
-
-            if ((*fp_gdk_pixbuf_get_width)(pixbuf) == width
-                    && (*fp_gdk_pixbuf_get_height)(pixbuf) == height
-                    && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
-                    && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
-                    && nchan >= 3
-                    ) {
-                guchar *p, *pix = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
-
-                ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
-                if (!ary) {
-                    (*fp_g_object_unref)(pixbuf);
-                    (*fp_gdk_threads_leave)();
-                    AWT_UNLOCK();
-                    return;
-                }
-
-                for (_y = 0; _y < height; _y++) {
-                    for (_x = 0; _x < width; _x++) {
-                        p = pix + _y * stride + _x * nchan;
-
-                        index = (_y + dy) * jwidth + (_x + dx);
-                        ary[index] = 0xff000000
-                                        | (p[0] << 16)
-                                        | (p[1] << 8)
-                                        | (p[2]);
-
-                    }
-                }
-                (*env)->ReleasePrimitiveArrayCritical(env, pixelArray, ary, 0);
-                if ((*env)->ExceptionCheck(env)) {
-                    (*fp_g_object_unref)(pixbuf);
-                    (*fp_gdk_threads_leave)();
-                    AWT_UNLOCK();
-                    return;
-                }
-                gtk_failed = FALSE;
-            }
-            (*fp_g_object_unref)(pixbuf);
-        }
-        (*fp_gdk_threads_leave)();
+        gtk->gdk_threads_enter();
+        gtk_failed = gtk->get_drawable_data(env, pixelArray, x, y, width,
+                                            jwidth, height, dx, dy, scale);
+        gtk->gdk_threads_leave();
     }
 
     if (gtk_failed) {
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -34,7 +34,7 @@
 
 #ifndef HEADLESS
 #include "awt.h"
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
 #endif /* !HEADLESS */
 
 
@@ -45,13 +45,12 @@
 /*
  * Class:     sun_awt_UNIXToolkit
  * Method:    check_gtk
- * Signature: ()Z
+ * Signature: (I)Z
  */
 JNIEXPORT jboolean JNICALL
-Java_sun_awt_UNIXToolkit_check_1gtk(JNIEnv *env, jclass klass)
-{
+Java_sun_awt_UNIXToolkit_check_1gtk(JNIEnv *env, jclass klass, jint version) {
 #ifndef HEADLESS
-    return (jboolean)gtk2_check_version();
+    return (jboolean)gtk_check_version(version);
 #else
     return JNI_FALSE;
 #endif /* !HEADLESS */
@@ -61,13 +60,13 @@
 /*
  * Class:     sun_awt_UNIXToolkit
  * Method:    load_gtk
- * Signature: ()Z
+ * Signature: (I)Z
  */
 JNIEXPORT jboolean JNICALL
-Java_sun_awt_UNIXToolkit_load_1gtk(JNIEnv *env, jclass klass)
-{
+Java_sun_awt_UNIXToolkit_load_1gtk(JNIEnv *env, jclass klass, jint version,
+                                                             jboolean verbose) {
 #ifndef HEADLESS
-    return (jboolean)gtk2_load(env);
+    return (jboolean)gtk_load(env, version, verbose);
 #else
     return JNI_FALSE;
 #endif /* !HEADLESS */
@@ -83,16 +82,14 @@
 Java_sun_awt_UNIXToolkit_unload_1gtk(JNIEnv *env, jclass klass)
 {
 #ifndef HEADLESS
-    return (jboolean)gtk2_unload();
+    return (jboolean)gtk->unload();
 #else
     return JNI_FALSE;
 #endif /* !HEADLESS */
 }
 
-jboolean _icon_upcall(JNIEnv *env, jobject this, GdkPixbuf *pixbuf)
+jboolean init_method(JNIEnv *env, jobject this)
 {
-    jboolean result = JNI_FALSE;
-
     if (this_class == NULL) {
         this_class = (*env)->NewGlobalRef(env,
                                           (*env)->GetObjectClass(env, this));
@@ -100,33 +97,7 @@
                                  "loadIconCallback", "([BIIIIIZ)V");
         CHECK_NULL_RETURN(icon_upcall_method, JNI_FALSE);
     }
-
-    if (pixbuf != NULL)
-    {
-        guchar *pixbuf_data = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
-        int row_stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
-        int width = (*fp_gdk_pixbuf_get_width)(pixbuf);
-        int height = (*fp_gdk_pixbuf_get_height)(pixbuf);
-        int bps = (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf);
-        int channels = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
-        gboolean alpha = (*fp_gdk_pixbuf_get_has_alpha)(pixbuf);
-
-        /* Copy the data array into a Java structure so we can pass it back. */
-        jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
-        JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
-
-        (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
-                                   (jbyte *)pixbuf_data);
-
-        /* Release the pixbuf. */
-        (*fp_g_object_unref)(pixbuf);
-
-        /* Call the callback method to create the image on the Java side. */
-        (*env)->CallVoidMethod(env, this, icon_upcall_method, data,
-                width, height, row_stride, bps, channels, alpha);
-        result = JNI_TRUE;
-    }
-    return result;
+    return JNI_TRUE;
 }
 
 /*
@@ -144,7 +115,6 @@
     int len;
     char *filename_str = NULL;
     GError **error = NULL;
-    GdkPixbuf *pixbuf;
 
     if (filename == NULL)
     {
@@ -158,13 +128,17 @@
         JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
         return JNI_FALSE;
     }
+    if (!init_method(env, this) ) {
+        return JNI_FALSE;
+    }
     (*env)->GetStringUTFRegion(env, filename, 0, len, filename_str);
-    pixbuf = (*fp_gdk_pixbuf_new_from_file)(filename_str, error);
+    jboolean result = gtk->get_file_icon_data(env, filename_str, error,
+                                            icon_upcall_method, this);
 
     /* Release the strings we've allocated. */
     free(filename_str);
 
-    return _icon_upcall(env, this, pixbuf);
+    return result;
 #else /* HEADLESS */
     return JNI_FALSE;
 #endif /* !HEADLESS */
@@ -186,7 +160,6 @@
     int len;
     char *stock_id_str = NULL;
     char *detail_str = NULL;
-    GdkPixbuf *pixbuf;
 
     if (stock_id == NULL)
     {
@@ -215,8 +188,12 @@
         (*env)->GetStringUTFRegion(env, detail, 0, len, detail_str);
     }
 
-    pixbuf = gtk2_get_stock_icon(widget_type, stock_id_str, icon_size,
-                                 text_direction, detail_str);
+    if (!init_method(env, this) ) {
+        return JNI_FALSE;
+    }
+    jboolean result = gtk->get_icon_data(env, widget_type, stock_id_str,
+                  icon_size, text_direction, detail_str,
+                  icon_upcall_method, this);
 
     /* Release the strings we've allocated. */
     free(stock_id_str);
@@ -224,8 +201,7 @@
     {
         free(detail_str);
     }
-
-    return _icon_upcall(env, this, pixbuf);
+    return result;
 #else /* HEADLESS */
     return JNI_FALSE;
 #endif /* !HEADLESS */
@@ -279,11 +255,25 @@
 {
     char *ret;
 
-    ret = fp_gtk_check_version(major, minor, micro);
+    ret = gtk->gtk_check_version(major, minor, micro);
     if (ret == NULL) {
         return TRUE;
     }
 
-    free(ret);
     return FALSE;
 }
+
+/*
+ * Class:     sun_awt_UNIXToolkit
+ * Method:    get_gtk_version
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL
+Java_sun_awt_UNIXToolkit_get_1gtk_1version(JNIEnv *env, jclass klass)
+{
+#ifndef HEADLESS
+    return gtk ? gtk->version : GTK_ANY;
+#else
+    return GTK_ANY;
+#endif /* !HEADLESS */
+}
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c	Mon Apr 25 09:25:26 2016 -0700
@@ -29,7 +29,6 @@
 
 #include "awt_p.h"
 #include "color.h"
-#include <X11/IntrinsicP.h>
 #include <X11/Xatom.h>
 #include <X11/Xmd.h>
 #include <X11/Xutil.h>
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c	Mon Apr 25 09:25:26 2016 -0700
@@ -35,52 +35,18 @@
 #include <jni_util.h>
 #include "awt.h"
 
-#define GTK2_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("gtk-x11-2.0", "0")
-#define GTK2_LIB JNI_LIB_NAME("gtk-x11-2.0")
 #define GTHREAD_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("gthread-2.0", "0")
 #define GTHREAD_LIB JNI_LIB_NAME("gthread-2.0")
 
-#define G_TYPE_INVALID                  G_TYPE_MAKE_FUNDAMENTAL (0)
-#define G_TYPE_NONE                     G_TYPE_MAKE_FUNDAMENTAL (1)
-#define G_TYPE_INTERFACE                G_TYPE_MAKE_FUNDAMENTAL (2)
-#define G_TYPE_CHAR                     G_TYPE_MAKE_FUNDAMENTAL (3)
-#define G_TYPE_UCHAR                    G_TYPE_MAKE_FUNDAMENTAL (4)
-#define G_TYPE_BOOLEAN                  G_TYPE_MAKE_FUNDAMENTAL (5)
-#define G_TYPE_INT                      G_TYPE_MAKE_FUNDAMENTAL (6)
-#define G_TYPE_UINT                     G_TYPE_MAKE_FUNDAMENTAL (7)
-#define G_TYPE_LONG                     G_TYPE_MAKE_FUNDAMENTAL (8)
-#define G_TYPE_ULONG                    G_TYPE_MAKE_FUNDAMENTAL (9)
-#define G_TYPE_INT64                    G_TYPE_MAKE_FUNDAMENTAL (10)
-#define G_TYPE_UINT64                   G_TYPE_MAKE_FUNDAMENTAL (11)
-#define G_TYPE_ENUM                     G_TYPE_MAKE_FUNDAMENTAL (12)
-#define G_TYPE_FLAGS                    G_TYPE_MAKE_FUNDAMENTAL (13)
-#define G_TYPE_FLOAT                    G_TYPE_MAKE_FUNDAMENTAL (14)
-#define G_TYPE_DOUBLE                   G_TYPE_MAKE_FUNDAMENTAL (15)
-#define G_TYPE_STRING                   G_TYPE_MAKE_FUNDAMENTAL (16)
-#define G_TYPE_POINTER                  G_TYPE_MAKE_FUNDAMENTAL (17)
-#define G_TYPE_BOXED                    G_TYPE_MAKE_FUNDAMENTAL (18)
-#define G_TYPE_PARAM                    G_TYPE_MAKE_FUNDAMENTAL (19)
-#define G_TYPE_OBJECT                   G_TYPE_MAKE_FUNDAMENTAL (20)
-
 #define GTK_TYPE_BORDER                 ((*fp_gtk_border_get_type)())
 
 #define G_TYPE_FUNDAMENTAL_SHIFT        (2)
 #define G_TYPE_MAKE_FUNDAMENTAL(x)      ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
-#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
 
 #define CONV_BUFFER_SIZE 128
 
 #define NO_SYMBOL_EXCEPTION 1
 
-/* SynthConstants */
-const gint ENABLED    = 1 << 0;
-const gint MOUSE_OVER = 1 << 1;
-const gint PRESSED    = 1 << 2;
-const gint DISABLED   = 1 << 3;
-const gint FOCUSED    = 1 << 8;
-const gint SELECTED   = 1 << 9;
-const gint DEFAULT    = 1 << 10;
-
 static void *gtk2_libhandle = NULL;
 static void *gthread_libhandle = NULL;
 
@@ -105,54 +71,6 @@
 static gboolean new_combo = TRUE;
 const char ENV_PREFIX[] = "GTK_MODULES=";
 
-/*******************/
-enum GtkWidgetType
-{
-    _GTK_ARROW_TYPE,
-    _GTK_BUTTON_TYPE,
-    _GTK_CHECK_BUTTON_TYPE,
-    _GTK_CHECK_MENU_ITEM_TYPE,
-    _GTK_COLOR_SELECTION_DIALOG_TYPE,
-    _GTK_COMBO_BOX_TYPE,
-    _GTK_COMBO_BOX_ARROW_BUTTON_TYPE,
-    _GTK_COMBO_BOX_TEXT_FIELD_TYPE,
-    _GTK_CONTAINER_TYPE,
-    _GTK_ENTRY_TYPE,
-    _GTK_FRAME_TYPE,
-    _GTK_HANDLE_BOX_TYPE,
-    _GTK_HPANED_TYPE,
-    _GTK_HPROGRESS_BAR_TYPE,
-    _GTK_HSCALE_TYPE,
-    _GTK_HSCROLLBAR_TYPE,
-    _GTK_HSEPARATOR_TYPE,
-    _GTK_IMAGE_TYPE,
-    _GTK_MENU_TYPE,
-    _GTK_MENU_BAR_TYPE,
-    _GTK_MENU_ITEM_TYPE,
-    _GTK_NOTEBOOK_TYPE,
-    _GTK_LABEL_TYPE,
-    _GTK_RADIO_BUTTON_TYPE,
-    _GTK_RADIO_MENU_ITEM_TYPE,
-    _GTK_SCROLLED_WINDOW_TYPE,
-    _GTK_SEPARATOR_MENU_ITEM_TYPE,
-    _GTK_SEPARATOR_TOOL_ITEM_TYPE,
-    _GTK_SPIN_BUTTON_TYPE,
-    _GTK_TEXT_VIEW_TYPE,
-    _GTK_TOGGLE_BUTTON_TYPE,
-    _GTK_TOOLBAR_TYPE,
-    _GTK_TOOLTIP_TYPE,
-    _GTK_TREE_VIEW_TYPE,
-    _GTK_VIEWPORT_TYPE,
-    _GTK_VPANED_TYPE,
-    _GTK_VPROGRESS_BAR_TYPE,
-    _GTK_VSCALE_TYPE,
-    _GTK_VSCROLLBAR_TYPE,
-    _GTK_VSEPARATOR_TYPE,
-    _GTK_WINDOW_TYPE,
-    _GTK_DIALOG_TYPE,
-    _GTK_WIDGET_TYPE_SIZE
-};
-
 
 static GtkWidget *gtk2_widgets[_GTK_WIDGET_TYPE_SIZE];
 
@@ -359,20 +277,6 @@
 static GtkAdjustment* (*fp_gtk_range_get_adjustment)(GtkRange* range);
 
 /* Method bodies */
-const char *getStrFor(JNIEnv *env, jstring val)
-{
-    int length = (*env)->GetStringLength(env, val);
-    if (length > CONV_BUFFER_SIZE-1)
-    {
-        length = CONV_BUFFER_SIZE-1;
-#ifdef DEBUG
-        fprintf(stderr, "Note: Detail is too long: %d chars\n", length);
-#endif /* DEBUG */
-    }
-
-    (*env)->GetStringUTFRegion(env, val, 0, length, convertionBuffer);
-    return convertionBuffer;
-}
 
 static void throw_exception(JNIEnv *env, const char* name, const char* message)
 {
@@ -408,33 +312,34 @@
     return result;
 }
 
-gboolean gtk2_check_version()
+gboolean gtk2_check(const char* lib_name, int flags)
 {
     if (gtk2_libhandle != NULL) {
         /* We've already successfully opened the GTK libs, so return true. */
         return TRUE;
     } else {
         void *lib = NULL;
-        gboolean result = FALSE;
 
-        lib = dlopen(GTK2_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
+        lib = dlopen(lib_name, flags);
+
         if (lib == NULL) {
-            lib = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL);
-            if (lib == NULL) {
-                return FALSE;
-            }
+            return FALSE;
+        }
+
+        if (flags & RTLD_NOLOAD) {
+            return TRUE;
         }
 
         fp_gtk_check_version = dlsym(lib, "gtk_check_version");
         /* Check for GTK 2.2+ */
         if (!fp_gtk_check_version(2, 2, 0)) {
-            result = TRUE;
+            return TRUE;
         }
 
         // 8048289: workaround for https://bugzilla.gnome.org/show_bug.cgi?id=733065
         // dlclose(lib);
 
-        return result;
+        return FALSE;
     }
 }
 
@@ -450,7 +355,7 @@
 } while(0);
 
 
-void update_supported_actions(JNIEnv *env) {
+static void update_supported_actions(JNIEnv *env) {
     GVfs * (*fp_g_vfs_get_default) (void);
     const gchar * const * (*fp_g_vfs_get_supported_uri_schemes) (GVfs * vfs);
     const gchar * const * schemes = NULL;
@@ -513,7 +418,7 @@
 /**
  * Functions for awt_Desktop.c
  */
-gboolean gtk2_show_uri_load(JNIEnv *env) {
+static gboolean gtk2_show_uri_load(JNIEnv *env) {
      gboolean success = FALSE;
      dlerror();
      const char *gtk_version = fp_gtk_check_version(2, 14, 0);
@@ -547,7 +452,7 @@
 /**
  * Functions for sun_awt_X11_GtkFileDialogPeer.c
  */
-void gtk2_file_chooser_load()
+static void gtk2_file_chooser_load()
 {
     fp_gtk_file_chooser_get_filename = dl_symbol(
             "gtk_file_chooser_get_filename");
@@ -576,7 +481,7 @@
     fp_gdk_x11_drawable_get_xid = dl_symbol("gdk_x11_drawable_get_xid");
 }
 
-gboolean gtk2_load(JNIEnv *env)
+GtkApi* gtk2_load(JNIEnv *env, const char* lib_name)
 {
     gboolean result;
     int i;
@@ -584,11 +489,9 @@
     int (*io_handler)();
     char *gtk_modules_env;
 
-    gtk2_libhandle = dlopen(GTK2_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
+    gtk2_libhandle = dlopen(lib_name, RTLD_LAZY | RTLD_LOCAL);
     if (gtk2_libhandle == NULL) {
-        gtk2_libhandle = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL);
-        if (gtk2_libhandle == NULL)
-            return FALSE;
+        return FALSE;
     }
 
     gthread_libhandle = dlopen(GTHREAD_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
@@ -962,8 +865,12 @@
     {
         gtk2_widgets[i] = NULL;
     }
-
-    return result;
+    if (result) {
+        GtkApi* gtk = (GtkApi*)malloc(sizeof(GtkApi));
+        gtk2_init(gtk);
+        return gtk;
+    }
+    return NULL;
 }
 
 int gtk2_unload()
@@ -1007,7 +914,7 @@
 /* Dispatch all pending events from the GTK event loop.
  * This is needed to catch theme change and update widgets' style.
  */
-void flush_gtk_event_loop()
+static void flush_gtk_event_loop()
 {
     while( (*fp_g_main_context_iteration)(NULL, FALSE));
 }
@@ -1056,7 +963,7 @@
  * comparing results. This can be optimized by using subclassed pixmap and
  * doing the second drawing only if necessary.
 */
-void gtk2_init_painting(JNIEnv *env, gint width, gint height)
+static void gtk2_init_painting(JNIEnv *env, gint width, gint height)
 {
     GdkGC *gc;
     GdkPixbuf *white, *black;
@@ -1116,7 +1023,7 @@
  * one of java_awt_Transparency_OPAQUE, java_awt_Transparency_BITMASK, and
  * java_awt_Transparency_TRANSLUCENT.
  */
-gint gtk2_copy_image(gint *dst, gint width, gint height)
+static gint gtk2_copy_image(gint *dst, gint width, gint height)
 {
     gint i, j, r, g, b;
     guchar *white, *black;
@@ -1778,7 +1685,7 @@
             x, y, w, h);
 }
 
-void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type,
                     GtkShadowType shadow_type, const gchar *detail,
                     gint x, gint y, gint width, gint height,
                     gint synth_state, GtkTextDirection dir)
@@ -1948,7 +1855,7 @@
             x, y, width, height, gap_side, gap_x, gap_width);
 }
 
-void gtk2_paint_check(WidgetType widget_type, gint synth_state,
+static void gtk2_paint_check(WidgetType widget_type, gint synth_state,
         const gchar *detail, gint x, gint y, gint width, gint height)
 {
     GtkStateType state_type = get_gtk_state_type(widget_type, synth_state);
@@ -1965,7 +1872,7 @@
             x, y, width, height);
 }
 
-void gtk2_paint_diamond(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_diamond(WidgetType widget_type, GtkStateType state_type,
         GtkShadowType shadow_type, const gchar *detail,
         gint x, gint y, gint width, gint height)
 {
@@ -1978,7 +1885,7 @@
             x, y, width, height);
 }
 
-void gtk2_paint_expander(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_expander(WidgetType widget_type, GtkStateType state_type,
         const gchar *detail, gint x, gint y, gint width, gint height,
         GtkExpanderStyle expander_style)
 {
@@ -1991,7 +1898,7 @@
             x + width / 2, y + height / 2, expander_style);
 }
 
-void gtk2_paint_extension(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_extension(WidgetType widget_type, GtkStateType state_type,
         GtkShadowType shadow_type, const gchar *detail,
         gint x, gint y, gint width, gint height, GtkPositionType gap_side)
 {
@@ -2004,7 +1911,7 @@
             x, y, width, height, gap_side);
 }
 
-void gtk2_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
         GtkShadowType shadow_type, const gchar *detail,
         gint x, gint y, gint width, gint height, gboolean has_focus)
 {
@@ -2023,7 +1930,7 @@
             x, y, width, height);
 }
 
-void gtk2_paint_focus(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_focus(WidgetType widget_type, GtkStateType state_type,
         const char *detail, gint x, gint y, gint width, gint height)
 {
     gtk2_widget = gtk2_get_widget(widget_type);
@@ -2033,7 +1940,7 @@
             NULL, gtk2_widget, detail, x, y, width, height);
 }
 
-void gtk2_paint_handle(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_handle(WidgetType widget_type, GtkStateType state_type,
         GtkShadowType shadow_type, const gchar *detail,
         gint x, gint y, gint width, gint height, GtkOrientation orientation)
 {
@@ -2046,7 +1953,7 @@
             x, y, width, height, orientation);
 }
 
-void gtk2_paint_hline(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_hline(WidgetType widget_type, GtkStateType state_type,
         const gchar *detail, gint x, gint y, gint width, gint height)
 {
     gtk2_widget = gtk2_get_widget(widget_type);
@@ -2056,7 +1963,7 @@
             NULL, gtk2_widget, detail, x, x + width, y);
 }
 
-void gtk2_paint_option(WidgetType widget_type, gint synth_state,
+static void gtk2_paint_option(WidgetType widget_type, gint synth_state,
         const gchar *detail, gint x, gint y, gint width, gint height)
 {
     GtkStateType state_type = get_gtk_state_type(widget_type, synth_state);
@@ -2073,7 +1980,7 @@
             x, y, width, height);
 }
 
-void gtk2_paint_shadow(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_shadow(WidgetType widget_type, GtkStateType state_type,
                        GtkShadowType shadow_type, const gchar *detail,
                        gint x, gint y, gint width, gint height,
                        gint synth_state, GtkTextDirection dir)
@@ -2123,9 +2030,10 @@
     gtk2_set_direction(gtk2_widget, GTK_TEXT_DIR_LTR);
 }
 
-void gtk2_paint_slider(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_slider(WidgetType widget_type, GtkStateType state_type,
         GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height, GtkOrientation orientation)
+        gint x, gint y, gint width, gint height, GtkOrientation orientation,
+        gboolean has_focus)
 {
     gtk2_widget = gtk2_get_widget(widget_type);
     (*fp_gtk_paint_slider)(gtk2_widget->style, gtk2_white_pixmap, state_type,
@@ -2136,7 +2044,7 @@
             x, y, width, height, orientation);
 }
 
-void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type,
         const gchar *detail, gint x, gint y, gint width, gint height)
 {
     gtk2_widget = gtk2_get_widget(widget_type);
@@ -2146,7 +2054,7 @@
             NULL, gtk2_widget, detail, y, y + height, x);
 }
 
-void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
+static void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
         gint x, gint y, gint width, gint height)
 {
     gtk2_widget = gtk2_get_widget(widget_type);
@@ -2156,7 +2064,7 @@
             gtk2_black_pixmap, TRUE, state_type, NULL, x, y, width, height);
 }
 
-GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
+static GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
         GtkIconSize size, GtkTextDirection direction, const char *detail)
 {
     init_containers();
@@ -2166,8 +2074,52 @@
     return (*fp_gtk_widget_render_icon)(gtk2_widget, stock_id, size, detail);
 }
 
+static jboolean gtk2_get_pixbuf_data(JNIEnv *env, GdkPixbuf* pixbuf,
+                              jmethodID icon_upcall_method, jobject this) {
+    if (!pixbuf) {
+        return JNI_FALSE;
+    }
+    guchar *pixbuf_data = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
+    if (pixbuf_data) {
+        int row_stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
+        int width = (*fp_gdk_pixbuf_get_width)(pixbuf);
+        int height = (*fp_gdk_pixbuf_get_height)(pixbuf);
+        int bps = (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf);
+        int channels = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
+        gboolean alpha = (*fp_gdk_pixbuf_get_has_alpha)(pixbuf);
+
+        jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
+        JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
+
+        (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
+                                   (jbyte *)pixbuf_data);
+        (*fp_g_object_unref)(pixbuf);
+
+        /* Call the callback method to create the image on the Java side. */
+        (*env)->CallVoidMethod(env, this, icon_upcall_method, data,
+                width, height, row_stride, bps, channels, alpha);
+        return JNI_TRUE;
+    }
+    return JNI_FALSE;
+}
+
+static jboolean gtk2_get_file_icon_data(JNIEnv *env, const char *filename,
+                 GError **error, jmethodID icon_upcall_method, jobject this) {
+    GdkPixbuf* pixbuf = fp_gdk_pixbuf_new_from_file(filename, error);
+    return gtk2_get_pixbuf_data(env, pixbuf, icon_upcall_method, this);
+}
+
+static jboolean gtk2_get_icon_data(JNIEnv *env, gint widget_type,
+                              const gchar *stock_id, GtkIconSize size,
+                              GtkTextDirection direction, const char *detail,
+                              jmethodID icon_upcall_method, jobject this) {
+    GdkPixbuf* pixbuf = gtk2_get_stock_icon(widget_type, stock_id, size,
+                                       direction, detail);
+    return gtk2_get_pixbuf_data(env, pixbuf, icon_upcall_method, this);
+}
+
 /*************************************************/
-gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type)
+static gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type)
 {
     init_containers();
 
@@ -2176,7 +2128,7 @@
     return style->xthickness;
 }
 
-gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type)
+static gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type)
 {
     init_containers();
 
@@ -2186,12 +2138,12 @@
 }
 
 /*************************************************/
-guint8 recode_color(guint16 channel)
+static guint8 recode_color(guint16 channel)
 {
     return (guint8)(channel>>8);
 }
 
-gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
+static gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
                               GtkStateType state_type, ColorType color_type)
 {
     gint result = 0;
@@ -2243,19 +2195,19 @@
 }
 
 /*************************************************/
-jobject create_Boolean(JNIEnv *env, jboolean boolean_value);
-jobject create_Integer(JNIEnv *env, jint int_value);
-jobject create_Long(JNIEnv *env, jlong long_value);
-jobject create_Float(JNIEnv *env, jfloat float_value);
-jobject create_Double(JNIEnv *env, jdouble double_value);
-jobject create_Character(JNIEnv *env, jchar char_value);
-jobject create_Insets(JNIEnv *env, GtkBorder *border);
+static jobject create_Boolean(JNIEnv *env, jboolean boolean_value);
+static jobject create_Integer(JNIEnv *env, jint int_value);
+static jobject create_Long(JNIEnv *env, jlong long_value);
+static jobject create_Float(JNIEnv *env, jfloat float_value);
+static jobject create_Double(JNIEnv *env, jdouble double_value);
+static jobject create_Character(JNIEnv *env, jchar char_value);
+static jobject create_Insets(JNIEnv *env, GtkBorder *border);
 
-jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type, jstring jkey)
+static jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type,
+                              const char* key)
 {
     init_containers();
 
-    const char* key = getStrFor(env, jkey);
     gtk2_widget = gtk2_get_widget(widget_type);
 
     GValue value;
@@ -2376,7 +2328,7 @@
     return NULL;
 }
 
-void gtk2_set_range_value(WidgetType widget_type, jdouble value,
+static void gtk2_set_range_value(WidgetType widget_type, jdouble value,
                           jdouble min, jdouble max, jdouble visible)
 {
     GtkAdjustment *adj;
@@ -2391,7 +2343,7 @@
 }
 
 /*************************************************/
-jobject create_Object(JNIEnv *env, jmethodID *cid,
+static jobject create_Object(JNIEnv *env, jmethodID *cid,
                              const char* class_name,
                              const char* signature,
                              jvalue* value)
@@ -2494,7 +2446,7 @@
 }
 
 /*********************************************/
-jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type)
+static jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type)
 {
     init_containers();
 
@@ -2513,7 +2465,7 @@
 }
 
 /***********************************************/
-jobject get_string_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
+static jobject get_string_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
 {
     jobject result = NULL;
     gchar*  strval = NULL;
@@ -2525,21 +2477,21 @@
     return result;
 }
 
-jobject get_integer_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
+static jobject get_integer_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
 {
     gint intval = NULL;
     (*fp_g_object_get)(settings, key, &intval, NULL);
     return create_Integer(env, intval);
 }
 
-jobject get_boolean_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
+static jobject get_boolean_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
 {
     gint intval = NULL;
     (*fp_g_object_get)(settings, key, &intval, NULL);
     return create_Boolean(env, intval);
 }
 
-jobject gtk2_get_setting(JNIEnv *env, Setting property)
+static jobject gtk2_get_setting(JNIEnv *env, Setting property)
 {
     GtkSettings* settings = (*fp_gtk_settings_get_default)();
 
@@ -2557,3 +2509,148 @@
 
     return NULL;
 }
+
+static gboolean gtk2_get_drawable_data(JNIEnv *env, jintArray pixelArray, jint x,
+     jint y, jint width, jint height, jint jwidth, int dx, int dy, jint scale) {
+    GdkPixbuf *pixbuf;
+    jint *ary;
+
+    GdkWindow *root = (*fp_gdk_get_default_root_window)();
+
+    pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(NULL, root, NULL, x, y,
+                                                    0, 0, width, height);
+    if (pixbuf && scale != 1) {
+        GdkPixbuf *scaledPixbuf;
+        x /= scale;
+        y /= scale;
+        width /= scale;
+        height /= scale;
+        dx /= scale;
+        dy /= scale;
+        scaledPixbuf = (*fp_gdk_pixbuf_scale_simple)(pixbuf, width, height,
+                                                     GDK_INTERP_BILINEAR);
+        (*fp_g_object_unref)(pixbuf);
+        pixbuf = scaledPixbuf;
+    }
+
+    if (pixbuf) {
+        int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
+        int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
+
+        if ((*fp_gdk_pixbuf_get_width)(pixbuf) == width
+                && (*fp_gdk_pixbuf_get_height)(pixbuf) == height
+                && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
+                && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
+                && nchan >= 3
+                ) {
+            guchar *p, *pix = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
+
+            ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
+            if (ary) {
+                jint _x, _y;
+                int index;
+                for (_y = 0; _y < height; _y++) {
+                    for (_x = 0; _x < width; _x++) {
+                        p = pix + _y * stride + _x * nchan;
+
+                        index = (_y + dy) * jwidth + (_x + dx);
+                        ary[index] = 0xff000000
+                                        | (p[0] << 16)
+                                        | (p[1] << 8)
+                                        | (p[2]);
+
+                    }
+                }
+                (*env)->ReleasePrimitiveArrayCritical(env, pixelArray, ary, 0);
+            }
+        }
+        (*fp_g_object_unref)(pixbuf);
+    }
+    return JNI_FALSE;
+}
+
+static GdkWindow* gtk2_get_window(void *widget) {
+    return ((GtkWidget*)widget)->window;
+}
+
+void gtk2_init(GtkApi* gtk) {
+    gtk->version = GTK_2;
+
+    gtk->show_uri_load = &gtk2_show_uri_load;
+    gtk->unload = &gtk2_unload;
+    gtk->flush_event_loop = &flush_gtk_event_loop;
+    gtk->gtk_check_version = fp_gtk_check_version;
+    gtk->get_setting = &gtk2_get_setting;
+
+    gtk->paint_arrow = &gtk2_paint_arrow;
+    gtk->paint_box = &gtk2_paint_box;
+    gtk->paint_box_gap = &gtk2_paint_box_gap;
+    gtk->paint_expander = &gtk2_paint_expander;
+    gtk->paint_extension = &gtk2_paint_extension;
+    gtk->paint_flat_box = &gtk2_paint_flat_box;
+    gtk->paint_focus = &gtk2_paint_focus;
+    gtk->paint_handle = &gtk2_paint_handle;
+    gtk->paint_hline = &gtk2_paint_hline;
+    gtk->paint_vline = &gtk2_paint_vline;
+    gtk->paint_option = &gtk2_paint_option;
+    gtk->paint_shadow = &gtk2_paint_shadow;
+    gtk->paint_slider = &gtk2_paint_slider;
+    gtk->paint_background = &gtk_paint_background;
+    gtk->paint_check = &gtk2_paint_check;
+    gtk->set_range_value = &gtk2_set_range_value;
+
+    gtk->init_painting = &gtk2_init_painting;
+    gtk->copy_image = &gtk2_copy_image;
+
+    gtk->get_xthickness = &gtk2_get_xthickness;
+    gtk->get_ythickness = &gtk2_get_ythickness;
+    gtk->get_color_for_state = &gtk2_get_color_for_state;
+    gtk->get_class_value = &gtk2_get_class_value;
+
+    gtk->get_pango_font_name = &gtk2_get_pango_font_name;
+    gtk->get_icon_data = &gtk2_get_icon_data;
+    gtk->get_file_icon_data = &gtk2_get_file_icon_data;
+    gtk->gdk_threads_enter = fp_gdk_threads_enter;
+    gtk->gdk_threads_leave = fp_gdk_threads_leave;
+    gtk->gtk_show_uri = fp_gtk_show_uri;
+    gtk->get_drawable_data = &gtk2_get_drawable_data;
+    gtk->g_free = fp_g_free;
+
+    gtk->gtk_file_chooser_get_filename = fp_gtk_file_chooser_get_filename;
+    gtk->gtk_widget_hide = fp_gtk_widget_hide;
+    gtk->gtk_main_quit = fp_gtk_main_quit;
+    gtk->gtk_file_chooser_dialog_new = fp_gtk_file_chooser_dialog_new;
+    gtk->gtk_file_chooser_set_current_folder =
+                          fp_gtk_file_chooser_set_current_folder;
+    gtk->gtk_file_chooser_set_filename = fp_gtk_file_chooser_set_filename;
+    gtk->gtk_file_chooser_set_current_name =
+                          fp_gtk_file_chooser_set_current_name;
+    gtk->gtk_file_filter_add_custom = fp_gtk_file_filter_add_custom;
+    gtk->gtk_file_chooser_set_filter = fp_gtk_file_chooser_set_filter;
+    gtk->gtk_file_chooser_get_type = fp_gtk_file_chooser_get_type;
+    gtk->gtk_file_filter_new = fp_gtk_file_filter_new;
+    gtk->gtk_file_chooser_set_do_overwrite_confirmation =
+                          fp_gtk_file_chooser_set_do_overwrite_confirmation;
+    gtk->gtk_file_chooser_set_select_multiple =
+                          fp_gtk_file_chooser_set_select_multiple;
+    gtk->gtk_file_chooser_get_current_folder =
+                          fp_gtk_file_chooser_get_current_folder;
+    gtk->gtk_file_chooser_get_filenames = fp_gtk_file_chooser_get_filenames;
+    gtk->gtk_g_slist_length = fp_gtk_g_slist_length;
+    gtk->g_signal_connect_data = fp_g_signal_connect_data;
+    gtk->gtk_widget_show = fp_gtk_widget_show;
+    gtk->gtk_main = fp_gtk_main;
+    gtk->gtk_main_level = fp_gtk_main_level;
+    gtk->g_path_get_dirname = fp_g_path_get_dirname;
+    gtk->gdk_x11_drawable_get_xid = fp_gdk_x11_drawable_get_xid;
+    gtk->gtk_widget_destroy = fp_gtk_widget_destroy;
+    gtk->gtk_window_present = fp_gtk_window_present;
+    gtk->gtk_window_move = fp_gtk_window_move;
+    gtk->gtk_window_resize = fp_gtk_window_resize;
+    gtk->get_window = &gtk2_get_window;
+
+    gtk->g_object_unref = fp_g_object_unref;
+    gtk->g_list_append = fp_g_list_append;
+    gtk->g_list_free = fp_g_list_free;
+    gtk->g_list_free_full = fp_g_list_free_full;
+}
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h	Mon Apr 25 09:25:26 2016 -0700
@@ -28,232 +28,11 @@
 #include <stdlib.h>
 #include <jni.h>
 #include <X11/X.h>
-
-#define _G_TYPE_CIC(ip, gt, ct)       ((ct*) ip)
-#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type)    (_G_TYPE_CIC ((instance), (g_type), c_type))
-#define GTK_TYPE_FILE_CHOOSER             (fp_gtk_file_chooser_get_type ())
-#define GTK_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser))
-#define fp_g_signal_connect(instance, detailed_signal, c_handler, data) \
-    fp_g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
-#define G_CALLBACK(f) ((GCallback) (f))
-#define G_TYPE_FUNDAMENTAL_SHIFT (2)
-#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
-#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
-#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
-#define GTK_STOCK_CANCEL           "gtk-cancel"
-#define GTK_STOCK_SAVE             "gtk-save"
-#define GTK_STOCK_OPEN             "gtk-open"
-#define GDK_CURRENT_TIME           0L
-
-typedef enum _WidgetType
-{
-    BUTTON,                     /* GtkButton */
-    CHECK_BOX,                  /* GtkCheckButton */
-    CHECK_BOX_MENU_ITEM,        /* GtkCheckMenuItem */
-    COLOR_CHOOSER,              /* GtkColorSelectionDialog */
-    COMBO_BOX,                  /* GtkComboBox */
-    COMBO_BOX_ARROW_BUTTON,     /* GtkComboBoxEntry */
-    COMBO_BOX_TEXT_FIELD,       /* GtkComboBoxEntry */
-    DESKTOP_ICON,               /* GtkLabel */
-    DESKTOP_PANE,               /* GtkContainer */
-    EDITOR_PANE,                /* GtkTextView */
-    FORMATTED_TEXT_FIELD,       /* GtkEntry */
-    HANDLE_BOX,                 /* GtkHandleBox */
-    HPROGRESS_BAR,              /* GtkProgressBar */
-    HSCROLL_BAR,                /* GtkHScrollbar */
-    HSCROLL_BAR_BUTTON_LEFT,    /* GtkHScrollbar */
-    HSCROLL_BAR_BUTTON_RIGHT,   /* GtkHScrollbar */
-    HSCROLL_BAR_TRACK,          /* GtkHScrollbar */
-    HSCROLL_BAR_THUMB,          /* GtkHScrollbar */
-    HSEPARATOR,                 /* GtkHSeparator */
-    HSLIDER,                    /* GtkHScale */
-    HSLIDER_TRACK,              /* GtkHScale */
-    HSLIDER_THUMB,              /* GtkHScale */
-    HSPLIT_PANE_DIVIDER,        /* GtkHPaned */
-    INTERNAL_FRAME,             /* GtkWindow */
-    INTERNAL_FRAME_TITLE_PANE,  /* GtkLabel */
-    IMAGE,                      /* GtkImage */
-    LABEL,                      /* GtkLabel */
-    LIST,                       /* GtkTreeView */
-    MENU,                       /* GtkMenu */
-    MENU_BAR,                   /* GtkMenuBar */
-    MENU_ITEM,                  /* GtkMenuItem */
-    MENU_ITEM_ACCELERATOR,      /* GtkLabel */
-    OPTION_PANE,                /* GtkMessageDialog */
-    PANEL,                      /* GtkContainer */
-    PASSWORD_FIELD,             /* GtkEntry */
-    POPUP_MENU,                 /* GtkMenu */
-    POPUP_MENU_SEPARATOR,       /* GtkSeparatorMenuItem */
-    RADIO_BUTTON,               /* GtkRadioButton */
-    RADIO_BUTTON_MENU_ITEM,     /* GtkRadioMenuItem */
-    ROOT_PANE,                  /* GtkContainer */
-    SCROLL_PANE,                /* GtkScrolledWindow */
-    SPINNER,                    /* GtkSpinButton */
-    SPINNER_ARROW_BUTTON,       /* GtkSpinButton */
-    SPINNER_TEXT_FIELD,         /* GtkSpinButton */
-    SPLIT_PANE,                 /* GtkPaned */
-    TABBED_PANE,                /* GtkNotebook */
-    TABBED_PANE_TAB_AREA,       /* GtkNotebook */
-    TABBED_PANE_CONTENT,        /* GtkNotebook */
-    TABBED_PANE_TAB,            /* GtkNotebook */
-    TABLE,                      /* GtkTreeView */
-    TABLE_HEADER,               /* GtkButton */
-    TEXT_AREA,                  /* GtkTextView */
-    TEXT_FIELD,                 /* GtkEntry */
-    TEXT_PANE,                  /* GtkTextView */
-    TITLED_BORDER,              /* GtkFrame */
-    TOGGLE_BUTTON,              /* GtkToggleButton */
-    TOOL_BAR,                   /* GtkToolbar */
-    TOOL_BAR_DRAG_WINDOW,       /* GtkToolbar */
-    TOOL_BAR_SEPARATOR,         /* GtkSeparatorToolItem */
-    TOOL_TIP,                   /* GtkWindow */
-    TREE,                       /* GtkTreeView */
-    TREE_CELL,                  /* GtkTreeView */
-    VIEWPORT,                   /* GtkViewport */
-    VPROGRESS_BAR,              /* GtkProgressBar */
-    VSCROLL_BAR,                /* GtkVScrollbar */
-    VSCROLL_BAR_BUTTON_UP,      /* GtkVScrollbar */
-    VSCROLL_BAR_BUTTON_DOWN,    /* GtkVScrollbar */
-    VSCROLL_BAR_TRACK,          /* GtkVScrollbar */
-    VSCROLL_BAR_THUMB,          /* GtkVScrollbar */
-    VSEPARATOR,                 /* GtkVSeparator */
-    VSLIDER,                    /* GtkVScale */
-    VSLIDER_TRACK,              /* GtkVScale */
-    VSLIDER_THUMB,              /* GtkVScale */
-    VSPLIT_PANE_DIVIDER,        /* GtkVPaned */
-    WIDGET_TYPE_SIZE
-} WidgetType;
-
-typedef enum _ColorType
-{
-    FOREGROUND,
-    BACKGROUND,
-    TEXT_FOREGROUND,
-    TEXT_BACKGROUND,
-    FOCUS,
-    LIGHT,
-    DARK,
-    MID,
-    BLACK,
-    WHITE
-} ColorType;
-
-typedef enum _Setting
-{
-    GTK_FONT_NAME,
-    GTK_ICON_SIZES,
-    GTK_CURSOR_BLINK,
-    GTK_CURSOR_BLINK_TIME
-} Setting;
-
-/* GTK types, here to eliminate need for GTK headers at compile time */
-
-#ifndef FALSE
-#define FALSE           (0)
-#define TRUE            (!FALSE)
-#endif
+#include "gtk_interface.h"
 
 #define GTK_HAS_FOCUS   (1 << 12)
 #define GTK_HAS_DEFAULT (1 << 14)
 
-
-/* basic types */
-typedef char    gchar;
-typedef short   gshort;
-typedef int     gint;
-typedef long    glong;
-typedef float   gfloat;
-typedef double  gdouble;
-typedef void*   gpointer;
-typedef gint    gboolean;
-
-typedef signed char  gint8;
-typedef signed short gint16;
-typedef signed int   gint32;
-
-typedef unsigned char  guchar;
-typedef unsigned char  guint8;
-typedef unsigned short gushort;
-typedef unsigned short guint16;
-typedef unsigned int   guint;
-typedef unsigned int   guint32;
-typedef unsigned int   gsize;
-typedef unsigned long  gulong;
-
-typedef signed long long   gint64;
-typedef unsigned long long guint64;
-
-/* enumerated constants */
-typedef enum
-{
-  GTK_ARROW_UP,
-  GTK_ARROW_DOWN,
-  GTK_ARROW_LEFT,
-  GTK_ARROW_RIGHT
-} GtkArrowType;
-
-typedef enum {
-  GDK_COLORSPACE_RGB
-} GdkColorspace;
-
-typedef enum
-{
-  GTK_EXPANDER_COLLAPSED,
-  GTK_EXPANDER_SEMI_COLLAPSED,
-  GTK_EXPANDER_SEMI_EXPANDED,
-  GTK_EXPANDER_EXPANDED
-} GtkExpanderStyle;
-
-typedef enum
-{
-  GTK_ICON_SIZE_INVALID,
-  GTK_ICON_SIZE_MENU,
-  GTK_ICON_SIZE_SMALL_TOOLBAR,
-  GTK_ICON_SIZE_LARGE_TOOLBAR,
-  GTK_ICON_SIZE_BUTTON,
-  GTK_ICON_SIZE_DND,
-  GTK_ICON_SIZE_DIALOG
-} GtkIconSize;
-
-typedef enum
-{
-  GTK_ORIENTATION_HORIZONTAL,
-  GTK_ORIENTATION_VERTICAL
-} GtkOrientation;
-
-typedef enum
-{
-  GTK_POS_LEFT,
-  GTK_POS_RIGHT,
-  GTK_POS_TOP,
-  GTK_POS_BOTTOM
-} GtkPositionType;
-
-typedef enum
-{
-  GTK_SHADOW_NONE,
-  GTK_SHADOW_IN,
-  GTK_SHADOW_OUT,
-  GTK_SHADOW_ETCHED_IN,
-  GTK_SHADOW_ETCHED_OUT
-} GtkShadowType;
-
-typedef enum
-{
-  GTK_STATE_NORMAL,
-  GTK_STATE_ACTIVE,
-  GTK_STATE_PRELIGHT,
-  GTK_STATE_SELECTED,
-  GTK_STATE_INSENSITIVE
-} GtkStateType;
-
-typedef enum
-{
-  GTK_TEXT_DIR_NONE,
-  GTK_TEXT_DIR_LTR,
-  GTK_TEXT_DIR_RTL
-} GtkTextDirection;
-
 typedef enum
 {
   GTK_WINDOW_TOPLEVEL,
@@ -270,41 +49,15 @@
   G_PARAM_PRIVATE             = 1 << 5
 } GParamFlags;
 
-typedef enum {
-    GDK_INTERP_NEAREST,
-    GDK_INTERP_TILES,
-    GDK_INTERP_BILINEAR,
-    GDK_INTERP_HYPER
-} GdkInterpType;
-
 /* We define all structure pointers to be void* */
-typedef void GError;
 typedef void GMainContext;
 typedef void GVfs;
 
-typedef struct _GSList GSList;
-struct _GSList
-{
-  gpointer data;
-  GSList *next;
-};
-
-typedef struct _GList GList;
-
-struct _GList
-{
-  gpointer data;
-  GList *next;
-  GList *prev;
-};
-
 typedef void GdkColormap;
 typedef void GdkDrawable;
 typedef void GdkGC;
-typedef void GdkScreen;
 typedef void GdkPixbuf;
 typedef void GdkPixmap;
-typedef void GdkWindow;
 
 typedef void GtkFixed;
 typedef void GtkMenuItem;
@@ -364,7 +117,6 @@
  * structures. This is a place where getting rid of gtk
  * headers may be dangerous.
  ******************************************************/
-typedef gulong         GType;
 
 typedef struct
 {
@@ -599,70 +351,9 @@
   guint ellipsize : 3;
 };
 
-typedef enum {
-  GTK_RESPONSE_NONE = -1,
-  GTK_RESPONSE_REJECT = -2,
-  GTK_RESPONSE_ACCEPT = -3,
-  GTK_RESPONSE_DELETE_EVENT = -4,
-  GTK_RESPONSE_OK = -5,
-  GTK_RESPONSE_CANCEL = -6,
-  GTK_RESPONSE_CLOSE = -7,
-  GTK_RESPONSE_YES = -8,
-  GTK_RESPONSE_NO = -9,
-  GTK_RESPONSE_APPLY = -10,
-  GTK_RESPONSE_HELP = -11
-} GtkResponseType;
-
-typedef struct _GtkWindow GtkWindow;
-
-typedef struct _GtkFileChooser GtkFileChooser;
-
-typedef enum {
-  GTK_FILE_CHOOSER_ACTION_OPEN,
-  GTK_FILE_CHOOSER_ACTION_SAVE,
-  GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
-  GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
-} GtkFileChooserAction;
-
-typedef struct _GtkFileFilter GtkFileFilter;
-
-typedef enum {
-  GTK_FILE_FILTER_FILENAME = 1 << 0,
-  GTK_FILE_FILTER_URI = 1 << 1,
-  GTK_FILE_FILTER_DISPLAY_NAME = 1 << 2,
-  GTK_FILE_FILTER_MIME_TYPE = 1 << 3
-} GtkFileFilterFlags;
-
-typedef struct {
-  GtkFileFilterFlags contains;
-  const gchar *filename;
-  const gchar *uri;
-  const gchar *display_name;
-  const gchar *mime_type;
-} GtkFileFilterInfo;
-
-typedef gboolean (*GtkFileFilterFunc)(const GtkFileFilterInfo *filter_info,
-    gpointer data);
-
-typedef void (*GDestroyNotify)(gpointer data);
-
-typedef void (*GCallback)(void);
-
-typedef struct _GClosure GClosure;
-
-typedef void (*GClosureNotify)(gpointer data, GClosure *closure);
-
-typedef enum {
-  G_CONNECT_AFTER = 1 << 0, G_CONNECT_SWAPPED = 1 << 1
-} GConnectFlags;
 
 typedef struct _GThreadFunctions GThreadFunctions;
 
-/*
- * Converts java.lang.String object to UTF-8 character string.
- */
-const char *getStrFor(JNIEnv *env, jstring value);
-
 /**
  * Returns :
  * NULL if the GLib library is compatible with the given version, or a string
@@ -670,7 +361,7 @@
  * Please note that the glib_check_version() is available since 2.6,
  * so you should use GLIB_CHECK_VERSION macro instead.
  */
-gchar* (*fp_glib_check_version)(guint required_major, guint required_minor,
+static gchar* (*fp_glib_check_version)(guint required_major, guint required_minor,
                        guint required_micro);
 
 /**
@@ -680,193 +371,96 @@
 #define GLIB_CHECK_VERSION(major, minor, micro) \
     (fp_glib_check_version && fp_glib_check_version(major, minor, micro) == NULL)
 
-/*
- * Check whether the gtk2 library is available and meets the minimum
- * version requirement.  If the library is already loaded this method has no
- * effect and returns success.
- * Returns FALSE on failure and TRUE on success.
- */
-gboolean gtk2_check_version();
-
 /**
  * Returns :
  * NULL if the GTK+ library is compatible with the given version, or a string
  * describing the version mismatch.
  */
-gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
+static gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
                        guint required_micro);
-/*
- * Load the gtk2 library.  If the library is already loaded this method has no
- * effect and returns success.
- * Returns FALSE on failure and TRUE on success.
- */
-gboolean gtk2_load(JNIEnv *env);
 
-/*
- * Loads fp_gtk_show_uri function pointer. This initialization is
- * separated because the function is required only
- * for java.awt.Desktop API. The function relies on initialization in
- * gtk2_load, so it must be invoked only after a successful gtk2_load
- * invocation
- */
-gboolean gtk2_show_uri_load(JNIEnv *env);
+static void gtk2_init(GtkApi* gtk);
 
-/*
- * Unload the gtk2 library.  If the library is already unloaded this method has
- * no effect and returns success.
- * Returns FALSE on failure and TRUE on success.
- */
-gboolean gtk2_unload();
+static void (*fp_g_free)(gpointer mem);
+static void (*fp_g_object_unref)(gpointer object);
+static GdkWindow *(*fp_gdk_get_default_root_window) (void);
 
-void gtk2_paint_arrow(WidgetType widget_type, GtkStateType state_type,
-        GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height,
-        GtkArrowType arrow_type, gboolean fill);
-void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type,
-        GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height,
-        gint synth_state, GtkTextDirection dir);
-void gtk2_paint_box_gap(WidgetType widget_type, GtkStateType state_type,
-        GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height,
-        GtkPositionType gap_side, gint gap_x, gint gap_width);
-void gtk2_paint_check(WidgetType widget_type, gint synth_state,
-        const gchar *detail, gint x, gint y, gint width, gint height);
-void gtk2_paint_diamond(WidgetType widget_type, GtkStateType state_type,
-        GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height);
-void gtk2_paint_expander(WidgetType widget_type, GtkStateType state_type,
-        const gchar *detail, gint x, gint y, gint width, gint height,
-        GtkExpanderStyle expander_style);
-void gtk2_paint_extension(WidgetType widget_type, GtkStateType state_type,
-        GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height, GtkPositionType gap_side);
-void gtk2_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
-        GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height, gboolean has_focus);
-void gtk2_paint_focus(WidgetType widget_type, GtkStateType state_type,
-        const char *detail, gint x, gint y, gint width, gint height);
-void gtk2_paint_handle(WidgetType widget_type, GtkStateType state_type,
-        GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height, GtkOrientation orientation);
-void gtk2_paint_hline(WidgetType widget_type, GtkStateType state_type,
-        const gchar *detail, gint x, gint y, gint width, gint height);
-void gtk2_paint_option(WidgetType widget_type, gint synth_state,
-        const gchar *detail, gint x, gint y, gint width, gint height);
-void gtk2_paint_shadow(WidgetType widget_type, GtkStateType state_type,
-        GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height,
-        gint synth_state, GtkTextDirection dir);
-void gtk2_paint_slider(WidgetType widget_type, GtkStateType state_type,
-        GtkShadowType shadow_type, const gchar *detail,
-        gint x, gint y, gint width, gint height, GtkOrientation orientation);
-void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type,
-        const gchar *detail, gint x, gint y, gint width, gint height);
-void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
-        gint x, gint y, gint width, gint height);
+static int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
+static guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
+static gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
+static GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
+static GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);
 
-void gtk2_init_painting(JNIEnv *env, gint w, gint h);
-gint gtk2_copy_image(gint *dest, gint width, gint height);
-
-gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type);
-gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type);
-gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
-                              GtkStateType state_type, ColorType color_type);
-jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type, jstring key);
-
-GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
-        GtkIconSize size, GtkTextDirection direction, const char *detail);
-GdkPixbuf *gtk2_get_icon(const gchar *filename, gint size);
-jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type);
-
-void flush_gtk_event_loop();
-
-jobject gtk2_get_setting(JNIEnv *env, Setting property);
-
-void gtk2_set_range_value(WidgetType widget_type, jdouble value,
-                          jdouble min, jdouble max, jdouble visible);
-
-void (*fp_g_free)(gpointer mem);
-void (*fp_g_object_unref)(gpointer object);
-GdkWindow *(*fp_gdk_get_default_root_window) (void);
-
-int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
-guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
-gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
-int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
-int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
-int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
-int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
-GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
-GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);
-
-GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest,
+static GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest,
         GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y,
         int dest_x, int dest_y, int width, int height);
-GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,
+static GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,
         int dest_width, int dest_heigh, GdkInterpType interp_type);
 
 
-void (*fp_gtk_widget_destroy)(GtkWidget *widget);
-void (*fp_gtk_window_present)(GtkWindow *window);
-void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
-void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
+static void (*fp_gtk_widget_destroy)(void *widget);
+static void (*fp_gtk_window_present)(GtkWindow *window);
+static void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
+static void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
 
 /**
  * Function Pointers for GtkFileChooser
  */
-gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
-void (*fp_gtk_widget_hide)(GtkWidget *widget);
-void (*fp_gtk_main_quit)(void);
-GtkWidget* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
+static gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
+static void (*fp_gtk_widget_hide)(void *widget);
+static void (*fp_gtk_main_quit)(void);
+static void* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
     GtkWindow *parent, GtkFileChooserAction action,
     const gchar *first_button_text, ...);
-gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
+static gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
     const gchar *filename);
-gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
+static gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
     const char *filename);
-void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
+static void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
     const gchar *name);
-void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
+static void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
     GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
     GDestroyNotify notify);
-void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
+static void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
     GtkFileFilter *filter);
-GType (*fp_gtk_file_chooser_get_type)(void);
-GtkFileFilter* (*fp_gtk_file_filter_new)(void);
-void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
+static GType (*fp_gtk_file_chooser_get_type)(void);
+static GtkFileFilter* (*fp_gtk_file_filter_new)(void);
+static void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
     GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
-void (*fp_gtk_file_chooser_set_select_multiple)(
+static void (*fp_gtk_file_chooser_set_select_multiple)(
     GtkFileChooser *chooser, gboolean select_multiple);
-gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
-GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
-guint (*fp_gtk_g_slist_length)(GSList *list);
-gulong (*fp_g_signal_connect_data)(gpointer instance,
+static gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
+static GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
+static guint (*fp_gtk_g_slist_length)(GSList *list);
+static gulong (*fp_g_signal_connect_data)(gpointer instance,
     const gchar *detailed_signal, GCallback c_handler, gpointer data,
     GClosureNotify destroy_data, GConnectFlags connect_flags);
-void (*fp_gtk_widget_show)(GtkWidget *widget);
-void (*fp_gtk_main)(void);
-guint (*fp_gtk_main_level)(void);
-gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
-XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
+static void (*fp_gtk_widget_show)(void *widget);
+static void (*fp_gtk_main)(void);
+static guint (*fp_gtk_main_level)(void);
+static gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
+static XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
 
-
-GList* (*fp_g_list_append) (GList *list, gpointer data);
-void (*fp_g_list_free) (GList *list);
-void (*fp_g_list_free_full) (GList *list, GDestroyNotify free_func);
+static GList* (*fp_g_list_append) (GList *list, gpointer data);
+static void (*fp_g_list_free) (GList *list);
+static void (*fp_g_list_free_full) (GList *list, GDestroyNotify free_func);
 
 /**
  * This function is available for GLIB > 2.20, so it MUST be
  * called within GLIB_CHECK_VERSION(2, 20, 0) check.
  */
-gboolean (*fp_g_thread_get_initialized)(void);
+static gboolean (*fp_g_thread_get_initialized)(void);
 
-void (*fp_g_thread_init)(GThreadFunctions *vtable);
-void (*fp_gdk_threads_init)(void);
-void (*fp_gdk_threads_enter)(void);
-void (*fp_gdk_threads_leave)(void);
+static void (*fp_g_thread_init)(GThreadFunctions *vtable);
+static void (*fp_gdk_threads_init)(void);
+static void (*fp_gdk_threads_enter)(void);
+static void (*fp_gdk_threads_leave)(void);
 
-gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
+static gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
     guint32 timestamp, GError **error);
 
 #endif /* !_GTK2_INTERFACE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,2881 @@
+/*
+ * Copyright (c) 2005, 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.
+ */
+#include <dlfcn.h>
+#include <setjmp.h>
+#include <X11/Xlib.h>
+#include <limits.h>
+#include <string.h>
+#include "gtk3_interface.h"
+#include "java_awt_Transparency.h"
+#include "sizecalc.h"
+#include <jni_util.h>
+#include <stdio.h>
+#include "awt.h"
+
+static void *gtk3_libhandle = NULL;
+
+static jmp_buf j;
+
+/* Widgets */
+static GtkWidget *gtk3_widget = NULL;
+static GtkWidget *gtk3_window = NULL;
+static GtkFixed  *gtk3_fixed  = NULL;
+static GtkStyleProvider *gtk3_css = NULL;
+
+/* Paint system */
+static cairo_surface_t *surface = NULL;
+static cairo_t *cr = NULL;
+
+static const char ENV_PREFIX[] = "GTK_MODULES=";
+
+static GtkWidget *gtk3_widgets[_GTK_WIDGET_TYPE_SIZE];
+
+static void throw_exception(JNIEnv *env, const char* name, const char* message)
+{
+    jclass class = (*env)->FindClass(env, name);
+
+    if (class != NULL)
+        (*env)->ThrowNew(env, class, message);
+
+    (*env)->DeleteLocalRef(env, class);
+}
+
+static void gtk3_add_state(GtkWidget *widget, GtkStateType state) {
+    GtkStateType old_state = fp_gtk_widget_get_state(widget);
+    fp_gtk_widget_set_state(widget, old_state | state);
+}
+
+static void gtk3_remove_state(GtkWidget *widget, GtkStateType state) {
+    GtkStateType old_state = fp_gtk_widget_get_state(widget);
+    fp_gtk_widget_set_state(widget, old_state & ~state);
+}
+
+/* This is a workaround for the bug:
+ * http://sourceware.org/bugzilla/show_bug.cgi?id=1814
+ * (dlsym/dlopen clears dlerror state)
+ * This bug is specific to Linux, but there is no harm in
+ * applying this workaround on Solaris as well.
+ */
+static void* dl_symbol(const char* name)
+{
+    void* result = dlsym(gtk3_libhandle, name);
+    if (!result)
+        longjmp(j, NO_SYMBOL_EXCEPTION);
+
+    return result;
+}
+
+gboolean gtk3_check(const char* lib_name, int flags)
+{
+    if (gtk3_libhandle != NULL) {
+        /* We've already successfully opened the GTK libs, so return true. */
+        return TRUE;
+    } else {
+        return dlopen(lib_name, flags) != NULL;
+    }
+}
+
+#define ADD_SUPPORTED_ACTION(actionStr)                                        \
+do {                                                                           \
+    jfieldID fld_action = (*env)->GetStaticFieldID(env, cls_action, actionStr, \
+                                                 "Ljava/awt/Desktop$Action;"); \
+    if (!(*env)->ExceptionCheck(env)) {                                        \
+        jobject action = (*env)->GetStaticObjectField(env, cls_action,         \
+                                                                  fld_action); \
+        (*env)->CallBooleanMethod(env, supportedActions, mid_arrayListAdd,     \
+                                                                      action); \
+    } else {                                                                   \
+        (*env)->ExceptionClear(env);                                           \
+    }                                                                          \
+} while(0);
+
+
+static void update_supported_actions(JNIEnv *env) {
+    GVfs * (*fp_g_vfs_get_default) (void);
+    const gchar * const * (*fp_g_vfs_get_supported_uri_schemes) (GVfs * vfs);
+    const gchar * const * schemes = NULL;
+
+    jclass cls_action = (*env)->FindClass(env, "java/awt/Desktop$Action");
+    CHECK_NULL(cls_action);
+    jclass cls_xDesktopPeer = (*env)->
+                                     FindClass(env, "sun/awt/X11/XDesktopPeer");
+    CHECK_NULL(cls_xDesktopPeer);
+    jfieldID fld_supportedActions = (*env)->GetStaticFieldID(env,
+                      cls_xDesktopPeer, "supportedActions", "Ljava/util/List;");
+    CHECK_NULL(fld_supportedActions);
+    jobject supportedActions = (*env)->GetStaticObjectField(env,
+                                        cls_xDesktopPeer, fld_supportedActions);
+
+    jclass cls_arrayList = (*env)->FindClass(env, "java/util/ArrayList");
+    CHECK_NULL(cls_arrayList);
+    jmethodID mid_arrayListAdd = (*env)->GetMethodID(env, cls_arrayList, "add",
+                                                       "(Ljava/lang/Object;)Z");
+    CHECK_NULL(mid_arrayListAdd);
+    jmethodID mid_arrayListClear = (*env)->GetMethodID(env, cls_arrayList,
+                                                                "clear", "()V");
+    CHECK_NULL(mid_arrayListClear);
+
+    (*env)->CallVoidMethod(env, supportedActions, mid_arrayListClear);
+
+    ADD_SUPPORTED_ACTION("OPEN");
+
+    /**
+     * gtk_show_uri() documentation says:
+     *
+     * > you need to install gvfs to get support for uri schemes such as http://
+     * > or ftp://, as only local files are handled by GIO itself.
+     *
+     * So OPEN action was safely added here.
+     * However, it looks like Solaris 11 have gvfs support only for 32-bit
+     * applications only by default.
+     */
+
+    fp_g_vfs_get_default = dl_symbol("g_vfs_get_default");
+    fp_g_vfs_get_supported_uri_schemes =
+                           dl_symbol("g_vfs_get_supported_uri_schemes");
+    dlerror();
+
+    if (fp_g_vfs_get_default && fp_g_vfs_get_supported_uri_schemes) {
+        GVfs * vfs = fp_g_vfs_get_default();
+        schemes = vfs ? fp_g_vfs_get_supported_uri_schemes(vfs) : NULL;
+        if (schemes) {
+            int i = 0;
+            while (schemes[i]) {
+                if (strcmp(schemes[i], "http") == 0) {
+                    ADD_SUPPORTED_ACTION("BROWSE");
+                    ADD_SUPPORTED_ACTION("MAIL");
+                    break;
+                }
+                i++;
+            }
+        }
+    } else {
+#ifdef DEBUG
+        fprintf(stderr, "Cannot load g_vfs_get_supported_uri_schemes\n");
+#endif /* DEBUG */
+    }
+
+}
+/**
+ * Functions for awt_Desktop.c
+ */
+static gboolean gtk3_show_uri_load(JNIEnv *env) {
+    gboolean success = FALSE;
+    dlerror();
+    fp_gtk_show_uri = dl_symbol("gtk_show_uri");
+    const char *dlsym_error = dlerror();
+    if (dlsym_error) {
+#ifdef DEBUG
+        fprintf (stderr, "Cannot load symbol: %s \n", dlsym_error);
+#endif /* DEBUG */
+    } else if (fp_gtk_show_uri == NULL) {
+#ifdef DEBUG
+        fprintf(stderr, "dlsym(gtk_show_uri) returned NULL\n");
+#endif /* DEBUG */
+    } else {
+        update_supported_actions(env);
+        success = TRUE;
+    }
+    return success;
+}
+
+/**
+ * Functions for sun_awt_X11_GtkFileDialogPeer.c
+ */
+static void gtk3_file_chooser_load()
+{
+    fp_gtk_file_chooser_get_filename = dl_symbol(
+            "gtk_file_chooser_get_filename");
+    fp_gtk_file_chooser_dialog_new = dl_symbol("gtk_file_chooser_dialog_new");
+    fp_gtk_file_chooser_set_current_folder = dl_symbol(
+            "gtk_file_chooser_set_current_folder");
+    fp_gtk_file_chooser_set_filename = dl_symbol(
+            "gtk_file_chooser_set_filename");
+    fp_gtk_file_chooser_set_current_name = dl_symbol(
+            "gtk_file_chooser_set_current_name");
+    fp_gtk_file_filter_add_custom = dl_symbol("gtk_file_filter_add_custom");
+    fp_gtk_file_chooser_set_filter = dl_symbol("gtk_file_chooser_set_filter");
+    fp_gtk_file_chooser_get_type = dl_symbol("gtk_file_chooser_get_type");
+    fp_gtk_file_filter_new = dl_symbol("gtk_file_filter_new");
+    fp_gtk_file_chooser_set_do_overwrite_confirmation = dl_symbol(
+                "gtk_file_chooser_set_do_overwrite_confirmation");
+    fp_gtk_file_chooser_set_select_multiple = dl_symbol(
+            "gtk_file_chooser_set_select_multiple");
+    fp_gtk_file_chooser_get_current_folder = dl_symbol(
+            "gtk_file_chooser_get_current_folder");
+    fp_gtk_file_chooser_get_filenames = dl_symbol(
+            "gtk_file_chooser_get_filenames");
+    fp_gtk_g_slist_length = dl_symbol("g_slist_length");
+    fp_gdk_x11_drawable_get_xid = dl_symbol("gdk_x11_window_get_xid");
+}
+
+static void empty() {}
+
+static gboolean gtk3_version_3_10 = TRUE;
+static gboolean gtk3_version_3_14 = FALSE;
+
+GtkApi* gtk3_load(JNIEnv *env, const char* lib_name)
+{
+    gboolean result;
+    int i;
+    int (*handler)();
+    int (*io_handler)();
+    char *gtk_modules_env;
+    gtk3_libhandle = dlopen(lib_name, RTLD_LAZY | RTLD_LOCAL);
+    if (gtk3_libhandle == NULL) {
+        return FALSE;
+    }
+
+    if (setjmp(j) == 0)
+    {
+        fp_gtk_check_version = dl_symbol("gtk_check_version");
+
+        /* GLib */
+        fp_glib_check_version = dlsym(gtk3_libhandle, "glib_check_version");
+        if (!fp_glib_check_version) {
+            dlerror();
+        }
+        fp_g_free = dl_symbol("g_free");
+        fp_g_object_unref = dl_symbol("g_object_unref");
+
+        fp_g_main_context_iteration =
+            dl_symbol("g_main_context_iteration");
+
+        fp_g_value_init = dl_symbol("g_value_init");
+        fp_g_type_is_a = dl_symbol("g_type_is_a");
+        fp_g_value_get_boolean = dl_symbol("g_value_get_boolean");
+        fp_g_value_get_char = dl_symbol("g_value_get_char");
+        fp_g_value_get_uchar = dl_symbol("g_value_get_uchar");
+        fp_g_value_get_int = dl_symbol("g_value_get_int");
+        fp_g_value_get_uint = dl_symbol("g_value_get_uint");
+        fp_g_value_get_long = dl_symbol("g_value_get_long");
+        fp_g_value_get_ulong = dl_symbol("g_value_get_ulong");
+        fp_g_value_get_int64 = dl_symbol("g_value_get_int64");
+        fp_g_value_get_uint64 = dl_symbol("g_value_get_uint64");
+        fp_g_value_get_float = dl_symbol("g_value_get_float");
+        fp_g_value_get_double = dl_symbol("g_value_get_double");
+        fp_g_value_get_string = dl_symbol("g_value_get_string");
+        fp_g_value_get_enum = dl_symbol("g_value_get_enum");
+        fp_g_value_get_flags = dl_symbol("g_value_get_flags");
+        fp_g_value_get_param = dl_symbol("g_value_get_param");
+        fp_g_value_get_boxed = dl_symbol("g_value_get_boxed");
+        fp_g_value_get_pointer = dl_symbol("g_value_get_pointer");
+
+        fp_g_object_get = dl_symbol("g_object_get");
+        fp_g_object_set = dl_symbol("g_object_set");
+
+        fp_g_str_has_prefix = dl_symbol("g_str_has_prefix");
+        fp_g_strsplit = dl_symbol("g_strsplit");
+        fp_g_strfreev = dl_symbol("g_strfreev");
+
+        /* GDK */
+        fp_gdk_get_default_root_window =
+            dl_symbol("gdk_get_default_root_window");
+
+        /* Pixbuf */
+        fp_gdk_pixbuf_new = dl_symbol("gdk_pixbuf_new");
+        fp_gdk_pixbuf_new_from_file =
+                dl_symbol("gdk_pixbuf_new_from_file");
+        fp_gdk_pixbuf_get_from_drawable =
+                    dl_symbol("gdk_pixbuf_get_from_window");
+        fp_gdk_pixbuf_get_width = dl_symbol("gdk_pixbuf_get_width");
+        fp_gdk_pixbuf_get_height = dl_symbol("gdk_pixbuf_get_height");
+        fp_gdk_pixbuf_get_pixels = dl_symbol("gdk_pixbuf_get_pixels");
+        fp_gdk_pixbuf_get_rowstride =
+                dl_symbol("gdk_pixbuf_get_rowstride");
+        fp_gdk_pixbuf_get_has_alpha =
+                dl_symbol("gdk_pixbuf_get_has_alpha");
+        fp_gdk_pixbuf_get_bits_per_sample =
+                dl_symbol("gdk_pixbuf_get_bits_per_sample");
+        fp_gdk_pixbuf_get_n_channels =
+                dl_symbol("gdk_pixbuf_get_n_channels");
+        fp_gdk_pixbuf_get_colorspace =
+                dl_symbol("gdk_pixbuf_get_colorspace");
+
+        fp_cairo_image_surface_create = dl_symbol("cairo_image_surface_create");
+        fp_cairo_surface_destroy = dl_symbol("cairo_surface_destroy");
+        fp_cairo_create = dl_symbol("cairo_create");
+        fp_cairo_destroy = dl_symbol("cairo_destroy");
+        fp_cairo_fill = dl_symbol("cairo_fill");
+        fp_cairo_rectangle = dl_symbol("cairo_rectangle");
+        fp_cairo_set_source_rgb = dl_symbol("cairo_set_source_rgb");
+        fp_cairo_set_source_rgba = dl_symbol("cairo_set_source_rgba");
+        fp_cairo_surface_flush = dl_symbol("cairo_surface_flush");
+        fp_cairo_paint = dl_symbol("cairo_paint");
+        fp_cairo_clip = dl_symbol("cairo_clip");
+        fp_cairo_image_surface_get_data =
+                       dl_symbol("cairo_image_surface_get_data");
+        fp_cairo_image_surface_get_stride =
+                       dl_symbol("cairo_image_surface_get_stride");
+
+        fp_gdk_pixbuf_get_from_surface =
+                       dl_symbol("gdk_pixbuf_get_from_surface");
+
+        fp_gtk_widget_get_state = dl_symbol("gtk_widget_get_state");
+        fp_gtk_widget_set_state = dl_symbol("gtk_widget_set_state");
+
+        fp_gtk_widget_is_focus = dl_symbol("gtk_widget_is_focus");
+        fp_gtk_widget_set_allocation = dl_symbol("gtk_widget_set_allocation");
+        fp_gtk_widget_get_parent = dl_symbol("gtk_widget_get_parent");
+        fp_gtk_widget_get_window = dl_symbol("gtk_widget_get_window");
+
+        fp_gtk_widget_get_style_context =
+                       dl_symbol("gtk_widget_get_style_context");
+        fp_gtk_style_context_get_color =
+                       dl_symbol("gtk_style_context_get_color");
+        fp_gtk_style_context_get_background_color =
+                       dl_symbol("gtk_style_context_get_background_color");
+        fp_gtk_widget_get_state_flags = dl_symbol("gtk_widget_get_state_flags");
+        fp_gtk_style_context_set_state =
+                       dl_symbol("gtk_style_context_set_state");
+        fp_gtk_style_context_add_class =
+                       dl_symbol("gtk_style_context_add_class");
+        fp_gtk_style_context_save = dl_symbol("gtk_style_context_save");
+        fp_gtk_style_context_restore = dl_symbol("gtk_style_context_restore");
+        fp_gtk_render_check = dl_symbol("gtk_render_check");
+        fp_gtk_render_option = dl_symbol("gtk_render_option");
+        fp_gtk_render_extension = dl_symbol("gtk_render_extension");
+        fp_gtk_render_expander = dl_symbol("gtk_render_expander");
+        fp_gtk_render_frame_gap = dl_symbol("gtk_render_frame_gap");
+        fp_gtk_render_line = dl_symbol("gtk_render_line");
+        fp_gtk_widget_render_icon_pixbuf =
+                      dl_symbol("gtk_widget_render_icon_pixbuf");
+        if (fp_gtk_check_version(3, 10, 0)) {
+            gtk3_version_3_10 = FALSE;
+        } else {
+            fp_gdk_window_create_similar_image_surface =
+                       dl_symbol("gdk_window_create_similar_image_surface");
+        }
+        gtk3_version_3_14 = !fp_gtk_check_version(3, 14, 0);
+
+        fp_gdk_window_create_similar_surface =
+                      dl_symbol("gdk_window_create_similar_surface");
+        fp_gtk_settings_get_for_screen =
+                      dl_symbol("gtk_settings_get_for_screen");
+        fp_gtk_widget_get_screen = dl_symbol("gtk_widget_get_screen");
+        fp_gtk_css_provider_get_named = dl_symbol("gtk_css_provider_get_named");
+        fp_gtk_style_context_add_provider =
+                      dl_symbol("gtk_style_context_add_provider");
+        fp_gtk_render_frame = dl_symbol("gtk_render_frame");
+        fp_gtk_render_focus = dl_symbol("gtk_render_focus");
+        fp_gtk_render_handle = dl_symbol("gtk_render_handle");
+        fp_gtk_render_arrow = dl_symbol("gtk_render_arrow");
+
+        fp_gtk_style_context_get_property =
+                      dl_symbol("gtk_style_context_get_property");
+        fp_gtk_scrolled_window_set_shadow_type =
+                      dl_symbol("gtk_scrolled_window_set_shadow_type");
+        fp_gtk_render_slider = dl_symbol("gtk_render_slider");
+        fp_gtk_style_context_get_padding =
+                      dl_symbol("gtk_style_context_get_padding");
+        fp_gtk_range_set_inverted = dl_symbol("gtk_range_set_inverted");
+        fp_gtk_style_context_get_font = dl_symbol("gtk_style_context_get_font");
+        fp_gtk_widget_get_allocated_width =
+                      dl_symbol("gtk_widget_get_allocated_width");
+        fp_gtk_widget_get_allocated_height =
+                      dl_symbol("gtk_widget_get_allocated_height");
+        fp_gtk_icon_theme_get_default = dl_symbol("gtk_icon_theme_get_default");
+        fp_gtk_icon_theme_load_icon = dl_symbol("gtk_icon_theme_load_icon");
+
+        fp_gtk_adjustment_set_lower = dl_symbol("gtk_adjustment_set_lower");
+        fp_gtk_adjustment_set_page_increment =
+                      dl_symbol("gtk_adjustment_set_page_increment");
+        fp_gtk_adjustment_set_page_size =
+                      dl_symbol("gtk_adjustment_set_page_size");
+        fp_gtk_adjustment_set_step_increment =
+                      dl_symbol("gtk_adjustment_set_step_increment");
+        fp_gtk_adjustment_set_upper = dl_symbol("gtk_adjustment_set_upper");
+        fp_gtk_adjustment_set_value = dl_symbol("gtk_adjustment_set_value");
+
+        fp_gtk_render_activity = dl_symbol("gtk_render_activity");
+        fp_gtk_render_background = dl_symbol("gtk_render_background");
+        fp_gtk_style_context_has_class =
+                      dl_symbol("gtk_style_context_has_class");
+
+        fp_gtk_style_context_set_junction_sides =
+                      dl_symbol("gtk_style_context_set_junction_sides");
+        fp_gtk_style_context_add_region =
+                      dl_symbol("gtk_style_context_add_region");
+
+        fp_gtk_init_check = dl_symbol("gtk_init_check");
+
+        /* GTK widgets */
+        fp_gtk_arrow_new = dl_symbol("gtk_arrow_new");
+        fp_gtk_button_new = dl_symbol("gtk_button_new");
+        fp_gtk_spin_button_new = dl_symbol("gtk_spin_button_new");
+        fp_gtk_check_button_new = dl_symbol("gtk_check_button_new");
+        fp_gtk_check_menu_item_new =
+                dl_symbol("gtk_check_menu_item_new");
+        fp_gtk_color_selection_dialog_new =
+                dl_symbol("gtk_color_selection_dialog_new");
+        fp_gtk_entry_new = dl_symbol("gtk_entry_new");
+        fp_gtk_fixed_new = dl_symbol("gtk_fixed_new");
+        fp_gtk_handle_box_new = dl_symbol("gtk_handle_box_new");
+        fp_gtk_image_new = dl_symbol("gtk_image_new");
+        fp_gtk_hpaned_new = dl_symbol("gtk_hpaned_new");
+        fp_gtk_vpaned_new = dl_symbol("gtk_vpaned_new");
+        fp_gtk_scale_new = dl_symbol("gtk_scale_new");
+        fp_gtk_hscrollbar_new = dl_symbol("gtk_hscrollbar_new");
+        fp_gtk_vscrollbar_new = dl_symbol("gtk_vscrollbar_new");
+        fp_gtk_hseparator_new = dl_symbol("gtk_hseparator_new");
+        fp_gtk_vseparator_new = dl_symbol("gtk_vseparator_new");
+        fp_gtk_label_new = dl_symbol("gtk_label_new");
+        fp_gtk_menu_new = dl_symbol("gtk_menu_new");
+        fp_gtk_menu_bar_new = dl_symbol("gtk_menu_bar_new");
+        fp_gtk_menu_item_new = dl_symbol("gtk_menu_item_new");
+        fp_gtk_menu_item_set_submenu =
+                dl_symbol("gtk_menu_item_set_submenu");
+        fp_gtk_notebook_new = dl_symbol("gtk_notebook_new");
+        fp_gtk_progress_bar_new =
+            dl_symbol("gtk_progress_bar_new");
+        fp_gtk_progress_bar_set_orientation =
+            dl_symbol("gtk_orientable_set_orientation");
+        fp_gtk_radio_button_new =
+            dl_symbol("gtk_radio_button_new");
+        fp_gtk_radio_menu_item_new =
+            dl_symbol("gtk_radio_menu_item_new");
+        fp_gtk_scrolled_window_new =
+            dl_symbol("gtk_scrolled_window_new");
+        fp_gtk_separator_menu_item_new =
+            dl_symbol("gtk_separator_menu_item_new");
+        fp_gtk_text_view_new = dl_symbol("gtk_text_view_new");
+        fp_gtk_toggle_button_new =
+            dl_symbol("gtk_toggle_button_new");
+        fp_gtk_toolbar_new = dl_symbol("gtk_toolbar_new");
+        fp_gtk_tree_view_new = dl_symbol("gtk_tree_view_new");
+        fp_gtk_viewport_new = dl_symbol("gtk_viewport_new");
+        fp_gtk_window_new = dl_symbol("gtk_window_new");
+        fp_gtk_window_present = dl_symbol("gtk_window_present");
+        fp_gtk_window_move = dl_symbol("gtk_window_move");
+        fp_gtk_window_resize = dl_symbol("gtk_window_resize");
+
+          fp_gtk_dialog_new = dl_symbol("gtk_dialog_new");
+        fp_gtk_frame_new = dl_symbol("gtk_frame_new");
+
+        fp_gtk_adjustment_new = dl_symbol("gtk_adjustment_new");
+        fp_gtk_container_add = dl_symbol("gtk_container_add");
+        fp_gtk_menu_shell_append =
+            dl_symbol("gtk_menu_shell_append");
+        fp_gtk_widget_realize = dl_symbol("gtk_widget_realize");
+        fp_gtk_widget_destroy = dl_symbol("gtk_widget_destroy");
+        fp_gtk_widget_render_icon =
+            dl_symbol("gtk_widget_render_icon");
+        fp_gtk_widget_set_name =
+            dl_symbol("gtk_widget_set_name");
+        fp_gtk_widget_set_parent =
+            dl_symbol("gtk_widget_set_parent");
+        fp_gtk_widget_set_direction =
+            dl_symbol("gtk_widget_set_direction");
+        fp_gtk_widget_style_get =
+            dl_symbol("gtk_widget_style_get");
+        fp_gtk_widget_class_install_style_property =
+            dl_symbol("gtk_widget_class_install_style_property");
+        fp_gtk_widget_class_find_style_property =
+            dl_symbol("gtk_widget_class_find_style_property");
+        fp_gtk_widget_style_get_property =
+            dl_symbol("gtk_widget_style_get_property");
+        fp_pango_font_description_to_string =
+            dl_symbol("pango_font_description_to_string");
+        fp_gtk_settings_get_default =
+            dl_symbol("gtk_settings_get_default");
+        fp_gtk_widget_get_settings =
+            dl_symbol("gtk_widget_get_settings");
+        fp_gtk_border_get_type =  dl_symbol("gtk_border_get_type");
+        fp_gtk_arrow_set = dl_symbol("gtk_arrow_set");
+        fp_gtk_widget_size_request =
+            dl_symbol("gtk_widget_size_request");
+        fp_gtk_range_get_adjustment =
+            dl_symbol("gtk_range_get_adjustment");
+
+        fp_gtk_widget_hide = dl_symbol("gtk_widget_hide");
+        fp_gtk_main_quit = dl_symbol("gtk_main_quit");
+        fp_g_signal_connect_data = dl_symbol("g_signal_connect_data");
+        fp_gtk_widget_show = dl_symbol("gtk_widget_show");
+        fp_gtk_main = dl_symbol("gtk_main");
+
+        fp_g_path_get_dirname = dl_symbol("g_path_get_dirname");
+
+        fp_gdk_threads_enter = &empty;
+        fp_gdk_threads_leave = &empty;
+
+        /**
+         * Functions for sun_awt_X11_GtkFileDialogPeer.c
+         */
+        gtk3_file_chooser_load();
+
+        fp_gtk_combo_box_new = dlsym(gtk3_libhandle, "gtk_combo_box_new");
+        fp_gtk_combo_box_entry_new = dlsym(gtk3_libhandle,
+                                                "gtk_combo_box_new_with_entry");
+        fp_gtk_separator_tool_item_new = dlsym(gtk3_libhandle,
+                                                 "gtk_separator_tool_item_new");
+
+        fp_g_list_append = dl_symbol("g_list_append");
+        fp_g_list_free = dl_symbol("g_list_free");
+        fp_g_list_free_full = dl_symbol("g_list_free_full");
+    }
+    /* Now we have only one kind of exceptions: NO_SYMBOL_EXCEPTION
+     * Otherwise we can check the return value of setjmp method.
+     */
+    else
+    {
+        dlclose(gtk3_libhandle);
+        gtk3_libhandle = NULL;
+
+        return NULL;
+    }
+
+    /*
+     * Strip the AT-SPI GTK_MODULEs if present
+     */
+    gtk_modules_env = getenv ("GTK_MODULES");
+    if (gtk_modules_env && strstr (gtk_modules_env, "atk-bridge") ||
+        gtk_modules_env && strstr (gtk_modules_env, "gail"))
+    {
+        /* the new env will be smaller than the old one */
+        gchar *s, *new_env = SAFE_SIZE_STRUCT_ALLOC(malloc,
+                sizeof(ENV_PREFIX), 1, strlen (gtk_modules_env));
+
+        if (new_env != NULL )
+        {
+            /* careful, strtok modifies its args */
+            gchar *tmp_env = strdup (gtk_modules_env);
+            strcpy(new_env, ENV_PREFIX);
+
+            /* strip out 'atk-bridge' and 'gail' */
+            size_t PREFIX_LENGTH = strlen(ENV_PREFIX);
+            while (s = strtok(tmp_env, ":"))
+            {
+                if ((!strstr (s, "atk-bridge")) && (!strstr (s, "gail")))
+                {
+                    if (strlen (new_env) > PREFIX_LENGTH) {
+                        new_env = strcat (new_env, ":");
+                    }
+                    new_env = strcat(new_env, s);
+                }
+                if (tmp_env)
+                {
+                    free (tmp_env);
+                    tmp_env = NULL; /* next call to strtok arg1==NULL */
+                }
+            }
+            putenv (new_env);
+            free (new_env);
+            free (tmp_env);
+        }
+    }
+    /*
+     * GTK should be initialized with gtk_init_check() before use.
+     *
+     * gtk_init_check installs its own error handlers. It is critical that
+     * we preserve error handler set from AWT. Otherwise we'll crash on
+     * BadMatch errors which we would normally ignore. The IO error handler
+     * is preserved here, too, just for consistency.
+    */
+    AWT_LOCK();
+    handler = XSetErrorHandler(NULL);
+    io_handler = XSetIOErrorHandler(NULL);
+    result = (*fp_gtk_init_check)(NULL, NULL);
+    XSetErrorHandler(handler);
+    XSetIOErrorHandler(io_handler);
+    AWT_UNLOCK();
+    /* Initialize widget array. */
+    for (i = 0; i < _GTK_WIDGET_TYPE_SIZE; i++)
+    {
+        gtk3_widgets[i] = NULL;
+    }
+    if (result) {
+        GtkApi* gtk = (GtkApi*)malloc(sizeof(GtkApi));
+        gtk3_init(gtk);
+        return gtk;
+    }
+    return NULL;
+}
+
+static int gtk3_unload()
+{
+    int i;
+    char *gtk3_error;
+
+    if (!gtk3_libhandle)
+        return TRUE;
+
+    /* Release painting objects */
+    if (surface != NULL) {
+        fp_cairo_destroy(cr);
+        fp_cairo_surface_destroy(surface);
+        surface = NULL;
+    }
+
+    if (gtk3_window != NULL) {
+        /* Destroying toplevel widget will destroy all contained widgets */
+        (*fp_gtk_widget_destroy)(gtk3_window);
+
+        /* Unset some static data so they get reinitialized on next load */
+        gtk3_window = NULL;
+    }
+
+    dlerror();
+    dlclose(gtk3_libhandle);
+    if ((gtk3_error = dlerror()) != NULL)
+    {
+        return FALSE;
+    }
+    return TRUE;
+}
+
+/* Dispatch all pending events from the GTK event loop.
+ * This is needed to catch theme change and update widgets' style.
+ */
+static void flush_gtk_event_loop()
+{
+    while((*fp_g_main_context_iteration)(NULL));
+}
+
+/*
+ * Initialize components of containment hierarchy. This creates a GtkFixed
+ * inside a GtkWindow. All widgets get realized.
+ */
+static void init_containers()
+{
+    if (gtk3_window == NULL)
+    {
+        gtk3_window = (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL);
+        gtk3_fixed = (GtkFixed *)(*fp_gtk_fixed_new)();
+        (*fp_gtk_container_add)((GtkContainer*)gtk3_window,
+                                (GtkWidget *)gtk3_fixed);
+        (*fp_gtk_widget_realize)(gtk3_window);
+        (*fp_gtk_widget_realize)((GtkWidget *)gtk3_fixed);
+
+        GtkSettings* settings = fp_gtk_settings_get_for_screen(
+                                         fp_gtk_widget_get_screen(gtk3_window));
+        gchar*  strval = NULL;
+        fp_g_object_get(settings, "gtk-theme-name", &strval, NULL);
+        gtk3_css = fp_gtk_css_provider_get_named(strval, NULL);
+    }
+}
+
+/*
+ * Ensure everything is ready for drawing an element of the specified width
+ * and height.
+ *
+ * We should somehow handle translucent images. GTK can draw to X Drawables
+ * only, which don't support alpha. When we retrieve the image back from
+ * the server, translucency information is lost. There're several ways to
+ * work around this:
+ * 1) Subclass GdkPixmap and cache translucent objects on client side. This
+ * requires us to implement parts of X server drawing logic on client side.
+ * Many X requests can potentially be "translucent"; e.g. XDrawLine with
+ * fill=tile and a translucent tile is a "translucent" operation, whereas
+ * XDrawLine with fill=solid is an "opaque" one. Moreover themes can (and some
+ * do) intermix transparent and opaque operations which makes caching even
+ * more problematic.
+ * 2) Use Xorg 32bit ARGB visual when available. GDK has no native support
+ * for it (as of version 2.6). Also even in JDS 3 Xorg does not support
+ * these visuals by default, which makes optimizing for them pointless.
+ * We can consider doing this at a later point when ARGB visuals become more
+ * popular.
+ * 3') GTK has plans to use Cairo as its graphical backend (presumably in
+ * 2.8), and Cairo supports alpha. With it we could also get rid of the
+ * unnecessary round trip to server and do all the drawing on client side.
+ * 4) For now we draw to two different pixmaps and restore alpha channel by
+ * comparing results. This can be optimized by using subclassed pixmap and
+*/
+static void gtk3_init_painting(JNIEnv *env, gint width, gint height)
+{
+    init_containers();
+
+    if (cr) {
+        fp_cairo_destroy(cr);
+    }
+
+    if (surface != NULL) {
+        /* free old stuff */
+        fp_cairo_surface_destroy(surface);
+
+    }
+
+    if (gtk3_version_3_10) {
+        surface = fp_gdk_window_create_similar_image_surface(
+                           fp_gtk_widget_get_window(gtk3_window),
+                                         CAIRO_FORMAT_ARGB32, width, height, 1);
+    } else {
+        surface = fp_cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+                                                                 width, height);
+    }
+
+    cr = fp_cairo_create(surface);
+}
+
+/*
+ * Restore image from white and black pixmaps and copy it into destination
+ * buffer. This method compares two pixbufs taken from white and black
+ * pixmaps and decodes color and alpha components. Pixbufs are RGB without
+ * alpha, destination buffer is ABGR.
+ *
+ * The return value is the transparency type of the resulting image, either
+ * one of java_awt_Transparency_OPAQUE, java_awt_Transparency_BITMASK, and
+ * java_awt_Transparency_TRANSLUCENT.
+ */
+static gint gtk3_copy_image(gint *dst, gint width, gint height)
+{
+    gint i, j, r, g, b;
+    guchar *data;
+    gint stride, padding;
+
+    fp_cairo_surface_flush(surface);
+    data = (*fp_cairo_image_surface_get_data)(surface);
+    stride = (*fp_cairo_image_surface_get_stride)(surface);
+    padding = stride - width * 4;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++) {
+            int r = *data++;
+            int g = *data++;
+            int b = *data++;
+            int a = *data++;
+            *dst++ = (a << 24 | b << 16 | g << 8 | r);
+        }
+        data += padding;
+    }
+    return java_awt_Transparency_TRANSLUCENT;
+}
+
+static void gtk3_set_direction(GtkWidget *widget, GtkTextDirection dir)
+{
+    /*
+     * Some engines (inexplicably) look at the direction of the widget's
+     * parent, so we need to set the direction of both the widget and its
+     * parent.
+     */
+    (*fp_gtk_widget_set_direction)(widget, dir);
+    GtkWidget* parent = fp_gtk_widget_get_parent(widget);
+    if (parent != NULL) {
+        fp_gtk_widget_set_direction(parent, dir);
+    }
+}
+
+/* GTK state_type filter */
+static GtkStateType get_gtk_state_type(WidgetType widget_type, gint synth_state)
+{
+    GtkStateType result = GTK_STATE_NORMAL;
+
+    if ((synth_state & DISABLED) != 0) {
+        result = GTK_STATE_INSENSITIVE;
+    } else if ((synth_state & PRESSED) != 0) {
+        result = GTK_STATE_ACTIVE;
+    } else if ((synth_state & MOUSE_OVER) != 0) {
+        result = GTK_STATE_PRELIGHT;
+    }
+    return result;
+}
+
+static GtkStateFlags get_gtk_state_flags(gint synth_state)
+{
+    GtkStateFlags flags = 0;
+
+    if ((synth_state & DISABLED) != 0) {
+        flags |= GTK_STATE_FLAG_INSENSITIVE;
+    }
+    if (((synth_state & PRESSED) != 0 || (synth_state & SELECTED) != 0)) {
+        flags |= GTK_STATE_FLAG_ACTIVE;
+    }
+    if ((synth_state & MOUSE_OVER) != 0) {
+        flags |= GTK_STATE_FLAG_PRELIGHT;
+    }
+    if ((synth_state & FOCUSED) != 0) {
+        flags |= GTK_STATE_FLAG_FOCUSED;
+    }
+    return flags;
+}
+
+static GtkStateFlags get_gtk_flags(GtkStateType state_type) {
+    GtkStateFlags flags = 0;
+    switch (state_type)
+    {
+        case GTK_STATE_PRELIGHT:
+          flags |= GTK_STATE_FLAG_PRELIGHT;
+          break;
+        case GTK_STATE_SELECTED:
+          flags |= GTK_STATE_FLAG_SELECTED;
+          break;
+        case GTK_STATE_INSENSITIVE:
+          flags |= GTK_STATE_FLAG_INSENSITIVE;
+          break;
+        case GTK_STATE_ACTIVE:
+          flags |= GTK_STATE_FLAG_ACTIVE;
+          break;
+        case GTK_STATE_FOCUSED:
+          flags |= GTK_STATE_FLAG_FOCUSED;
+          break;
+        default:
+          break;
+    }
+    return flags;
+}
+
+/* GTK shadow_type filter */
+static GtkShadowType get_gtk_shadow_type(WidgetType widget_type,
+                                                               gint synth_state)
+{
+    GtkShadowType result = GTK_SHADOW_OUT;
+
+    if ((synth_state & SELECTED) != 0) {
+        result = GTK_SHADOW_IN;
+    }
+    return result;
+}
+
+
+static GtkWidget* gtk3_get_arrow(GtkArrowType arrow_type,
+                                                      GtkShadowType shadow_type)
+{
+    GtkWidget *arrow = NULL;
+    if (NULL == gtk3_widgets[_GTK_ARROW_TYPE])
+    {
+        gtk3_widgets[_GTK_ARROW_TYPE] = (*fp_gtk_arrow_new)(arrow_type,
+                                                                   shadow_type);
+        (*fp_gtk_container_add)((GtkContainer *)gtk3_fixed,
+                                                 gtk3_widgets[_GTK_ARROW_TYPE]);
+        (*fp_gtk_widget_realize)(gtk3_widgets[_GTK_ARROW_TYPE]);
+    }
+    arrow = gtk3_widgets[_GTK_ARROW_TYPE];
+
+    (*fp_gtk_arrow_set)(arrow, arrow_type, shadow_type);
+    return arrow;
+}
+
+static GtkAdjustment* create_adjustment()
+{
+    return (GtkAdjustment *)
+            (*fp_gtk_adjustment_new)(50.0, 0.0, 100.0, 10.0, 20.0, 20.0);
+}
+
+/**
+ * Returns a pointer to the cached native widget for the specified widget
+ * type.
+ */
+static GtkWidget *gtk3_get_widget(WidgetType widget_type)
+{
+    gboolean init_result = FALSE;
+    GtkWidget *result = NULL;
+    switch (widget_type)
+    {
+        case BUTTON:
+        case TABLE_HEADER:
+            if (init_result = (NULL == gtk3_widgets[_GTK_BUTTON_TYPE]))
+            {
+                gtk3_widgets[_GTK_BUTTON_TYPE] = (*fp_gtk_button_new)();
+            }
+            result = gtk3_widgets[_GTK_BUTTON_TYPE];
+            break;
+        case CHECK_BOX:
+            if (init_result = (NULL == gtk3_widgets[_GTK_CHECK_BUTTON_TYPE]))
+            {
+                gtk3_widgets[_GTK_CHECK_BUTTON_TYPE] =
+                    (*fp_gtk_check_button_new)();
+            }
+            result = gtk3_widgets[_GTK_CHECK_BUTTON_TYPE];
+            break;
+        case CHECK_BOX_MENU_ITEM:
+            if (init_result = (NULL == gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE]))
+            {
+                gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE] =
+                    (*fp_gtk_check_menu_item_new)();
+            }
+            result = gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE];
+            break;
+        /************************************************************
+         *    Creation a dedicated color chooser is dangerous because
+         * it deadlocks the EDT
+         ************************************************************/
+/*        case COLOR_CHOOSER:
+            if (init_result =
+                    (NULL == gtk3_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE]))
+            {
+                gtk3_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE] =
+                    (*fp_gtk_color_selection_dialog_new)(NULL);
+            }
+            result = gtk3_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE];
+            break;*/
+        case COMBO_BOX:
+            if (init_result = (NULL == gtk3_widgets[_GTK_COMBO_BOX_TYPE]))
+            {
+                gtk3_widgets[_GTK_COMBO_BOX_TYPE] =
+                    (*fp_gtk_combo_box_new)();
+            }
+            result = gtk3_widgets[_GTK_COMBO_BOX_TYPE];
+            break;
+        case COMBO_BOX_ARROW_BUTTON:
+            if (init_result =
+                    (NULL == gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE]))
+            {
+                gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE] =
+                     (*fp_gtk_toggle_button_new)();
+            }
+            result = gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE];
+            break;
+        case COMBO_BOX_TEXT_FIELD:
+            if (init_result =
+                    (NULL == gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE]))
+            {
+                result = gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE] =
+                     (*fp_gtk_entry_new)();
+            }
+            result = gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE];
+            break;
+        case DESKTOP_ICON:
+        case INTERNAL_FRAME_TITLE_PANE:
+        case LABEL:
+            if (init_result = (NULL == gtk3_widgets[_GTK_LABEL_TYPE]))
+            {
+                gtk3_widgets[_GTK_LABEL_TYPE] =
+                    (*fp_gtk_label_new)(NULL);
+            }
+            result = gtk3_widgets[_GTK_LABEL_TYPE];
+            break;
+        case DESKTOP_PANE:
+        case PANEL:
+        case ROOT_PANE:
+            if (init_result = (NULL == gtk3_widgets[_GTK_CONTAINER_TYPE]))
+            {
+                /* There is no constructor for a container type.  I've
+                 * chosen GtkFixed container since it has a default
+                 * constructor.
+                 */
+                gtk3_widgets[_GTK_CONTAINER_TYPE] =
+                    (*fp_gtk_fixed_new)();
+            }
+            result = gtk3_widgets[_GTK_CONTAINER_TYPE];
+            break;
+        case EDITOR_PANE:
+        case TEXT_AREA:
+        case TEXT_PANE:
+            if (init_result = (NULL == gtk3_widgets[_GTK_TEXT_VIEW_TYPE]))
+            {
+                gtk3_widgets[_GTK_TEXT_VIEW_TYPE] =
+                    (*fp_gtk_text_view_new)();
+            }
+            result = gtk3_widgets[_GTK_TEXT_VIEW_TYPE];
+            break;
+        case FORMATTED_TEXT_FIELD:
+        case PASSWORD_FIELD:
+        case TEXT_FIELD:
+            if (init_result = (NULL == gtk3_widgets[_GTK_ENTRY_TYPE]))
+            {
+                gtk3_widgets[_GTK_ENTRY_TYPE] =
+                    (*fp_gtk_entry_new)();
+            }
+            result = gtk3_widgets[_GTK_ENTRY_TYPE];
+            break;
+        case HANDLE_BOX:
+            if (init_result = (NULL == gtk3_widgets[_GTK_HANDLE_BOX_TYPE]))
+            {
+                gtk3_widgets[_GTK_HANDLE_BOX_TYPE] =
+                    (*fp_gtk_handle_box_new)();
+            }
+            result = gtk3_widgets[_GTK_HANDLE_BOX_TYPE];
+            break;
+        case HSCROLL_BAR:
+        case HSCROLL_BAR_BUTTON_LEFT:
+        case HSCROLL_BAR_BUTTON_RIGHT:
+        case HSCROLL_BAR_TRACK:
+        case HSCROLL_BAR_THUMB:
+            if (init_result = (NULL == gtk3_widgets[_GTK_HSCROLLBAR_TYPE]))
+            {
+                gtk3_widgets[_GTK_HSCROLLBAR_TYPE] =
+                    (*fp_gtk_hscrollbar_new)(create_adjustment());
+            }
+            result = gtk3_widgets[_GTK_HSCROLLBAR_TYPE];
+            break;
+        case HSEPARATOR:
+            if (init_result = (NULL == gtk3_widgets[_GTK_HSEPARATOR_TYPE]))
+            {
+                gtk3_widgets[_GTK_HSEPARATOR_TYPE] =
+                    (*fp_gtk_hseparator_new)();
+            }
+            result = gtk3_widgets[_GTK_HSEPARATOR_TYPE];
+            break;
+        case HSLIDER:
+        case HSLIDER_THUMB:
+        case HSLIDER_TRACK:
+            if (init_result = (NULL == gtk3_widgets[_GTK_HSCALE_TYPE]))
+            {
+                gtk3_widgets[_GTK_HSCALE_TYPE] =
+                    (*fp_gtk_scale_new)(GTK_ORIENTATION_HORIZONTAL, NULL);
+            }
+            result = gtk3_widgets[_GTK_HSCALE_TYPE];
+            break;
+        case HSPLIT_PANE_DIVIDER:
+        case SPLIT_PANE:
+            if (init_result = (NULL == gtk3_widgets[_GTK_HPANED_TYPE]))
+            {
+                gtk3_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_hpaned_new)();
+            }
+            result = gtk3_widgets[_GTK_HPANED_TYPE];
+            break;
+        case IMAGE:
+            if (init_result = (NULL == gtk3_widgets[_GTK_IMAGE_TYPE]))
+            {
+                gtk3_widgets[_GTK_IMAGE_TYPE] = (*fp_gtk_image_new)();
+            }
+            result = gtk3_widgets[_GTK_IMAGE_TYPE];
+            break;
+        case INTERNAL_FRAME:
+            if (init_result = (NULL == gtk3_widgets[_GTK_WINDOW_TYPE]))
+            {
+                gtk3_widgets[_GTK_WINDOW_TYPE] =
+                    (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL);
+            }
+            result = gtk3_widgets[_GTK_WINDOW_TYPE];
+            break;
+        case TOOL_TIP:
+            if (init_result = (NULL == gtk3_widgets[_GTK_TOOLTIP_TYPE]))
+            {
+                result = (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL);
+                gtk3_widgets[_GTK_TOOLTIP_TYPE] = result;
+            }
+            result = gtk3_widgets[_GTK_TOOLTIP_TYPE];
+            break;
+        case LIST:
+        case TABLE:
+        case TREE:
+        case TREE_CELL:
+            if (init_result = (NULL == gtk3_widgets[_GTK_TREE_VIEW_TYPE]))
+            {
+                gtk3_widgets[_GTK_TREE_VIEW_TYPE] =
+                    (*fp_gtk_tree_view_new)();
+            }
+            result = gtk3_widgets[_GTK_TREE_VIEW_TYPE];
+            break;
+        case TITLED_BORDER:
+            if (init_result = (NULL == gtk3_widgets[_GTK_FRAME_TYPE]))
+            {
+                gtk3_widgets[_GTK_FRAME_TYPE] = fp_gtk_frame_new(NULL);
+            }
+            result = gtk3_widgets[_GTK_FRAME_TYPE];
+            break;
+        case POPUP_MENU:
+            if (init_result = (NULL == gtk3_widgets[_GTK_MENU_TYPE]))
+            {
+                gtk3_widgets[_GTK_MENU_TYPE] =
+                    (*fp_gtk_menu_new)();
+            }
+            result = gtk3_widgets[_GTK_MENU_TYPE];
+            break;
+        case MENU:
+        case MENU_ITEM:
+        case MENU_ITEM_ACCELERATOR:
+            if (init_result = (NULL == gtk3_widgets[_GTK_MENU_ITEM_TYPE]))
+            {
+                gtk3_widgets[_GTK_MENU_ITEM_TYPE] =
+                    (*fp_gtk_menu_item_new)();
+            }
+            result = gtk3_widgets[_GTK_MENU_ITEM_TYPE];
+            break;
+        case MENU_BAR:
+            if (init_result = (NULL == gtk3_widgets[_GTK_MENU_BAR_TYPE]))
+            {
+                gtk3_widgets[_GTK_MENU_BAR_TYPE] =
+                    (*fp_gtk_menu_bar_new)();
+            }
+            result = gtk3_widgets[_GTK_MENU_BAR_TYPE];
+            break;
+        case COLOR_CHOOSER:
+        case OPTION_PANE:
+            if (init_result = (NULL == gtk3_widgets[_GTK_DIALOG_TYPE]))
+            {
+                gtk3_widgets[_GTK_DIALOG_TYPE] =
+                    (*fp_gtk_dialog_new)();
+            }
+            result = gtk3_widgets[_GTK_DIALOG_TYPE];
+            break;
+        case POPUP_MENU_SEPARATOR:
+            if (init_result =
+                    (NULL == gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE]))
+            {
+                gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE] =
+                    (*fp_gtk_separator_menu_item_new)();
+            }
+            result = gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE];
+            break;
+        case HPROGRESS_BAR:
+            if (init_result = (NULL == gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE]))
+            {
+                gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE] =
+                    (*fp_gtk_progress_bar_new)();
+            }
+            result = gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE];
+            break;
+        case VPROGRESS_BAR:
+            if (init_result = (NULL == gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE]))
+            {
+                gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE] =
+                    (*fp_gtk_progress_bar_new)();
+                /*
+                 * Vertical JProgressBars always go bottom-to-top,
+                 * regardless of the ComponentOrientation.
+                 */
+                (*fp_gtk_progress_bar_set_orientation)(
+                    (GtkProgressBar *)gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE],
+                    GTK_PROGRESS_BOTTOM_TO_TOP);
+            }
+            result = gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE];
+            break;
+        case RADIO_BUTTON:
+            if (init_result = (NULL == gtk3_widgets[_GTK_RADIO_BUTTON_TYPE]))
+            {
+                gtk3_widgets[_GTK_RADIO_BUTTON_TYPE] =
+                    (*fp_gtk_radio_button_new)(NULL);
+            }
+            result = gtk3_widgets[_GTK_RADIO_BUTTON_TYPE];
+            break;
+        case RADIO_BUTTON_MENU_ITEM:
+            if (init_result =
+                    (NULL == gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE]))
+            {
+                gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE] =
+                    (*fp_gtk_radio_menu_item_new)(NULL);
+            }
+            result = gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE];
+            break;
+        case SCROLL_PANE:
+            if (init_result =
+                    (NULL == gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE]))
+            {
+                gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE] =
+                    (*fp_gtk_scrolled_window_new)(NULL, NULL);
+            }
+            result = gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE];
+            break;
+        case SPINNER:
+        case SPINNER_ARROW_BUTTON:
+        case SPINNER_TEXT_FIELD:
+            if (init_result = (NULL == gtk3_widgets[_GTK_SPIN_BUTTON_TYPE]))
+            {
+                result = gtk3_widgets[_GTK_SPIN_BUTTON_TYPE] =
+                    (*fp_gtk_spin_button_new)(NULL, 0, 0);
+            }
+            result = gtk3_widgets[_GTK_SPIN_BUTTON_TYPE];
+            break;
+        case TABBED_PANE:
+        case TABBED_PANE_TAB_AREA:
+        case TABBED_PANE_CONTENT:
+        case TABBED_PANE_TAB:
+            if (init_result = (NULL == gtk3_widgets[_GTK_NOTEBOOK_TYPE]))
+            {
+                gtk3_widgets[_GTK_NOTEBOOK_TYPE] =
+                    (*fp_gtk_notebook_new)(NULL);
+            }
+            result = gtk3_widgets[_GTK_NOTEBOOK_TYPE];
+            break;
+        case TOGGLE_BUTTON:
+            if (init_result = (NULL == gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE]))
+            {
+                gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE] =
+                    (*fp_gtk_toggle_button_new)(NULL);
+            }
+            result = gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE];
+            break;
+        case TOOL_BAR:
+        case TOOL_BAR_DRAG_WINDOW:
+            if (init_result = (NULL == gtk3_widgets[_GTK_TOOLBAR_TYPE]))
+            {
+                gtk3_widgets[_GTK_TOOLBAR_TYPE] =
+                    (*fp_gtk_toolbar_new)(NULL);
+            }
+            result = gtk3_widgets[_GTK_TOOLBAR_TYPE];
+            break;
+        case TOOL_BAR_SEPARATOR:
+            if (init_result =
+                    (NULL == gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE]))
+            {
+                gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE] =
+                    (*fp_gtk_separator_tool_item_new)();
+            }
+            result = gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE];
+            break;
+        case VIEWPORT:
+            if (init_result = (NULL == gtk3_widgets[_GTK_VIEWPORT_TYPE]))
+            {
+                GtkAdjustment *adjustment = create_adjustment();
+                gtk3_widgets[_GTK_VIEWPORT_TYPE] =
+                    (*fp_gtk_viewport_new)(adjustment, adjustment);
+            }
+            result = gtk3_widgets[_GTK_VIEWPORT_TYPE];
+            break;
+        case VSCROLL_BAR:
+        case VSCROLL_BAR_BUTTON_UP:
+        case VSCROLL_BAR_BUTTON_DOWN:
+        case VSCROLL_BAR_TRACK:
+        case VSCROLL_BAR_THUMB:
+            if (init_result = (NULL == gtk3_widgets[_GTK_VSCROLLBAR_TYPE]))
+            {
+                gtk3_widgets[_GTK_VSCROLLBAR_TYPE] =
+                    (*fp_gtk_vscrollbar_new)(create_adjustment());
+            }
+            result = gtk3_widgets[_GTK_VSCROLLBAR_TYPE];
+            break;
+        case VSEPARATOR:
+            if (init_result = (NULL == gtk3_widgets[_GTK_VSEPARATOR_TYPE]))
+            {
+                gtk3_widgets[_GTK_VSEPARATOR_TYPE] =
+                    (*fp_gtk_vseparator_new)();
+            }
+            result = gtk3_widgets[_GTK_VSEPARATOR_TYPE];
+            break;
+        case VSLIDER:
+        case VSLIDER_THUMB:
+        case VSLIDER_TRACK:
+            if (init_result = (NULL == gtk3_widgets[_GTK_VSCALE_TYPE]))
+            {
+                gtk3_widgets[_GTK_VSCALE_TYPE] =
+                    (*fp_gtk_scale_new)(GTK_ORIENTATION_VERTICAL, NULL);
+            }
+            result = gtk3_widgets[_GTK_VSCALE_TYPE];
+            /*
+             * Vertical JSliders start at the bottom, while vertical
+             * GtkVScale widgets start at the top (by default), so to fix
+             * this we set the "inverted" flag to get the Swing behavior.
+             */
+             fp_gtk_range_set_inverted((GtkRange*)result, TRUE);
+            break;
+        case VSPLIT_PANE_DIVIDER:
+            if (init_result = (NULL == gtk3_widgets[_GTK_VPANED_TYPE]))
+            {
+                gtk3_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_vpaned_new)();
+            }
+            result = gtk3_widgets[_GTK_VPANED_TYPE];
+            break;
+        default:
+            result = NULL;
+            break;
+    }
+
+    if (result != NULL && init_result)
+    {
+        if (widget_type == RADIO_BUTTON_MENU_ITEM ||
+                widget_type == CHECK_BOX_MENU_ITEM ||
+                widget_type == MENU_ITEM ||
+                widget_type == MENU ||
+                widget_type == POPUP_MENU_SEPARATOR)
+        {
+            GtkWidget *menu = gtk3_get_widget(POPUP_MENU);
+            (*fp_gtk_menu_shell_append)((GtkMenuShell *)menu, result);
+        }
+        else if (widget_type == POPUP_MENU)
+        {
+            GtkWidget *menu_bar = gtk3_get_widget(MENU_BAR);
+            GtkWidget *root_menu = (*fp_gtk_menu_item_new)();
+            (*fp_gtk_menu_item_set_submenu)((GtkMenuItem*)root_menu, result);
+            (*fp_gtk_menu_shell_append)((GtkMenuShell *)menu_bar, root_menu);
+        }
+        else if (widget_type == COMBO_BOX_TEXT_FIELD )
+        {
+            GtkWidget* combo = gtk3_get_widget(COMBO_BOX);
+
+            /*
+            * We add a regular GtkButton/GtkEntry to a GtkComboBoxEntry
+            * in order to trick engines into thinking it's a real combobox
+            * arrow button/text field.
+            */
+
+            fp_gtk_container_add ((GtkContainer*)(combo), result);
+            GtkStyleContext* context = fp_gtk_widget_get_style_context (combo);
+            fp_gtk_style_context_add_class (context, "combobox-entry");
+            context = fp_gtk_widget_get_style_context (result);
+            fp_gtk_style_context_add_class (context, "combobox");
+            fp_gtk_style_context_add_class (context, "entry");
+        }
+        else if (widget_type == COMBO_BOX_ARROW_BUTTON )
+        {
+            GtkWidget* combo = gtk3_get_widget(COMBO_BOX);
+            fp_gtk_widget_set_parent(result, combo);
+        }
+        else if (widget_type != TOOL_TIP &&
+                 widget_type != INTERNAL_FRAME &&
+                 widget_type != OPTION_PANE)
+        {
+            (*fp_gtk_container_add)((GtkContainer *)gtk3_fixed, result);
+        }
+        (*fp_gtk_widget_realize)(result);
+    }
+    return result;
+}
+
+static void gtk3_paint_arrow(WidgetType widget_type, GtkStateType state_type,
+        GtkShadowType shadow_type, const gchar *detail,
+        gint x, gint y, gint width, gint height,
+        GtkArrowType arrow_type, gboolean fill)
+{
+    gdouble xx, yy, a = G_PI;
+    int s = width;
+    gtk3_widget = gtk3_get_arrow(arrow_type, shadow_type);
+
+    switch (widget_type)
+    {
+        case SPINNER_ARROW_BUTTON:
+            s = (int)(0.4 * width + 0.5) + 1;
+            if (arrow_type == GTK_ARROW_UP) {
+                a = 0;
+            } else if (arrow_type == GTK_ARROW_DOWN) {
+                a = G_PI;
+            }
+            break;
+
+        case HSCROLL_BAR_BUTTON_LEFT:
+            s = (int)(0.5 * MIN(height, width * 2) + 0.5) + 1;
+            a = 3 * G_PI / 2;
+            break;
+
+        case HSCROLL_BAR_BUTTON_RIGHT:
+            s = (int)(0.5 * MIN(height, width * 2) + 0.5) + 1;
+            a = G_PI / 2;
+            break;
+
+        case VSCROLL_BAR_BUTTON_UP:
+            s = (int)(0.5 * MIN(height * 2, width) + 0.5) + 1;
+            a = 0;
+            break;
+
+        case VSCROLL_BAR_BUTTON_DOWN:
+            s = (int)(0.5 * MIN(height * 2, width) + 0.5) + 1;
+            a = G_PI;
+            break;
+
+        case COMBO_BOX_ARROW_BUTTON:
+            s = (int)(0.3 * height + 0.5) + 1;
+            a = G_PI;
+            break;
+
+        case TABLE:
+            s = (int)(0.8 * height + 0.5) + 1;
+            if (arrow_type == GTK_ARROW_UP) {
+                a = G_PI;
+            } else if (arrow_type == GTK_ARROW_DOWN) {
+                a = 0;
+            }
+            break;
+
+        case MENU_ITEM:
+            if (arrow_type == GTK_ARROW_UP) {
+                a = G_PI;
+            } else if (arrow_type == GTK_ARROW_DOWN) {
+                a = 0;
+            } else if (arrow_type == GTK_ARROW_RIGHT) {
+                a = G_PI / 2;
+            } else if (arrow_type == GTK_ARROW_LEFT) {
+                a = 3 * G_PI / 2;
+            }
+            break;
+
+        default:
+            if (arrow_type == GTK_ARROW_UP) {
+                a = G_PI;
+            } else if (arrow_type == GTK_ARROW_DOWN) {
+                a = 0;
+            } else if (arrow_type == GTK_ARROW_RIGHT) {
+                a = G_PI / 2;
+            } else if (arrow_type == GTK_ARROW_LEFT) {
+                a = 3 * G_PI / 2;
+            }
+            break;
+    }
+
+    if (s < width && s < height) {
+        xx = x + (0.5 * (width - s) + 0.5);
+        yy = y + (0.5 * (height - s) + 0.5);
+    } else {
+        xx = x;
+        yy = y;
+    }
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+    fp_gtk_style_context_save (context);
+
+
+    if (detail != NULL) {
+        transform_detail_string(detail, context);
+    }
+
+    GtkStateFlags flags = get_gtk_flags(state_type);
+
+    fp_gtk_style_context_set_state (context, flags);
+
+    (*fp_gtk_render_arrow)(context, cr, a, xx, yy, s);
+
+    fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_box(WidgetType widget_type, GtkStateType state_type,
+                    GtkShadowType shadow_type, const gchar *detail,
+                    gint x, gint y, gint width, gint height,
+                    gint synth_state, GtkTextDirection dir)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    if (widget_type == HSLIDER_TRACK) {
+        /*
+         * For horizontal JSliders with right-to-left orientation, we need
+         * to set the "inverted" flag to match the native GTK behavior where
+         * the foreground highlight is on the right side of the slider thumb.
+         * This is needed especially for the ubuntulooks engine, which looks
+         * exclusively at the "inverted" flag to determine on which side of
+         * the thumb to paint the highlight...
+         */
+        fp_gtk_range_set_inverted((GtkRange*)gtk3_widget, dir ==
+                                                              GTK_TEXT_DIR_RTL);
+
+        /*
+         * Note however that other engines like clearlooks will look at both
+         * the "inverted" field and the text direction to determine how
+         * the foreground highlight is painted:
+         *     !inverted && ltr --> paint highlight on left side
+         *     !inverted && rtl --> paint highlight on right side
+         *      inverted && ltr --> paint highlight on right side
+         *      inverted && rtl --> paint highlight on left side
+         * So the only way to reliably get the desired results for horizontal
+         * JSlider (i.e., highlight on left side for LTR ComponentOrientation
+         * and highlight on right side for RTL ComponentOrientation) is to
+         * always override text direction as LTR, and then set the "inverted"
+         * flag accordingly (as we have done above).
+         */
+        dir = GTK_TEXT_DIR_LTR;
+    }
+
+    /*
+     * Some engines (e.g. clearlooks) will paint the shadow of certain
+     * widgets (e.g. COMBO_BOX_ARROW_BUTTON) differently depending on the
+     * the text direction.
+     */
+    gtk3_set_direction(gtk3_widget, dir);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+    fp_gtk_style_context_save (context);
+
+    transform_detail_string(detail, context);
+
+    GtkStateFlags flags = get_gtk_flags(state_type);
+
+    if (shadow_type == GTK_SHADOW_IN && widget_type != COMBO_BOX_ARROW_BUTTON) {
+        flags |= GTK_STATE_FLAG_ACTIVE;
+    }
+
+    if (synth_state & MOUSE_OVER) {
+        flags |= GTK_STATE_FLAG_PRELIGHT;
+    }
+
+    if (synth_state & FOCUSED) {
+        flags |= GTK_STATE_FLAG_FOCUSED;
+    }
+
+    if (synth_state & DEFAULT) {
+        fp_gtk_style_context_add_class (context, "default");
+    }
+
+    fp_gtk_style_context_set_state (context, flags);
+
+    if (fp_gtk_style_context_has_class(context, "progressbar")) {
+        fp_gtk_render_activity (context, cr, x, y, width, height);
+    } else {
+        fp_gtk_render_background (context, cr, x, y, width, height);
+        if (shadow_type != GTK_SHADOW_NONE) {
+            fp_gtk_render_frame(context, cr, x, y, width, height);
+        }
+    }
+
+    fp_gtk_style_context_restore (context);
+    /*
+     * Reset the text direction to the default value so that we don't
+     * accidentally affect other operations and widgets.
+     */
+    gtk3_set_direction(gtk3_widget, GTK_TEXT_DIR_LTR);
+}
+
+static void gtk3_paint_box_gap(WidgetType widget_type, GtkStateType state_type,
+        GtkShadowType shadow_type, const gchar *detail,
+        gint x, gint y, gint width, gint height,
+        GtkPositionType gap_side, gint gap_x, gint gap_width)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+    fp_gtk_style_context_save (context);
+
+    GtkStateFlags flags = get_gtk_flags(state_type);
+    fp_gtk_style_context_set_state(context, flags);
+
+    if (detail != 0) {
+        transform_detail_string(detail, context);
+    }
+    fp_gtk_render_background(context, cr, x, y, width, height);
+
+    if (shadow_type != GTK_SHADOW_NONE) {
+        fp_gtk_render_frame_gap(context, cr, x, y, width, height, gap_side,
+                                    (gdouble)gap_x, (gdouble)gap_x + gap_width);
+    }
+    fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_check(WidgetType widget_type, gint synth_state,
+        const gchar *detail, gint x, gint y, gint width, gint height)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+    fp_gtk_style_context_save (context);
+
+    GtkStateFlags flags = get_gtk_state_flags(synth_state);
+    if (gtk3_version_3_14 && (synth_state & SELECTED)) {
+        flags = GTK_STATE_FLAG_CHECKED;
+    }
+    fp_gtk_style_context_set_state(context, flags);
+
+    fp_gtk_style_context_add_class (context, "check");
+
+    fp_gtk_render_check (context, cr, x, y, width, height);
+
+    fp_gtk_style_context_restore (context);
+}
+
+
+static void gtk3_paint_expander(WidgetType widget_type, GtkStateType state_type,
+        const gchar *detail, gint x, gint y, gint width, gint height,
+        GtkExpanderStyle expander_style)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+    fp_gtk_style_context_save (context);
+
+    GtkStateFlags flags = get_gtk_flags(state_type);
+    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_style_context_restore (context);
+}
+
+static void gtk3_paint_extension(WidgetType widget_type, GtkStateType state_type,
+        GtkShadowType shadow_type, const gchar *detail,
+        gint x, gint y, gint width, gint height, GtkPositionType gap_side)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+    fp_gtk_style_context_save (context);
+
+    GtkStateFlags flags = GTK_STATE_FLAG_NORMAL;
+
+    if (state_type == 0) {
+        flags = GTK_STATE_FLAG_ACTIVE;
+    }
+
+    fp_gtk_style_context_set_state(context, flags);
+
+    if (detail != 0) {
+        transform_detail_string(detail, context);
+    }
+    switch(gap_side) {
+      case GTK_POS_LEFT:
+        fp_gtk_style_context_add_class(context, "right");
+        break;
+      case GTK_POS_RIGHT:
+        fp_gtk_style_context_add_class(context, "left");
+        break;
+      case GTK_POS_TOP:
+        fp_gtk_style_context_add_class(context, "bottom");
+        break;
+      case GTK_POS_BOTTOM:
+        fp_gtk_style_context_add_class(context, "top");
+        break;
+      default:
+        break;
+    }
+
+    fp_gtk_render_extension(context, cr, x, y, width, height, gap_side);
+
+    fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
+        GtkShadowType shadow_type, const gchar *detail,
+        gint x, gint y, gint width, gint height, gboolean has_focus)
+{
+    if (state_type == GTK_STATE_PRELIGHT &&
+        (widget_type == CHECK_BOX || widget_type == RADIO_BUTTON)) {
+        return;
+    }
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+    fp_gtk_style_context_save (context);
+
+    if (detail != 0) {
+        transform_detail_string(detail, context);
+    }
+
+    GtkStateFlags flags = get_gtk_flags(state_type);
+
+    if (has_focus) {
+        flags |= GTK_STATE_FLAG_FOCUSED;
+    }
+
+    fp_gtk_style_context_set_state (context, flags);
+
+    if (widget_type == COMBO_BOX_TEXT_FIELD) {
+        width += height /2;
+    }
+
+    fp_gtk_render_background (context, cr, x, y, width, height);
+
+    fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_focus(WidgetType widget_type, GtkStateType state_type,
+        const char *detail, gint x, gint y, gint width, gint height)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+    fp_gtk_style_context_save (context);
+
+    transform_detail_string(detail, context);
+    fp_gtk_render_focus (context, cr, x, y, width, height);
+
+    fp_gtk_style_context_restore (context);
+
+}
+
+static void gtk3_paint_handle(WidgetType widget_type, GtkStateType state_type,
+        GtkShadowType shadow_type, const gchar *detail,
+        gint x, gint y, gint width, gint height, GtkOrientation orientation)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+    fp_gtk_style_context_save (context);
+
+    GtkStateFlags flags = get_gtk_flags(state_type);
+    fp_gtk_style_context_set_state(context, GTK_STATE_FLAG_PRELIGHT);
+
+    if (detail != 0) {
+        transform_detail_string(detail, context);
+        fp_gtk_style_context_add_class (context, "handlebox_bin");
+    }
+
+    fp_gtk_render_handle(context, cr, x, y, width, height);
+    fp_gtk_render_background(context, cr, x, y, width, height);
+
+    fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_hline(WidgetType widget_type, GtkStateType state_type,
+        const gchar *detail, gint x, gint y, gint width, gint height)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+    fp_gtk_style_context_save (context);
+
+    if (detail != 0) {
+        transform_detail_string(detail, context);
+    }
+
+    fp_gtk_render_line(context, cr, x, y, x + width, y);
+
+    fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_vline(WidgetType widget_type, GtkStateType state_type,
+        const gchar *detail, gint x, gint y, gint width, gint height)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+    fp_gtk_style_context_save (context);
+
+    if (detail != 0) {
+        transform_detail_string(detail, context);
+    }
+
+    fp_gtk_render_line(context, cr, x, y, x, y + height);
+
+    fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_option(WidgetType widget_type, gint synth_state,
+        const gchar *detail, gint x, gint y, gint width, gint height)
+{
+     gtk3_widget = gtk3_get_widget(widget_type);
+
+     GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+     fp_gtk_style_context_save (context);
+
+     GtkStateFlags flags = get_gtk_state_flags(synth_state);
+     if (gtk3_version_3_14 && (synth_state & SELECTED)) {
+         flags = GTK_STATE_FLAG_CHECKED;
+     }
+     fp_gtk_style_context_set_state(context, flags);
+
+     if (detail != 0) {
+         transform_detail_string(detail, context);
+     }
+
+     fp_gtk_render_option(context, cr, x, y, width, height);
+
+     fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_shadow(WidgetType widget_type, GtkStateType state_type,
+                       GtkShadowType shadow_type, const gchar *detail,
+                       gint x, gint y, gint width, gint height,
+                       gint synth_state, GtkTextDirection dir)
+{
+    if (shadow_type == GTK_SHADOW_NONE) {
+        return;
+    }
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    /*
+     * Some engines (e.g. clearlooks) will paint the shadow of certain
+     * widgets (e.g. COMBO_BOX_TEXT_FIELD) differently depending on the
+     * the text direction.
+     */
+    gtk3_set_direction(gtk3_widget, dir);
+
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+    fp_gtk_style_context_save (context);
+
+    if (detail) {
+        transform_detail_string(detail, context);
+    }
+
+    GtkStateFlags flags = get_gtk_flags(state_type);
+
+    if (synth_state & MOUSE_OVER) {
+        flags |= GTK_STATE_FLAG_PRELIGHT;
+    }
+
+    if (synth_state & FOCUSED) {
+        flags |= GTK_STATE_FLAG_FOCUSED;
+    }
+
+    fp_gtk_style_context_set_state (context, flags);
+
+    if (widget_type == COMBO_BOX_TEXT_FIELD) {
+        width += height / 2;
+    }
+    fp_gtk_render_frame(context, cr, x, y, width, height);
+
+    fp_gtk_style_context_restore (context);
+
+    /*
+     * Reset the text direction to the default value so that we don't
+     * accidentally affect other operations and widgets.
+     */
+    gtk3_set_direction(gtk3_widget, GTK_TEXT_DIR_LTR);
+}
+
+static void gtk3_paint_slider(WidgetType widget_type, GtkStateType state_type,
+        GtkShadowType shadow_type, const gchar *detail,
+        gint x, gint y, gint width, gint height, GtkOrientation orientation,
+        gboolean has_focus)
+{
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+    fp_gtk_style_context_save (context);
+
+    if (detail) {
+       transform_detail_string(detail, context);
+    }
+
+    GtkStateFlags flags = get_gtk_flags(state_type);
+
+    if (state_type == GTK_STATE_ACTIVE) {
+        flags |= GTK_STATE_FLAG_PRELIGHT;
+    }
+
+    if (has_focus) {
+        flags |= GTK_STATE_FLAG_FOCUSED;
+    }
+
+    fp_gtk_style_context_set_state (context, flags);
+
+    (*fp_gtk_render_slider)(context, cr, x, y, width, height, orientation);
+
+    fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_background(WidgetType widget_type,
+             GtkStateType state_type, gint x, gint y, gint width, gint height) {
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+    fp_gtk_style_context_save (context);
+
+    GtkStateFlags flags = get_gtk_flags(state_type);
+
+    fp_gtk_style_context_set_state (context, flags);
+
+    fp_gtk_render_background (context, cr, x, y, width, height);
+
+    fp_gtk_style_context_restore (context);
+}
+
+static GdkPixbuf *gtk3_get_stock_icon(gint widget_type, const gchar *stock_id,
+        GtkIconSize size, GtkTextDirection direction, const char *detail)
+{
+    int sz;
+
+    switch(size) {
+      case GTK_ICON_SIZE_MENU:
+        sz = 16;
+        break;
+      case GTK_ICON_SIZE_SMALL_TOOLBAR:
+        sz = 18;
+        break;
+      case GTK_ICON_SIZE_LARGE_TOOLBAR:
+        sz = 24;
+        break;
+      case GTK_ICON_SIZE_BUTTON:
+        sz = 20;
+        break;
+      case GTK_ICON_SIZE_DND:
+        sz = 32;
+        break;
+      case GTK_ICON_SIZE_DIALOG:
+        sz = 48;
+        break;
+      default:
+        sz = 0;
+        break;
+    }
+
+    init_containers();
+    gtk3_widget = gtk3_get_widget((widget_type < 0) ? IMAGE : widget_type);
+    (*fp_gtk_widget_set_direction)(gtk3_widget, direction);
+    GtkIconTheme *icon_theme = fp_gtk_icon_theme_get_default();
+    GdkPixbuf *result = fp_gtk_icon_theme_load_icon(icon_theme, stock_id, sz,
+                                             GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
+    return result;
+}
+
+static jboolean gtk3_get_pixbuf_data(JNIEnv *env, GdkPixbuf* pixbuf,
+                              jmethodID icon_upcall_method, jobject this) {
+    if (!pixbuf) {
+        return JNI_FALSE;
+    }
+    guchar *pixbuf_data = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
+    if (pixbuf_data) {
+        int row_stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
+        int width = (*fp_gdk_pixbuf_get_width)(pixbuf);
+        int height = (*fp_gdk_pixbuf_get_height)(pixbuf);
+        int bps = (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf);
+        int channels = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
+        gboolean alpha = (*fp_gdk_pixbuf_get_has_alpha)(pixbuf);
+
+        jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
+        JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
+
+        (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
+                                   (jbyte *)pixbuf_data);
+        (*fp_g_object_unref)(pixbuf);
+
+        /* Call the callback method to create the image on the Java side. */
+        (*env)->CallVoidMethod(env, this, icon_upcall_method, data,
+                width, height, row_stride, bps, channels, alpha);
+        return JNI_TRUE;
+    }
+    return JNI_FALSE;
+}
+
+static jboolean gtk3_get_file_icon_data(JNIEnv *env, const char *filename,
+                 GError **error, jmethodID icon_upcall_method, jobject this) {
+    GdkPixbuf* pixbuf = fp_gdk_pixbuf_new_from_file(filename, error);
+    return gtk3_get_pixbuf_data(env, pixbuf, icon_upcall_method, this);
+}
+
+static jboolean gtk3_get_icon_data(JNIEnv *env, gint widget_type,
+                              const gchar *stock_id, GtkIconSize size,
+                              GtkTextDirection direction, const char *detail,
+                              jmethodID icon_upcall_method, jobject this) {
+    GdkPixbuf* pixbuf = gtk3_get_stock_icon(widget_type, stock_id, size,
+                                       direction, detail);
+    return gtk3_get_pixbuf_data(env, pixbuf, icon_upcall_method, this);
+}
+
+/*************************************************/
+static gint gtk3_get_xthickness(JNIEnv *env, WidgetType widget_type)
+{
+    init_containers();
+
+    gtk3_widget = gtk3_get_widget(widget_type);
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+    if (context) {
+        GtkBorder padding;
+        fp_gtk_style_context_get_padding(context, 0, &padding);
+        return padding.left + 1;
+    }
+    return 0;
+}
+
+static gint gtk3_get_ythickness(JNIEnv *env, WidgetType widget_type)
+{
+    init_containers();
+
+    gtk3_widget = gtk3_get_widget(widget_type);
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+    if (context) {
+        GtkBorder padding;
+        fp_gtk_style_context_get_padding(context, 0, &padding);
+        return padding.top + 1;
+    }
+    return 0;
+}
+
+/*************************************************/
+static guint8 recode_color(gdouble channel)
+{
+    guint16 result = (guint16)(channel * 65535);
+    if (result < 0) {
+        result = 0;
+    } else if (result > 65535) {
+        result = 65535;
+    }
+    return (guint8)( result >> 8);
+}
+
+static GtkStateFlags gtk3_get_state_flags(GtkStateType state_type) {
+    switch (state_type)
+    {
+        case GTK_STATE_NORMAL:
+            return GTK_STATE_FLAG_NORMAL;
+        case GTK_STATE_ACTIVE:
+            return GTK_STATE_FLAG_ACTIVE;
+        case GTK_STATE_PRELIGHT:
+            return GTK_STATE_FLAG_PRELIGHT;
+        case GTK_STATE_SELECTED:
+            return GTK_STATE_FLAG_SELECTED;
+        case GTK_STATE_INSENSITIVE:
+            return GTK_STATE_FLAG_INSENSITIVE;
+        case GTK_STATE_INCONSISTENT:
+            return GTK_STATE_FLAG_INCONSISTENT;
+        case GTK_STATE_FOCUSED:
+            return GTK_STATE_FLAG_FOCUSED;
+    }
+    return 0;
+}
+
+
+static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b) {
+  gdouble min;
+  gdouble max;
+  gdouble red;
+  gdouble green;
+  gdouble blue;
+  gdouble h, l, s;
+  gdouble delta;
+
+  red = *r;
+  green = *g;
+  blue = *b;
+
+  if (red > green)
+    {
+      if (red > blue)
+        max = red;
+      else
+        max = blue;
+
+      if (green < blue)
+        min = green;
+      else
+        min = blue;
+    }
+  else
+    {
+      if (green > blue)
+        max = green;
+      else
+        max = blue;
+
+      if (red < blue)
+        min = red;
+      else
+        min = blue;
+    }
+
+  l = (max + min) / 2;
+  s = 0;
+  h = 0;
+
+  if (max != min)
+    {
+      if (l <= 0.5)
+        s = (max - min) / (max + min);
+      else
+        s = (max - min) / (2 - max - min);
+
+      delta = max -min;
+      if (red == max)
+        h = (green - blue) / delta;
+      else if (green == max)
+        h = 2 + (blue - red) / delta;
+      else if (blue == max)
+        h = 4 + (red - green) / delta;
+
+      h *= 60;
+      if (h < 0.0)
+        h += 360;
+    }
+
+  *r = h;
+  *g = l;
+  *b = s;
+}
+
+static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s)
+{
+  gdouble hue;
+  gdouble lightness;
+  gdouble saturation;
+  gdouble m1, m2;
+  gdouble r, g, b;
+
+  lightness = *l;
+  saturation = *s;
+
+  if (lightness <= 0.5)
+    m2 = lightness * (1 + saturation);
+  else
+    m2 = lightness + saturation - lightness * saturation;
+  m1 = 2 * lightness - m2;
+
+  if (saturation == 0)
+    {
+      *h = lightness;
+      *l = lightness;
+      *s = lightness;
+    }
+  else
+    {
+      hue = *h + 120;
+      while (hue > 360)
+        hue -= 360;
+      while (hue < 0)
+        hue += 360;
+
+      if (hue < 60)
+        r = m1 + (m2 - m1) * hue / 60;
+      else if (hue < 180)
+        r = m2;
+      else if (hue < 240)
+        r = m1 + (m2 - m1) * (240 - hue) / 60;
+      else
+        r = m1;
+
+      hue = *h;
+      while (hue > 360)
+        hue -= 360;
+      while (hue < 0)
+        hue += 360;
+
+      if (hue < 60)
+        g = m1 + (m2 - m1) * hue / 60;
+      else if (hue < 180)
+        g = m2;
+      else if (hue < 240)
+        g = m1 + (m2 - m1) * (240 - hue) / 60;
+      else
+        g = m1;
+
+      hue = *h - 120;
+      while (hue > 360)
+        hue -= 360;
+      while (hue < 0)
+        hue += 360;
+
+      if (hue < 60)
+        b = m1 + (m2 - m1) * hue / 60;
+      else if (hue < 180)
+        b = m2;
+      else if (hue < 240)
+        b = m1 + (m2 - m1) * (240 - hue) / 60;
+      else
+        b = m1;
+
+      *h = r;
+      *l = g;
+      *s = b;
+    }
+}
+
+
+
+static void gtk3_style_shade (const GdkRGBA *a, GdkRGBA *b, gdouble k) {
+  gdouble red = a->red;
+  gdouble green = a->green;
+  gdouble blue = a->blue;
+
+  rgb_to_hls (&red, &green, &blue);
+
+  green *= k;
+  if (green > 1.0)
+    green = 1.0;
+  else if (green < 0.0)
+    green = 0.0;
+
+  blue *= k;
+  if (blue > 1.0)
+    blue = 1.0;
+  else if (blue < 0.0)
+    blue = 0.0;
+
+  hls_to_rgb (&red, &green, &blue);
+
+  b->red = red;
+  b->green = green;
+  b->blue = blue;
+}
+
+static GdkRGBA gtk3_get_color_for_flags(GtkStyleContext* context,
+                                  GtkStateFlags flags, ColorType color_type) {
+    GdkRGBA c, color;
+
+    switch (color_type)
+    {
+        case FOREGROUND:
+        case TEXT_FOREGROUND:
+            fp_gtk_style_context_get_color(context, flags, &color);
+            break;
+        case BACKGROUND:
+        case TEXT_BACKGROUND:
+            fp_gtk_style_context_get_background_color(context, flags, &color);
+            break;
+        case LIGHT:
+            c = gtk3_get_color_for_flags(context, flags, BACKGROUND);
+            gtk3_style_shade(&c, &color, LIGHTNESS_MULT);
+            break;
+        case DARK:
+            c = gtk3_get_color_for_flags(context, flags, BACKGROUND);
+            gtk3_style_shade (&c, &color, DARKNESS_MULT);
+            break;
+        case MID:
+            {
+                GdkRGBA c1 = gtk3_get_color_for_flags(context, flags, LIGHT);
+                GdkRGBA c2 = gtk3_get_color_for_flags(context, flags, DARK);
+                color.red = (c1.red + c2.red) / 2;
+                color.green = (c1.green + c2.green) / 2;
+                color.blue = (c1.blue + c2.blue) / 2;
+            }
+            break;
+        case FOCUS:
+        case BLACK:
+            color.red = 0;
+            color.green = 0;
+            color.blue = 0;
+            break;
+        case WHITE:
+            color.red = 1;
+            color.green = 1;
+            color.blue = 1;
+            break;
+    }
+    return color;
+}
+
+static gint gtk3_get_color_for_state(JNIEnv *env, WidgetType widget_type,
+                              GtkStateType state_type, ColorType color_type)
+{
+
+    gint result = 0;
+    GdkRGBA color;
+
+    GtkStateFlags flags = gtk3_get_state_flags(state_type);
+
+    init_containers();
+
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GtkStyleContext* context = fp_gtk_widget_get_style_context(gtk3_widget);
+
+    if (widget_type == TOOL_TIP) {
+        fp_gtk_style_context_add_class(context, "tooltip");
+    }
+    if (widget_type == CHECK_BOX_MENU_ITEM
+     || widget_type == RADIO_BUTTON_MENU_ITEM) {
+        flags &= GTK_STATE_FLAG_NORMAL | GTK_STATE_FLAG_SELECTED
+                  | GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_FOCUSED;
+    }
+
+    color = gtk3_get_color_for_flags(context, flags, color_type);
+
+    if (recode_color(color.alpha) == 0) {
+        color = gtk3_get_color_for_flags(
+        fp_gtk_widget_get_style_context(gtk3_get_widget(INTERNAL_FRAME)),
+        0, BACKGROUND);
+    }
+
+    result = recode_color(color.alpha) << 24 | recode_color(color.red) << 16 |
+             recode_color(color.green) << 8 | recode_color(color.blue);
+
+    return result;
+}
+
+/*************************************************/
+static jobject create_Boolean(JNIEnv *env, jboolean boolean_value);
+static jobject create_Integer(JNIEnv *env, jint int_value);
+static jobject create_Long(JNIEnv *env, jlong long_value);
+static jobject create_Float(JNIEnv *env, jfloat float_value);
+static jobject create_Double(JNIEnv *env, jdouble double_value);
+static jobject create_Character(JNIEnv *env, jchar char_value);
+static jobject create_Insets(JNIEnv *env, GtkBorder *border);
+
+static jobject gtk3_get_class_value(JNIEnv *env, WidgetType widget_type,
+                                                     const char* key)
+{
+    init_containers();
+
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    GValue value = { 0, { { 0 } } };
+
+    GParamSpec* param = (*fp_gtk_widget_class_find_style_property)(
+                                    ((GTypeInstance*)gtk3_widget)->g_class, key);
+    if ( param )
+    {
+        (*fp_g_value_init)( &value, param->value_type );
+        (*fp_gtk_widget_style_get_property)(gtk3_widget, key, &value);
+
+        if ((*fp_g_type_is_a)( param->value_type, G_TYPE_BOOLEAN ))
+        {
+            gboolean val = (*fp_g_value_get_boolean)(&value);
+            return create_Boolean(env, (jboolean)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_CHAR ))
+        {
+            gchar val = (*fp_g_value_get_char)(&value);
+            return create_Character(env, (jchar)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_UCHAR ))
+        {
+            guchar val = (*fp_g_value_get_uchar)(&value);
+            return create_Character(env, (jchar)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_INT ))
+        {
+            gint val = (*fp_g_value_get_int)(&value);
+            return create_Integer(env, (jint)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_UINT ))
+        {
+            guint val = (*fp_g_value_get_uint)(&value);
+                    return create_Integer(env, (jint)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_LONG ))
+        {
+            glong val = (*fp_g_value_get_long)(&value);
+            return create_Long(env, (jlong)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_ULONG ))
+        {
+            gulong val = (*fp_g_value_get_ulong)(&value);
+            return create_Long(env, (jlong)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_INT64 ))
+        {
+            gint64 val = (*fp_g_value_get_int64)(&value);
+            return create_Long(env, (jlong)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_UINT64 ))
+        {
+            guint64 val = (*fp_g_value_get_uint64)(&value);
+            return create_Long(env, (jlong)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_FLOAT ))
+        {
+            gfloat val = (*fp_g_value_get_float)(&value);
+            return create_Float(env, (jfloat)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_DOUBLE ))
+        {
+            gdouble val = (*fp_g_value_get_double)(&value);
+            return create_Double(env, (jdouble)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_ENUM ))
+        {
+            gint val = (*fp_g_value_get_enum)(&value);
+            return create_Integer(env, (jint)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_FLAGS ))
+        {
+            guint val = (*fp_g_value_get_flags)(&value);
+            return create_Integer(env, (jint)val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_STRING ))
+        {
+            const gchar* val = (*fp_g_value_get_string)(&value);
+
+            /* We suppose that all values come in C locale and
+             * utf-8 representation of a string is the same as
+             * the string itself. If this isn't so we should
+             * use g_convert.
+             */
+            return (*env)->NewStringUTF(env, val);
+        }
+        else if ((*fp_g_type_is_a)( param->value_type, GTK_TYPE_BORDER ))
+        {
+            GtkBorder *border = (GtkBorder*)(*fp_g_value_get_boxed)(&value);
+            return border ? create_Insets(env, border) : NULL;
+        }
+
+        /*      TODO: Other types are not supported yet.*/
+/*        else if((*fp_g_type_is_a)( param->value_type, G_TYPE_PARAM ))
+        {
+            GParamSpec* val = (*fp_g_value_get_param)(&value);
+            printf( "Param: %p\n", val );
+        }
+        else if((*fp_g_type_is_a)( param->value_type, G_TYPE_BOXED ))
+        {
+            gpointer* val = (*fp_g_value_get_boxed)(&value);
+            printf( "Boxed: %p\n", val );
+        }
+        else if((*fp_g_type_is_a)( param->value_type, G_TYPE_POINTER ))
+        {
+            gpointer* val = (*fp_g_value_get_pointer)(&value);
+            printf( "Pointer: %p\n", val );
+        }
+        else if((*fp_g_type_is_a)( param->value_type, G_TYPE_OBJECT ))
+        {
+            GObject* val = (GObject*)(*fp_g_value_get_object)(&value);
+            printf( "Object: %p\n", val );
+        }*/
+    }
+
+    return NULL;
+}
+
+static void gtk3_set_range_value(WidgetType widget_type, jdouble value,
+                          jdouble min, jdouble max, jdouble visible)
+{
+    GtkAdjustment *adj;
+
+    gtk3_widget = gtk3_get_widget(widget_type);
+
+    adj = (*fp_gtk_range_get_adjustment)((GtkRange *)gtk3_widget);
+
+    fp_gtk_adjustment_set_value(adj, value);
+    fp_gtk_adjustment_set_lower(adj, min);
+    fp_gtk_adjustment_set_upper(adj, max);
+    fp_gtk_adjustment_set_page_size(adj, visible);
+}
+
+/*************************************************/
+static jobject create_Object(JNIEnv *env, jmethodID *cid,
+                             const char* class_name,
+                             const char* signature,
+                             jvalue* value)
+{
+    jclass  class;
+    jobject result;
+
+    class = (*env)->FindClass(env, class_name);
+    if (class == NULL)
+        return NULL; /* can't find/load the class, exception thrown */
+
+    if (*cid == NULL)
+    {
+        *cid = (*env)->GetMethodID(env, class, "<init>", signature);
+        if (*cid == NULL)
+        {
+            (*env)->DeleteLocalRef(env, class);
+            return NULL; /* can't find/get the method, exception thrown */
+        }
+    }
+
+    result = (*env)->NewObjectA(env, class, *cid, value);
+
+    (*env)->DeleteLocalRef(env, class);
+    return result;
+}
+
+jobject create_Boolean(JNIEnv *env, jboolean boolean_value)
+{
+    static jmethodID cid = NULL;
+    jvalue value;
+
+    value.z = boolean_value;
+
+    return create_Object(env, &cid, "java/lang/Boolean", "(Z)V", &value);
+}
+
+jobject create_Integer(JNIEnv *env, jint int_value)
+{
+    static jmethodID cid = NULL;
+    jvalue value;
+
+    value.i = int_value;
+
+    return create_Object(env, &cid, "java/lang/Integer", "(I)V", &value);
+}
+
+jobject create_Long(JNIEnv *env, jlong long_value)
+{
+    static jmethodID cid = NULL;
+    jvalue value;
+
+    value.j = long_value;
+
+    return create_Object(env, &cid, "java/lang/Long", "(J)V", &value);
+}
+
+jobject create_Float(JNIEnv *env, jfloat float_value)
+{
+    static jmethodID cid = NULL;
+    jvalue value;
+
+    value.f = float_value;
+
+    return create_Object(env, &cid, "java/lang/Float", "(F)V", &value);
+}
+
+jobject create_Double(JNIEnv *env, jdouble double_value)
+{
+    static jmethodID cid = NULL;
+    jvalue value;
+
+    value.d = double_value;
+
+    return create_Object(env, &cid, "java/lang/Double", "(D)V", &value);
+}
+
+jobject create_Character(JNIEnv *env, jchar char_value)
+{
+    static jmethodID cid = NULL;
+    jvalue value;
+
+    value.c = char_value;
+
+    return create_Object(env, &cid, "java/lang/Character", "(C)V", &value);
+}
+
+
+jobject create_Insets(JNIEnv *env, GtkBorder *border)
+{
+    static jmethodID cid = NULL;
+    jvalue values[4];
+
+    values[0].i = border->top;
+    values[1].i = border->left;
+    values[2].i = border->bottom;
+    values[3].i = border->right;
+
+    return create_Object(env, &cid, "java/awt/Insets", "(IIII)V", values);
+}
+
+/*********************************************/
+static jstring gtk3_get_pango_font_name(JNIEnv *env, WidgetType widget_type)
+{
+    init_containers();
+
+    gtk3_widget = gtk3_get_widget(widget_type);
+    jstring  result = NULL;
+    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+    if (context)
+    {
+        PangoFontDescription* fd = fp_gtk_style_context_get_font(context, 0);
+        gchar* val = (*fp_pango_font_description_to_string)(fd);
+        result = (*env)->NewStringUTF(env, val);
+        (*fp_g_free)( val );
+    }
+
+    return result;
+}
+
+/***********************************************/
+static jobject get_string_property(JNIEnv *env, GtkSettings* settings,
+                                                             const gchar* key) {
+    jobject result = NULL;
+    gchar*  strval = NULL;
+
+    (*fp_g_object_get)(settings, key, &strval, NULL);
+    result = (*env)->NewStringUTF(env, strval);
+    (*fp_g_free)(strval);
+
+    return result;
+}
+
+static jobject get_integer_property(JNIEnv *env, GtkSettings* settings,
+                                                             const gchar* key) {
+    gint intval = NULL;
+    (*fp_g_object_get)(settings, key, &intval, NULL);
+    return create_Integer(env, intval);
+}
+
+static jobject get_boolean_property(JNIEnv *env, GtkSettings* settings,
+                                                             const gchar* key) {
+    gint intval = NULL;
+    (*fp_g_object_get)(settings, key, &intval, NULL);
+    return create_Boolean(env, intval);
+}
+
+static jobject gtk3_get_setting(JNIEnv *env, Setting property)
+{
+    GtkSettings* settings = (*fp_gtk_settings_get_default)();
+
+    switch (property)
+    {
+        case GTK_FONT_NAME:
+            return get_string_property(env, settings, "gtk-font-name");
+        case GTK_ICON_SIZES:
+            return get_string_property(env, settings, "gtk-icon-sizes");
+        case GTK_CURSOR_BLINK:
+            return get_boolean_property(env, settings, "gtk-cursor-blink");
+        case GTK_CURSOR_BLINK_TIME:
+            return get_integer_property(env, settings, "gtk-cursor-blink-time");
+    }
+
+    return NULL;
+}
+
+static void transform_detail_string (const gchar *detail,
+                                                     GtkStyleContext *context) {
+  if (!detail)
+    return;
+
+  if (strcmp (detail, "arrow") == 0)
+    fp_gtk_style_context_add_class (context, "arrow");
+  else if (strcmp (detail, "button") == 0)
+    fp_gtk_style_context_add_class (context, "button");
+  else if (strcmp (detail, "buttondefault") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "button");
+      fp_gtk_style_context_add_class (context, "default");
+    }
+  else if (strcmp (detail, "calendar") == 0)
+    fp_gtk_style_context_add_class (context, "calendar");
+  else if (strcmp (detail, "cellcheck") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "cell");
+      fp_gtk_style_context_add_class (context, "check");
+    }
+  else if (strcmp (detail, "cellradio") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "cell");
+      fp_gtk_style_context_add_class (context, "radio");
+    }
+  else if (strcmp (detail, "checkbutton") == 0)
+    fp_gtk_style_context_add_class (context, "check");
+  else if (strcmp (detail, "check") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "check");
+      fp_gtk_style_context_add_class (context, "menu");
+    }
+  else if (strcmp (detail, "radiobutton") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "radio");
+    }
+  else if (strcmp (detail, "option") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "radio");
+      fp_gtk_style_context_add_class (context, "menu");
+    }
+  else if (strcmp (detail, "entry") == 0 ||
+           strcmp (detail, "entry_bg") == 0)
+    fp_gtk_style_context_add_class (context, "entry");
+  else if (strcmp (detail, "expander") == 0)
+    fp_gtk_style_context_add_class (context, "expander");
+  else if (strcmp (detail, "tooltip") == 0)
+    fp_gtk_style_context_add_class (context, "tooltip");
+  else if (strcmp (detail, "frame") == 0)
+    fp_gtk_style_context_add_class (context, "frame");
+  else if (strcmp (detail, "scrolled_window") == 0)
+    fp_gtk_style_context_add_class (context, "scrolled-window");
+  else if (strcmp (detail, "viewport") == 0 ||
+           strcmp (detail, "viewportbin") == 0)
+    fp_gtk_style_context_add_class (context, "viewport");
+  else if (strncmp (detail, "trough", 6) == 0)
+    fp_gtk_style_context_add_class (context, "trough");
+  else if (strcmp (detail, "spinbutton") == 0)
+    fp_gtk_style_context_add_class (context, "spinbutton");
+  else if (strcmp (detail, "spinbutton_up") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "spinbutton");
+      fp_gtk_style_context_add_class (context, "button");
+      fp_gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
+    }
+  else if (strcmp (detail, "spinbutton_down") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "spinbutton");
+      fp_gtk_style_context_add_class (context, "button");
+      fp_gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
+    }
+  else if ((detail[0] == 'h' || detail[0] == 'v') &&
+           strncmp (&detail[1], "scrollbar_", 9) == 0)
+    {
+      fp_gtk_style_context_add_class (context, "button");
+      fp_gtk_style_context_add_class (context, "scrollbar");
+    }
+  else if (strcmp (detail, "slider") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "slider");
+      fp_gtk_style_context_add_class (context, "scrollbar");
+    }
+  else if (strcmp (detail, "vscale") == 0 ||
+           strcmp (detail, "hscale") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "slider");
+      fp_gtk_style_context_add_class (context, "scale");
+    }
+  else if (strcmp (detail, "menuitem") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "menuitem");
+      fp_gtk_style_context_add_class (context, "menu");
+    }
+  else if (strcmp (detail, "menu") == 0)
+    {
+      fp_gtk_style_context_add_class (context, "popup");
+      fp_gtk_style_context_add_class (context, "menu");
+    }
+  else if (strcmp (detail, "accellabel") == 0)
+    fp_gtk_style_context_add_class (context, "accelerator");
+  else if (strcmp (detail, "menubar") == 0)
+    fp_gtk_style_context_add_class (context, "menubar");
+  else if (strcmp (detail, "base") == 0)
+    fp_gtk_style_context_add_class (context, "background");
+  else if (strcmp (detail, "bar") == 0 ||
+           strcmp (detail, "progressbar") == 0)
+    fp_gtk_style_context_add_class (context, "progressbar");
+  else if (strcmp (detail, "toolbar") == 0)
+    fp_gtk_style_context_add_class (context, "toolbar");
+  else if (strcmp (detail, "handlebox_bin") == 0)
+    fp_gtk_style_context_add_class (context, "dock");
+  else if (strcmp (detail, "notebook") == 0)
+    fp_gtk_style_context_add_class (context, "notebook");
+  else if (strcmp (detail, "tab") == 0)
+  {
+      fp_gtk_style_context_add_class (context, "notebook");
+      fp_gtk_style_context_add_region (context, "tab", 0);
+  } else if (strcmp (detail, "paned") == 0) {
+      fp_gtk_style_context_add_class (context, "pane-separator");
+  }
+  else if (fp_g_str_has_prefix (detail, "cell"))
+    {
+      GtkRegionFlags row, col;
+      gboolean ruled = FALSE;
+      gchar** tokens;
+      guint i;
+
+      tokens = fp_g_strsplit (detail, "_", -1);
+      row = col = 0;
+      i = 0;
+
+      while (tokens[i])
+        {
+          if (strcmp (tokens[i], "even") == 0)
+            row |= GTK_REGION_EVEN;
+          else if (strcmp (tokens[i], "odd") == 0)
+            row |= GTK_REGION_ODD;
+          else if (strcmp (tokens[i], "start") == 0)
+            col |= GTK_REGION_FIRST;
+          else if (strcmp (tokens[i], "end") == 0)
+            col |= GTK_REGION_LAST;
+          else if (strcmp (tokens[i], "ruled") == 0)
+            ruled = TRUE;
+          else if (strcmp (tokens[i], "sorted") == 0)
+            col |= GTK_REGION_SORTED;
+
+          i++;
+        }
+
+      if (!ruled)
+        row &= ~(GTK_REGION_EVEN | GTK_REGION_ODD);
+
+      fp_gtk_style_context_add_class (context, "cell");
+      fp_gtk_style_context_add_region (context, "row", row);
+      fp_gtk_style_context_add_region (context, "column", col);
+
+      fp_g_strfreev (tokens);
+    }
+}
+
+static gboolean gtk3_get_drawable_data(JNIEnv *env, jintArray pixelArray,
+     int x, jint y, jint width, jint height, jint jwidth, int dx, int dy,
+                                                                   jint scale) {
+    GdkPixbuf *pixbuf;
+    jint *ary;
+
+    GdkWindow *root = (*fp_gdk_get_default_root_window)();
+    pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(root, x, y, width, height);
+    if (pixbuf && scale != 1) {
+        GdkPixbuf *scaledPixbuf;
+        x /= scale;
+        y /= scale;
+        width /= scale;
+        height /= scale;
+        dx /= scale;
+        dy /= scale;
+        scaledPixbuf = (*fp_gdk_pixbuf_scale_simple)(pixbuf, width, height,
+                                                     GDK_INTERP_BILINEAR);
+        (*fp_g_object_unref)(pixbuf);
+        pixbuf = scaledPixbuf;
+    }
+
+    if (pixbuf) {
+        int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
+        int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
+        if ((*fp_gdk_pixbuf_get_width)(pixbuf) == width
+                && (*fp_gdk_pixbuf_get_height)(pixbuf) == height
+                && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
+                && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
+                && nchan >= 3
+                ) {
+            guchar *p, *pix = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
+            ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
+            if (ary) {
+                jint _x, _y;
+                int index;
+                for (_y = 0; _y < height; _y++) {
+                    for (_x = 0; _x < width; _x++) {
+                        p = pix + _y * stride + _x * nchan;
+
+                        index = (_y + dy) * jwidth + (_x + dx);
+                        ary[index] = 0xff000000
+                                        | (p[0] << 16)
+                                        | (p[1] << 8)
+                                        | (p[2]);
+
+                    }
+                }
+                (*env)->ReleasePrimitiveArrayCritical(env, pixelArray, ary, 0);
+            }
+        }
+        (*fp_g_object_unref)(pixbuf);
+    }
+    return JNI_FALSE;
+}
+
+static GdkWindow* gtk3_get_window(void *widget) {
+    return fp_gtk_widget_get_window((GtkWidget*)widget);
+}
+
+static void gtk3_init(GtkApi* gtk) {
+    gtk->version = GTK_3;
+
+    gtk->show_uri_load = &gtk3_show_uri_load;
+    gtk->unload = &gtk3_unload;
+    gtk->flush_event_loop = &flush_gtk_event_loop;
+    gtk->gtk_check_version = fp_gtk_check_version;
+    gtk->get_setting = &gtk3_get_setting;
+
+    gtk->paint_arrow = &gtk3_paint_arrow;
+    gtk->paint_box = &gtk3_paint_box;
+    gtk->paint_box_gap = &gtk3_paint_box_gap;
+    gtk->paint_expander = &gtk3_paint_expander;
+    gtk->paint_extension = &gtk3_paint_extension;
+    gtk->paint_flat_box = &gtk3_paint_flat_box;
+    gtk->paint_focus = &gtk3_paint_focus;
+    gtk->paint_handle = &gtk3_paint_handle;
+    gtk->paint_hline = &gtk3_paint_hline;
+    gtk->paint_vline = &gtk3_paint_vline;
+    gtk->paint_option = &gtk3_paint_option;
+    gtk->paint_shadow = &gtk3_paint_shadow;
+    gtk->paint_slider = &gtk3_paint_slider;
+    gtk->paint_background = &gtk3_paint_background;
+    gtk->paint_check = &gtk3_paint_check;
+    gtk->set_range_value = &gtk3_set_range_value;
+
+    gtk->init_painting = &gtk3_init_painting;
+    gtk->copy_image = &gtk3_copy_image;
+
+    gtk->get_xthickness = &gtk3_get_xthickness;
+    gtk->get_ythickness = &gtk3_get_ythickness;
+    gtk->get_color_for_state = &gtk3_get_color_for_state;
+    gtk->get_class_value = &gtk3_get_class_value;
+
+    gtk->get_pango_font_name = &gtk3_get_pango_font_name;
+    gtk->get_icon_data = &gtk3_get_icon_data;
+    gtk->get_file_icon_data = &gtk3_get_file_icon_data;
+    gtk->gdk_threads_enter = fp_gdk_threads_enter;
+    gtk->gdk_threads_leave = fp_gdk_threads_leave;
+    gtk->gtk_show_uri = fp_gtk_show_uri;
+    gtk->get_drawable_data = &gtk3_get_drawable_data;
+    gtk->g_free = fp_g_free;
+
+    gtk->gtk_file_chooser_get_filename = fp_gtk_file_chooser_get_filename;
+    gtk->gtk_widget_hide = fp_gtk_widget_hide;
+    gtk->gtk_main_quit = fp_gtk_main_quit;
+    gtk->gtk_file_chooser_dialog_new = fp_gtk_file_chooser_dialog_new;
+    gtk->gtk_file_chooser_set_current_folder =
+                          fp_gtk_file_chooser_set_current_folder;
+    gtk->gtk_file_chooser_set_filename = fp_gtk_file_chooser_set_filename;
+    gtk->gtk_file_chooser_set_current_name =
+                          fp_gtk_file_chooser_set_current_name;
+    gtk->gtk_file_filter_add_custom = fp_gtk_file_filter_add_custom;
+    gtk->gtk_file_chooser_set_filter = fp_gtk_file_chooser_set_filter;
+    gtk->gtk_file_chooser_get_type = fp_gtk_file_chooser_get_type;
+    gtk->gtk_file_filter_new = fp_gtk_file_filter_new;
+    gtk->gtk_file_chooser_set_do_overwrite_confirmation =
+                          fp_gtk_file_chooser_set_do_overwrite_confirmation;
+    gtk->gtk_file_chooser_set_select_multiple =
+                          fp_gtk_file_chooser_set_select_multiple;
+    gtk->gtk_file_chooser_get_current_folder =
+                          fp_gtk_file_chooser_get_current_folder;
+    gtk->gtk_file_chooser_get_filenames = fp_gtk_file_chooser_get_filenames;
+    gtk->gtk_g_slist_length = fp_gtk_g_slist_length;
+    gtk->g_signal_connect_data = fp_g_signal_connect_data;
+    gtk->gtk_widget_show = fp_gtk_widget_show;
+    gtk->gtk_main = fp_gtk_main;
+    gtk->gtk_main_level = fp_gtk_main_level;
+    gtk->g_path_get_dirname = fp_g_path_get_dirname;
+    gtk->gdk_x11_drawable_get_xid = fp_gdk_x11_drawable_get_xid;
+    gtk->gtk_widget_destroy = fp_gtk_widget_destroy;
+    gtk->gtk_window_present = fp_gtk_window_present;
+    gtk->gtk_window_move = fp_gtk_window_move;
+    gtk->gtk_window_resize = fp_gtk_window_resize;
+    gtk->get_window = &gtk3_get_window;
+
+    gtk->g_object_unref = fp_g_object_unref;
+    gtk->g_list_append = fp_g_list_append;
+    gtk->g_list_free = fp_g_list_free;
+    gtk->g_list_free_full = fp_g_list_free_full;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,577 @@
+/*
+ * Copyright (c) 2005, 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.
+ */
+#ifndef _GTK3_INTERFACE_H
+#define _GTK3_INTERFACE_H
+
+#include <stdlib.h>
+#include <jni.h>
+#include <X11/X.h>
+#include "gtk_interface.h"
+
+#define LIGHTNESS_MULT  1.3
+#define DARKNESS_MULT   0.7
+
+#define G_PI    3.1415926535897932384626433832795028841971693993751
+
+typedef enum
+{
+  GTK_STATE_FLAG_NORMAL       = 0,
+  GTK_STATE_FLAG_ACTIVE       = 1 << 0,
+  GTK_STATE_FLAG_PRELIGHT     = 1 << 1,
+  GTK_STATE_FLAG_SELECTED     = 1 << 2,
+  GTK_STATE_FLAG_INSENSITIVE  = 1 << 3,
+  GTK_STATE_FLAG_INCONSISTENT = 1 << 4,
+  GTK_STATE_FLAG_FOCUSED      = 1 << 5,
+  GTK_STATE_FLAG_BACKDROP     = 1 << 6,
+  GTK_STATE_FLAG_DIR_LTR      = 1 << 7,
+  GTK_STATE_FLAG_DIR_RTL      = 1 << 8,
+  GTK_STATE_FLAG_LINK         = 1 << 9,
+  GTK_STATE_FLAG_VISITED      = 1 << 10,
+  GTK_STATE_FLAG_CHECKED      = 1 << 11
+} GtkStateFlags;
+
+typedef enum {
+  GTK_JUNCTION_NONE = 0,
+  GTK_JUNCTION_CORNER_TOPLEFT = 1 << 0,
+  GTK_JUNCTION_CORNER_TOPRIGHT = 1 << 1,
+  GTK_JUNCTION_CORNER_BOTTOMLEFT = 1 << 2,
+  GTK_JUNCTION_CORNER_BOTTOMRIGHT = 1 << 3,
+  GTK_JUNCTION_TOP =
+                   (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_TOPRIGHT),
+  GTK_JUNCTION_BOTTOM =
+             (GTK_JUNCTION_CORNER_BOTTOMLEFT | GTK_JUNCTION_CORNER_BOTTOMRIGHT),
+  GTK_JUNCTION_LEFT =
+                 (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMLEFT),
+  GTK_JUNCTION_RIGHT =
+               (GTK_JUNCTION_CORNER_TOPRIGHT | GTK_JUNCTION_CORNER_BOTTOMRIGHT)
+} GtkJunctionSides;
+
+typedef enum {
+  GTK_REGION_EVEN    = 1 << 0,
+  GTK_REGION_ODD     = 1 << 1,
+  GTK_REGION_FIRST   = 1 << 2,
+  GTK_REGION_LAST    = 1 << 3,
+  GTK_REGION_ONLY    = 1 << 4,
+  GTK_REGION_SORTED  = 1 << 5
+} GtkRegionFlags;
+
+typedef enum
+{
+  GTK_WINDOW_TOPLEVEL,
+  GTK_WINDOW_POPUP
+} GtkWindowType;
+
+typedef enum
+{
+  G_PARAM_READABLE            = 1 << 0,
+  G_PARAM_WRITABLE            = 1 << 1,
+  G_PARAM_CONSTRUCT           = 1 << 2,
+  G_PARAM_CONSTRUCT_ONLY      = 1 << 3,
+  G_PARAM_LAX_VALIDATION      = 1 << 4,
+  G_PARAM_STATIC_NAME         = 1 << 5
+} GParamFlags;
+
+typedef enum
+{
+  GTK_ICON_LOOKUP_NO_SVG           = 1 << 0,
+  GTK_ICON_LOOKUP_FORCE_SVG        = 1 << 1,
+  GTK_ICON_LOOKUP_USE_BUILTIN      = 1 << 2,
+  GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3,
+  GTK_ICON_LOOKUP_FORCE_SIZE       = 1 << 4
+} GtkIconLookupFlags;
+
+typedef enum
+{
+  GTK_UPDATE_CONTINUOUS,
+  GTK_UPDATE_DISCONTINUOUS,
+  GTK_UPDATE_DELAYED
+} GtkUpdateType;
+
+typedef enum
+{
+  GTK_PROGRESS_CONTINUOUS,
+  GTK_PROGRESS_DISCRETE
+} GtkProgressBarStyle;
+
+typedef enum
+{
+  GTK_PROGRESS_LEFT_TO_RIGHT,
+  GTK_PROGRESS_RIGHT_TO_LEFT,
+  GTK_PROGRESS_BOTTOM_TO_TOP,
+  GTK_PROGRESS_TOP_TO_BOTTOM
+} GtkProgressBarOrientation;
+
+typedef enum {
+    CAIRO_FORMAT_INVALID   = -1,
+    CAIRO_FORMAT_ARGB32    = 0,
+    CAIRO_FORMAT_RGB24     = 1,
+    CAIRO_FORMAT_A8        = 2,
+    CAIRO_FORMAT_A1        = 3,
+    CAIRO_FORMAT_RGB16_565 = 4
+} cairo_format_t;
+
+/* We define all structure pointers to be void* */
+typedef void GdkPixbuf;
+typedef void GMainContext;
+typedef void GVfs;
+
+typedef void GdkColormap;
+typedef void GdkDrawable;
+typedef void GdkGC;
+typedef void GdkPixmap;
+typedef void GtkStyleContext;
+typedef void GtkFixed;
+typedef void GtkMenuItem;
+typedef void GtkMenuShell;
+typedef void GtkWidgetClass;
+typedef void PangoFontDescription;
+typedef void GtkSettings;
+typedef void GtkStyleProvider;
+typedef void cairo_pattern_t;
+typedef void cairo_t;
+typedef void cairo_surface_t;
+typedef void GtkScrolledWindow;
+typedef void GtkIconTheme;
+typedef void GtkWidget;
+typedef void GtkMisc;
+typedef void GtkContainer;
+typedef void GtkBin;
+typedef void GtkAdjustment;
+typedef void GtkRange;
+typedef void GtkProgressBar;
+typedef void GtkProgress;
+
+/* Some real structures */
+typedef struct
+{
+  guint32 pixel;
+  guint16 red;
+  guint16 green;
+  guint16 blue;
+} GdkColor;
+
+typedef struct
+{
+  gdouble red;
+  gdouble green;
+  gdouble blue;
+  gdouble alpha;
+} GdkRGBA;
+
+typedef struct {
+  gint      fd;
+  gushort   events;
+  gushort   revents;
+} GPollFD;
+
+typedef struct {
+  gint x;
+  gint y;
+  gint width;
+  gint height;
+} GdkRectangle;
+
+typedef struct {
+    int x, y;
+    int width, height;
+} GtkAllocation;
+
+typedef struct {
+  gint width;
+  gint height;
+} GtkRequisition;
+
+typedef struct {
+  GtkWidgetClass *g_class;
+} GTypeInstance;
+
+typedef struct {
+  gint16 left;
+  gint16 right;
+  gint16 top;
+  gint16 bottom;
+} GtkBorder;
+
+typedef struct
+{
+  GType         g_type;
+  union {
+    gint        v_int;
+    guint       v_uint;
+    glong       v_long;
+    gulong      v_ulong;
+    gint64      v_int64;
+    guint64     v_uint64;
+    gfloat      v_float;
+    gdouble     v_double;
+    gpointer    v_pointer;
+  } data[2];
+} GValue;
+
+typedef struct {
+  GTypeInstance  g_type_instance;
+  const gchar   *name;
+  GParamFlags    flags;
+  GType    value_type;
+  GType    owner_type;
+} GParamSpec;
+
+
+static gchar* (*fp_glib_check_version)(guint required_major,
+                           guint required_minor, guint required_micro);
+
+/**
+ * Returns :
+ * NULL if the GTK+ library is compatible with the given version, or a string
+ * describing the version mismatch.
+ */
+static gchar* (*fp_gtk_check_version)(guint required_major, guint
+                           required_minor, guint required_micro);
+
+static void (*fp_g_free)(gpointer mem);
+static void (*fp_g_object_unref)(gpointer object);
+static GdkWindow *(*fp_gdk_get_default_root_window) (void);
+
+static int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
+static guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
+static gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
+static GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename,
+                                                              GError **error);
+static GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);
+
+static GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkWindow *window,
+        int src_x, int src_y, int width, int height);
+static GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,
+        int dest_width, int dest_heigh, GdkInterpType interp_type);
+
+
+static void (*fp_gtk_widget_destroy)(void *widget);
+static void (*fp_gtk_window_present)(GtkWindow *window);
+static void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
+static void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
+
+/**
+ * Function Pointers for GtkFileChooser
+ */
+static gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
+static void (*fp_gtk_widget_hide)(void *widget);
+static void (*fp_gtk_main_quit)(void);
+static void* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
+    GtkWindow *parent, GtkFileChooserAction action,
+    const gchar *first_button_text, ...);
+static gboolean (*fp_gtk_file_chooser_set_current_folder)
+                              (GtkFileChooser *chooser, const gchar *filename);
+static gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
+    const char *filename);
+static void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
+    const gchar *name);
+static void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
+    GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
+    GDestroyNotify notify);
+static void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
+    GtkFileFilter *filter);
+static GType (*fp_gtk_file_chooser_get_type)(void);
+static GtkFileFilter* (*fp_gtk_file_filter_new)(void);
+static void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
+    GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
+static void (*fp_gtk_file_chooser_set_select_multiple)(
+    GtkFileChooser *chooser, gboolean select_multiple);
+static gchar* (*fp_gtk_file_chooser_get_current_folder)
+                                                      (GtkFileChooser *chooser);
+static GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
+static guint (*fp_gtk_g_slist_length)(GSList *list);
+static gulong (*fp_g_signal_connect_data)(gpointer instance,
+    const gchar *detailed_signal, GCallback c_handler, gpointer data,
+    GClosureNotify destroy_data, GConnectFlags connect_flags);
+static void (*fp_gtk_widget_show)(void *widget);
+static void (*fp_gtk_main)(void);
+static guint (*fp_gtk_main_level)(void);
+static gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
+static XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
+
+static GList* (*fp_g_list_append) (GList *list, gpointer data);
+static void (*fp_g_list_free) (GList *list);
+static void (*fp_g_list_free_full) (GList *list, GDestroyNotify free_func);
+
+static void (*fp_gdk_threads_enter)(void);
+static void (*fp_gdk_threads_leave)(void);
+
+static gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
+    guint32 timestamp, GError **error);
+
+// Implementation functions prototypes
+static void gtk3_init(GtkApi* gtk);
+static GValue*      (*fp_g_value_init)(GValue *value, GType g_type);
+static gboolean     (*fp_g_type_is_a)(GType type, GType is_a_type);
+static gboolean     (*fp_g_value_get_boolean)(const GValue *value);
+static gchar        (*fp_g_value_get_char)(const GValue *value);
+static guchar       (*fp_g_value_get_uchar)(const GValue *value);
+static gint         (*fp_g_value_get_int)(const GValue *value);
+static guint        (*fp_g_value_get_uint)(const GValue *value);
+static glong        (*fp_g_value_get_long)(const GValue *value);
+static gulong       (*fp_g_value_get_ulong)(const GValue *value);
+static gint64       (*fp_g_value_get_int64)(const GValue *value);
+static guint64      (*fp_g_value_get_uint64)(const GValue *value);
+static gfloat       (*fp_g_value_get_float)(const GValue *value);
+static gdouble      (*fp_g_value_get_double)(const GValue *value);
+static const gchar* (*fp_g_value_get_string)(const GValue *value);
+static gint         (*fp_g_value_get_enum)(const GValue *value);
+static guint        (*fp_g_value_get_flags)(const GValue *value);
+static GParamSpec*  (*fp_g_value_get_param)(const GValue *value);
+static gpointer*    (*fp_g_value_get_boxed)(const GValue *value);
+static gpointer*    (*fp_g_value_get_pointer)(const GValue *value);
+static void         (*fp_g_object_get)(gpointer object,
+                                       const gchar* fpn, ...);
+static void         (*fp_g_object_set)(gpointer object,
+                                       const gchar *first_property_name,
+                                       ...);
+
+static gboolean (*fp_g_main_context_iteration)(GMainContext *context);
+static gboolean (*fp_g_str_has_prefix)(const gchar *str, const gchar *prefix);
+static gchar** (*fp_g_strsplit)(const gchar *string, const gchar *delimiter,
+           gint max_tokens);
+static void (*fp_g_strfreev)(gchar **str_array);
+
+
+static cairo_surface_t* (*fp_cairo_image_surface_create)(cairo_format_t format,
+                               int width, int height);
+static void (*fp_cairo_surface_destroy)(cairo_surface_t *surface);
+static cairo_t* (*fp_cairo_create)(cairo_surface_t *target);
+static void (*fp_cairo_destroy)(cairo_t *cr);
+static void (*fp_cairo_fill)(cairo_t *cr);
+static void (*fp_cairo_surface_flush)(cairo_surface_t *surface);
+static void (*fp_cairo_rectangle)(cairo_t *cr, double x, double y, double width,
+                double height);
+static void (*fp_cairo_set_source_rgb)(cairo_t *cr, double red, double green,
+                double blue);
+static void (*fp_cairo_set_source_rgba)(cairo_t *cr, double red, double green,
+                double blue, double alpha);
+static void (*fp_cairo_paint)(cairo_t *cr);
+static void (*fp_cairo_clip)(cairo_t *cr);
+static unsigned char* (*fp_cairo_image_surface_get_data)(
+                                                 cairo_surface_t *surface);
+static int (*fp_cairo_image_surface_get_stride) (cairo_surface_t *surface);
+static GdkPixbuf* (*fp_gdk_pixbuf_get_from_surface)(cairo_surface_t *surface,
+                            gint src_x, gint src_y, gint width, gint height);
+static GtkStateType (*fp_gtk_widget_get_state)(GtkWidget *widget);
+static void (*fp_gtk_widget_set_state)(GtkWidget *widget, GtkStateType state);
+static gboolean (*fp_gtk_widget_is_focus)(GtkWidget *widget);
+static void (*fp_gtk_widget_set_allocation)(GtkWidget *widget,
+                                            const GtkAllocation *allocation);
+static GtkWidget* (*fp_gtk_widget_get_parent)(GtkWidget *widget);
+static GtkStyleContext* (*fp_gtk_widget_get_style_context)(GtkWidget *widget);
+static void (*fp_gtk_style_context_get_color)(GtkStyleContext *context,
+                                           GtkStateFlags state, GdkRGBA *color);
+static void (*fp_gtk_style_context_get_background_color)
+                (GtkStyleContext *context, GtkStateFlags state, GdkRGBA *color);
+static void (*fp_gtk_style_context_get)(GtkStyleContext *context,
+                                                      GtkStateFlags state, ...);
+static GtkStateFlags (*fp_gtk_widget_get_state_flags)(GtkWidget* widget);
+static void (*fp_gtk_style_context_set_state)(GtkStyleContext* style,
+                                              GtkStateFlags flags);
+static void (*fp_gtk_style_context_add_class)(GtkStyleContext *context,
+                                                 const gchar *class_name);
+static void (*fp_gtk_style_context_save)(GtkStyleContext *context);
+static void (*fp_gtk_style_context_restore)(GtkStyleContext *context);
+static void (*fp_gtk_render_check)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_option)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_extension)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height,
+                     GtkPositionType gap_side);
+static void (*fp_gtk_render_expander)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_frame_gap)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height,
+                     GtkPositionType gap_side, gdouble xy0_gap,
+                     gdouble xy1_gap);
+static void (*fp_gtk_render_line)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble x0, gdouble y0, gdouble x1, gdouble y1);
+static GdkPixbuf* (*fp_gtk_widget_render_icon_pixbuf)(GtkWidget *widget,
+                     const gchar *stock_id, GtkIconSize size);
+static cairo_surface_t* (*fp_gdk_window_create_similar_image_surface)(
+                     GdkWindow *window, cairo_format_t format, int width,
+                     int height, int scale);
+static cairo_surface_t* (*fp_gdk_window_create_similar_surface)(
+                     GdkWindow *window, cairo_format_t format,
+                     int width, int height);
+static GdkWindow* (*fp_gtk_widget_get_window)(GtkWidget *widget);
+static GtkSettings *(*fp_gtk_settings_get_for_screen)(GdkScreen *screen);
+static GdkScreen *(*fp_gtk_widget_get_screen)(GtkWidget *widget);
+static GtkStyleProvider* (*fp_gtk_css_provider_get_named)(const gchar *name,
+                     const gchar *variant);
+static void (*fp_gtk_style_context_add_provider)(GtkStyleContext *context,
+                     GtkStyleProvider *provider, guint priority);
+static void (*fp_gtk_render_frame)(GtkStyleContext *context,cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_focus)(GtkStyleContext *context,cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_handle)(GtkStyleContext *context,cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_style_context_get_property)(GtkStyleContext *context,
+                     const gchar *property, GtkStateFlags state, GValue *value);
+static void (*fp_gtk_render_activity)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_background)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height);
+static gboolean (*fp_gtk_style_context_has_class)(GtkStyleContext *context,
+                     const gchar *class_name);
+static void transform_detail_string (const gchar *detail,
+                     GtkStyleContext *context);
+void (*fp_gtk_style_context_set_junction_sides)(GtkStyleContext  *context,
+                     GtkJunctionSides  sides);
+void (*fp_gtk_style_context_add_region)(GtkStyleContext *context,
+                     const gchar *region_name, GtkRegionFlags flags);
+void (*fp_gtk_render_arrow)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble angle, gdouble x, gdouble y, gdouble size);
+void (*fp_gtk_bin_set_child)(GtkBin *bin, GtkWidget *widget);
+void (*fp_gtk_scrolled_window_set_shadow_type)(
+                     GtkScrolledWindow *scrolled_window, GtkShadowType type);
+static void (*fp_gtk_render_slider)(GtkStyleContext *context, cairo_t *cr,
+                     gdouble x, gdouble y, gdouble width, gdouble height,
+                     GtkOrientation orientation);
+static void (*fp_gtk_style_context_get_padding)(GtkStyleContext *self,
+                     GtkStateFlags state, GtkBorder* padding);
+static void (*fp_gtk_range_set_inverted)(GtkRange *range, gboolean  setting);
+static PangoFontDescription* (*fp_gtk_style_context_get_font)(
+                     GtkStyleContext *context, GtkStateFlags state);
+static int (*fp_gtk_widget_get_allocated_width)(GtkWidget *widget);
+static int (*fp_gtk_widget_get_allocated_height)(GtkWidget *widget);
+static GtkIconTheme* (*fp_gtk_icon_theme_get_default)(void);
+static GdkPixbuf* (*fp_gtk_icon_theme_load_icon)(GtkIconTheme *icon_theme,
+                     const gchar *icon_name, gint size,
+                     GtkIconLookupFlags flags, GError **error);
+static void (*fp_gtk_adjustment_set_lower)(GtkAdjustment *adjustment,
+                     gdouble lower);
+static void (*fp_gtk_adjustment_set_page_increment)(GtkAdjustment *adjustment,
+                     gdouble page_increment);
+static void (*fp_gtk_adjustment_set_page_size)(GtkAdjustment *adjustment,
+                     gdouble page_size);
+static void (*fp_gtk_adjustment_set_step_increment)(GtkAdjustment *adjustment,
+                     gdouble step_increment);
+static void (*fp_gtk_adjustment_set_upper)(GtkAdjustment *adjustment,
+                     gdouble upper);
+static void (*fp_gtk_adjustment_set_value)(GtkAdjustment *adjustment,
+                     gdouble value);
+static GdkGC *(*fp_gdk_gc_new)(GdkDrawable*);
+static void (*fp_gdk_rgb_gc_set_foreground)(GdkGC*, guint32);
+static void (*fp_gdk_draw_rectangle)(GdkDrawable*, GdkGC*, gboolean,
+        gint, gint, gint, gint);
+static GdkPixbuf *(*fp_gdk_pixbuf_new)(GdkColorspace colorspace,
+        gboolean has_alpha, int bits_per_sample, int width, int height);
+static void (*fp_gdk_drawable_get_size)(GdkDrawable *drawable,
+        gint* width, gint* height);
+static gboolean (*fp_gtk_init_check)(int* argc, char** argv);
+
+/* Widget creation */
+static GtkWidget* (*fp_gtk_arrow_new)(GtkArrowType arrow_type,
+                                      GtkShadowType shadow_type);
+static GtkWidget* (*fp_gtk_button_new)();
+static GtkWidget* (*fp_gtk_check_button_new)();
+static GtkWidget* (*fp_gtk_check_menu_item_new)();
+static GtkWidget* (*fp_gtk_color_selection_dialog_new)(const gchar* title);
+static GtkWidget* (*fp_gtk_combo_box_new)();
+static GtkWidget* (*fp_gtk_combo_box_entry_new)();
+static GtkWidget* (*fp_gtk_entry_new)();
+static GtkWidget* (*fp_gtk_fixed_new)();
+static GtkWidget* (*fp_gtk_handle_box_new)();
+static GtkWidget* (*fp_gtk_hpaned_new)();
+static GtkWidget* (*fp_gtk_vpaned_new)();
+static GtkWidget* (*fp_gtk_scale_new)(GtkOrientation  orientation,
+                                       GtkAdjustment* adjustment);
+static GtkWidget* (*fp_gtk_hscrollbar_new)(GtkAdjustment* adjustment);
+static GtkWidget* (*fp_gtk_vscrollbar_new)(GtkAdjustment* adjustment);
+static GtkWidget* (*fp_gtk_hseparator_new)();
+static GtkWidget* (*fp_gtk_vseparator_new)();
+static GtkWidget* (*fp_gtk_image_new)();
+static GtkWidget* (*fp_gtk_label_new)(const gchar* str);
+static GtkWidget* (*fp_gtk_menu_new)();
+static GtkWidget* (*fp_gtk_menu_bar_new)();
+static GtkWidget* (*fp_gtk_menu_item_new)();
+static GtkWidget* (*fp_gtk_notebook_new)();
+static GtkWidget* (*fp_gtk_progress_bar_new)();
+static GtkWidget* (*fp_gtk_progress_bar_set_orientation)(
+        GtkProgressBar *pbar,
+        GtkProgressBarOrientation orientation);
+static GtkWidget* (*fp_gtk_radio_button_new)(GSList *group);
+static GtkWidget* (*fp_gtk_radio_menu_item_new)(GSList *group);
+static GtkWidget* (*fp_gtk_scrolled_window_new)(GtkAdjustment *hadjustment,
+        GtkAdjustment *vadjustment);
+static GtkWidget* (*fp_gtk_separator_menu_item_new)();
+static GtkWidget* (*fp_gtk_separator_tool_item_new)();
+static GtkWidget* (*fp_gtk_text_view_new)();
+static GtkWidget* (*fp_gtk_toggle_button_new)();
+static GtkWidget* (*fp_gtk_toolbar_new)();
+static GtkWidget* (*fp_gtk_tree_view_new)();
+static GtkWidget* (*fp_gtk_viewport_new)(GtkAdjustment *hadjustment,
+        GtkAdjustment *vadjustment);
+static GtkWidget* (*fp_gtk_window_new)(GtkWindowType type);
+static GtkWidget* (*fp_gtk_dialog_new)();
+static GtkWidget* (*fp_gtk_spin_button_new)(GtkAdjustment *adjustment,
+        gdouble climb_rate, guint digits);
+static GtkWidget* (*fp_gtk_frame_new)(const gchar *label);
+
+/* Other widget operations */
+static GtkAdjustment* (*fp_gtk_adjustment_new)(gdouble value,
+        gdouble lower, gdouble upper, gdouble step_increment,
+        gdouble page_increment, gdouble page_size);
+static void (*fp_gtk_container_add)(GtkContainer *window, GtkWidget *widget);
+static void (*fp_gtk_menu_shell_append)(GtkMenuShell *menu_shell,
+        GtkWidget *child);
+static void (*fp_gtk_menu_item_set_submenu)(GtkMenuItem *menu_item,
+        GtkWidget *submenu);
+static void (*fp_gtk_widget_realize)(GtkWidget *widget);
+static GdkPixbuf* (*fp_gtk_widget_render_icon)(GtkWidget *widget,
+        const gchar *stock_id, GtkIconSize size, const gchar *detail);
+static void (*fp_gtk_widget_set_name)(GtkWidget *widget, const gchar *name);
+static void (*fp_gtk_widget_set_parent)(GtkWidget *widget, GtkWidget *parent);
+static void (*fp_gtk_widget_set_direction)(GtkWidget *widget,
+        GtkTextDirection direction);
+static void (*fp_gtk_widget_style_get)(GtkWidget *widget,
+        const gchar *first_property_name, ...);
+static void (*fp_gtk_widget_class_install_style_property)(
+        GtkWidgetClass* class, GParamSpec *pspec);
+static GParamSpec* (*fp_gtk_widget_class_find_style_property)(
+        GtkWidgetClass* class, const gchar* property_name);
+static void (*fp_gtk_widget_style_get_property)(GtkWidget* widget,
+        const gchar* property_name, GValue* value);
+static char* (*fp_pango_font_description_to_string)(
+        const PangoFontDescription* fd);
+static GtkSettings* (*fp_gtk_settings_get_default)();
+static GtkSettings* (*fp_gtk_widget_get_settings)(GtkWidget *widget);
+static GType        (*fp_gtk_border_get_type)();
+static void (*fp_gtk_arrow_set)(GtkWidget* arrow,
+                                GtkArrowType arrow_type,
+                                GtkShadowType shadow_type);
+static void (*fp_gtk_widget_size_request)(GtkWidget *widget,
+                                          GtkRequisition *requisition);
+static GtkAdjustment* (*fp_gtk_range_get_adjustment)(GtkRange* range);
+
+#endif /* !_GTK3_INTERFACE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.c	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2005, 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.
+ */
+#include <dlfcn.h>
+#include <stdlib.h>
+#include "jvm_md.h"
+#include "gtk_interface.h"
+
+GtkApi* gtk2_load(JNIEnv *env, const char* lib_name);
+GtkApi* gtk3_load(JNIEnv *env, const char* lib_name);
+
+gboolean gtk2_check(const char* lib_name, int flags);
+gboolean gtk3_check(const char* lib_name, int flags);
+
+GtkApi *gtk;
+
+typedef struct {
+    GtkVersion version;
+    const char* name;
+    const char* vname;
+    GtkApi* (*load)(JNIEnv *env, const char* lib_name);
+    gboolean (*check)(const char* lib_name, int flags);
+} GtkLib;
+
+static GtkLib libs[] = {
+    {
+        GTK_2,
+        JNI_LIB_NAME("gtk-x11-2.0"),
+        VERSIONED_JNI_LIB_NAME("gtk-x11-2.0", "0"),
+        &gtk2_load,
+        &gtk2_check
+    },
+    {
+        GTK_3,
+        JNI_LIB_NAME("gtk-3"),
+        VERSIONED_JNI_LIB_NAME("gtk-3", "0"),
+        &gtk3_load,
+        &gtk3_check
+    },
+    {
+        0,
+        NULL,
+        NULL,
+        NULL,
+        NULL
+    }
+};
+
+static GtkLib* get_loaded() {
+    GtkLib* lib = libs;
+    while(!gtk && lib->version) {
+        if (lib->check(lib->vname, RTLD_NOLOAD)) {
+            return lib;
+        }
+        if (lib->check(lib->name, RTLD_NOLOAD)) {
+            return lib;
+        }
+        lib++;
+    }
+    return NULL;
+}
+
+gboolean gtk_load(JNIEnv *env, GtkVersion version, gboolean verbose) {
+    if (gtk == NULL) {
+        GtkLib* lib = get_loaded();
+        if (lib) {
+            if (version != GTK_ANY && lib->version != version) {
+                if (verbose) {
+                    fprintf(stderr, "WARNING: Cannot load GTK%d library: \
+                         GTK%d has already been loaded\n", version, lib->version);
+                }
+                return FALSE;
+            }
+            if (verbose) {
+                fprintf(stderr, "Looking for GTK%d library...\n", version);
+            }
+            gtk = lib->load(env, lib->vname);
+            if (!gtk) {
+                gtk = lib->load(env, lib->name);
+            }
+        } else {
+            lib = libs;
+            while (!gtk && lib->version) {
+                if (version == GTK_ANY || lib->version == version) {
+                    if (verbose) {
+                        fprintf(stderr, "Looking for GTK%d library...\n",
+                                                                  lib->version);
+                    }
+                    gtk = lib->load(env, lib->vname);
+                    if (!gtk) {
+                        gtk = lib->load(env, lib->name);
+                    }
+                    if (verbose && !gtk) {
+                        fprintf(stderr, "Not found.\n");
+                    }
+                }
+                lib++;
+            }
+            lib--;
+        }
+        if (verbose) {
+            if (gtk) {
+                fprintf(stderr, "GTK%d library loaded.\n", lib->version);
+            } else {
+                fprintf(stderr, "Failed to load GTK library.\n");
+            }
+        }
+    }
+    return gtk != NULL;
+}
+
+static gboolean check_version(GtkVersion version, int flags) {
+    GtkLib* lib = libs;
+    while (lib->version) {
+        if (version == GTK_ANY || lib->version == version) {
+            if (lib->check(lib->vname, flags)) {
+                return TRUE;
+            }
+            if (lib->check(lib->name, flags)) {
+                return TRUE;
+            }
+        }
+        lib++;
+    }
+    return FALSE;
+}
+
+gboolean gtk_check_version(GtkVersion version) {
+    if (gtk) {
+        return TRUE;
+    }
+    if (check_version(version, RTLD_NOLOAD)) {
+        return TRUE;
+    }
+    return check_version(version, RTLD_LAZY | RTLD_LOCAL);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.h	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,560 @@
+/*
+ * Copyright (c) 2005, 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.
+ */
+#ifndef _GTK_INTERFACE_H
+#define _GTK_INTERFACE_H
+
+#include <X11/X.h>
+#include <jni.h>
+
+#ifndef FALSE
+#define FALSE           (0)
+#define TRUE            (!FALSE)
+#endif
+
+#define _G_TYPE_CIC(ip, gt, ct)       ((ct*) ip)
+#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type)  \
+                                    (_G_TYPE_CIC ((instance), (g_type), c_type))
+#define GTK_TYPE_FILE_CHOOSER             (fp_gtk_file_chooser_get_type ())
+#define GTK_FILE_CHOOSER(obj) \
+     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser))
+#define G_CALLBACK(f) ((GCallback) (f))
+#define G_TYPE_FUNDAMENTAL_SHIFT (2)
+#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
+#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
+#define GTK_STOCK_CANCEL           "gtk-cancel"
+#define GTK_STOCK_SAVE             "gtk-save"
+#define GTK_STOCK_OPEN             "gtk-open"
+#define GDK_CURRENT_TIME           0L
+
+#define G_TYPE_INVALID                  G_TYPE_MAKE_FUNDAMENTAL (0)
+#define G_TYPE_NONE                     G_TYPE_MAKE_FUNDAMENTAL (1)
+#define G_TYPE_INTERFACE                G_TYPE_MAKE_FUNDAMENTAL (2)
+#define G_TYPE_CHAR                     G_TYPE_MAKE_FUNDAMENTAL (3)
+#define G_TYPE_UCHAR                    G_TYPE_MAKE_FUNDAMENTAL (4)
+#define G_TYPE_BOOLEAN                  G_TYPE_MAKE_FUNDAMENTAL (5)
+#define G_TYPE_INT                      G_TYPE_MAKE_FUNDAMENTAL (6)
+#define G_TYPE_UINT                     G_TYPE_MAKE_FUNDAMENTAL (7)
+#define G_TYPE_LONG                     G_TYPE_MAKE_FUNDAMENTAL (8)
+#define G_TYPE_ULONG                    G_TYPE_MAKE_FUNDAMENTAL (9)
+#define G_TYPE_INT64                    G_TYPE_MAKE_FUNDAMENTAL (10)
+#define G_TYPE_UINT64                   G_TYPE_MAKE_FUNDAMENTAL (11)
+#define G_TYPE_ENUM                     G_TYPE_MAKE_FUNDAMENTAL (12)
+#define G_TYPE_FLAGS                    G_TYPE_MAKE_FUNDAMENTAL (13)
+#define G_TYPE_FLOAT                    G_TYPE_MAKE_FUNDAMENTAL (14)
+#define G_TYPE_DOUBLE                   G_TYPE_MAKE_FUNDAMENTAL (15)
+#define G_TYPE_STRING                   G_TYPE_MAKE_FUNDAMENTAL (16)
+#define G_TYPE_POINTER                  G_TYPE_MAKE_FUNDAMENTAL (17)
+#define G_TYPE_BOXED                    G_TYPE_MAKE_FUNDAMENTAL (18)
+#define G_TYPE_PARAM                    G_TYPE_MAKE_FUNDAMENTAL (19)
+#define G_TYPE_OBJECT                   G_TYPE_MAKE_FUNDAMENTAL (20)
+
+#define GTK_TYPE_BORDER                 ((*fp_gtk_border_get_type)())
+
+#define G_TYPE_FUNDAMENTAL_SHIFT        (2)
+#define G_TYPE_MAKE_FUNDAMENTAL(x)      ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
+
+#ifndef MIN
+#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
+#endif
+
+#define CONV_BUFFER_SIZE 128
+#define NO_SYMBOL_EXCEPTION 1
+
+/* basic types */
+typedef char    gchar;
+typedef short   gshort;
+typedef int     gint;
+typedef long    glong;
+typedef float   gfloat;
+typedef double  gdouble;
+typedef void*   gpointer;
+typedef gint    gboolean;
+typedef signed char  gint8;
+typedef signed short gint16;
+typedef signed int   gint32;
+typedef unsigned char  guchar;
+typedef unsigned char  guint8;
+typedef unsigned short gushort;
+typedef unsigned short guint16;
+typedef unsigned int   guint;
+typedef unsigned int   guint32;
+typedef unsigned int   gsize;
+typedef unsigned long  gulong;
+typedef signed long long   gint64;
+typedef unsigned long long guint64;
+typedef gulong GType;
+
+typedef struct _GList GList;
+struct _GList
+{
+  gpointer data;
+  GList *next;
+  GList *prev;
+};
+
+typedef struct _GSList GSList;
+struct _GSList {
+  gpointer data;
+  GSList *next;
+};
+
+typedef enum {
+    BUTTON,                     /* GtkButton */
+    CHECK_BOX,                  /* GtkCheckButton */
+    CHECK_BOX_MENU_ITEM,        /* GtkCheckMenuItem */
+    COLOR_CHOOSER,              /* GtkColorSelectionDialog */
+    COMBO_BOX,                  /* GtkComboBox */
+    COMBO_BOX_ARROW_BUTTON,     /* GtkComboBoxEntry */
+    COMBO_BOX_TEXT_FIELD,       /* GtkComboBoxEntry */
+    DESKTOP_ICON,               /* GtkLabel */
+    DESKTOP_PANE,               /* GtkContainer */
+    EDITOR_PANE,                /* GtkTextView */
+    FORMATTED_TEXT_FIELD,       /* GtkEntry */
+    HANDLE_BOX,                 /* GtkHandleBox */
+    HPROGRESS_BAR,              /* GtkProgressBar */
+    HSCROLL_BAR,                /* GtkHScrollbar */
+    HSCROLL_BAR_BUTTON_LEFT,    /* GtkHScrollbar */
+    HSCROLL_BAR_BUTTON_RIGHT,   /* GtkHScrollbar */
+    HSCROLL_BAR_TRACK,          /* GtkHScrollbar */
+    HSCROLL_BAR_THUMB,          /* GtkHScrollbar */
+    HSEPARATOR,                 /* GtkHSeparator */
+    HSLIDER,                    /* GtkHScale */
+    HSLIDER_TRACK,              /* GtkHScale */
+    HSLIDER_THUMB,              /* GtkHScale */
+    HSPLIT_PANE_DIVIDER,        /* GtkHPaned */
+    INTERNAL_FRAME,             /* GtkWindow */
+    INTERNAL_FRAME_TITLE_PANE,  /* GtkLabel */
+    IMAGE,                      /* GtkImage */
+    LABEL,                      /* GtkLabel */
+    LIST,                       /* GtkTreeView */
+    MENU,                       /* GtkMenu */
+    MENU_BAR,                   /* GtkMenuBar */
+    MENU_ITEM,                  /* GtkMenuItem */
+    MENU_ITEM_ACCELERATOR,      /* GtkLabel */
+    OPTION_PANE,                /* GtkMessageDialog */
+    PANEL,                      /* GtkContainer */
+    PASSWORD_FIELD,             /* GtkEntry */
+    POPUP_MENU,                 /* GtkMenu */
+    POPUP_MENU_SEPARATOR,       /* GtkSeparatorMenuItem */
+    RADIO_BUTTON,               /* GtkRadioButton */
+    RADIO_BUTTON_MENU_ITEM,     /* GtkRadioMenuItem */
+    ROOT_PANE,                  /* GtkContainer */
+    SCROLL_PANE,                /* GtkScrolledWindow */
+    SPINNER,                    /* GtkSpinButton */
+    SPINNER_ARROW_BUTTON,       /* GtkSpinButton */
+    SPINNER_TEXT_FIELD,         /* GtkSpinButton */
+    SPLIT_PANE,                 /* GtkPaned */
+    TABBED_PANE,                /* GtkNotebook */
+    TABBED_PANE_TAB_AREA,       /* GtkNotebook */
+    TABBED_PANE_CONTENT,        /* GtkNotebook */
+    TABBED_PANE_TAB,            /* GtkNotebook */
+    TABLE,                      /* GtkTreeView */
+    TABLE_HEADER,               /* GtkButton */
+    TEXT_AREA,                  /* GtkTextView */
+    TEXT_FIELD,                 /* GtkEntry */
+    TEXT_PANE,                  /* GtkTextView */
+    TITLED_BORDER,              /* GtkFrame */
+    TOGGLE_BUTTON,              /* GtkToggleButton */
+    TOOL_BAR,                   /* GtkToolbar */
+    TOOL_BAR_DRAG_WINDOW,       /* GtkToolbar */
+    TOOL_BAR_SEPARATOR,         /* GtkSeparatorToolItem */
+    TOOL_TIP,                   /* GtkWindow */
+    TREE,                       /* GtkTreeView */
+    TREE_CELL,                  /* GtkTreeView */
+    VIEWPORT,                   /* GtkViewport */
+    VPROGRESS_BAR,              /* GtkProgressBar */
+    VSCROLL_BAR,                /* GtkVScrollbar */
+    VSCROLL_BAR_BUTTON_UP,      /* GtkVScrollbar */
+    VSCROLL_BAR_BUTTON_DOWN,    /* GtkVScrollbar */
+    VSCROLL_BAR_TRACK,          /* GtkVScrollbar */
+    VSCROLL_BAR_THUMB,          /* GtkVScrollbar */
+    VSEPARATOR,                 /* GtkVSeparator */
+    VSLIDER,                    /* GtkVScale */
+    VSLIDER_TRACK,              /* GtkVScale */
+    VSLIDER_THUMB,              /* GtkVScale */
+    VSPLIT_PANE_DIVIDER,        /* GtkVPaned */
+    WIDGET_TYPE_SIZE
+} WidgetType;
+
+typedef enum
+{
+    _GTK_ARROW_TYPE,
+    _GTK_BUTTON_TYPE,
+    _GTK_CHECK_BUTTON_TYPE,
+    _GTK_CHECK_MENU_ITEM_TYPE,
+    _GTK_COLOR_SELECTION_DIALOG_TYPE,
+    _GTK_COMBO_BOX_TYPE,
+    _GTK_COMBO_BOX_ARROW_BUTTON_TYPE,
+    _GTK_COMBO_BOX_TEXT_FIELD_TYPE,
+    _GTK_CONTAINER_TYPE,
+    _GTK_ENTRY_TYPE,
+    _GTK_FRAME_TYPE,
+    _GTK_HANDLE_BOX_TYPE,
+    _GTK_HPANED_TYPE,
+    _GTK_HPROGRESS_BAR_TYPE,
+    _GTK_HSCALE_TYPE,
+    _GTK_HSCROLLBAR_TYPE,
+    _GTK_HSEPARATOR_TYPE,
+    _GTK_IMAGE_TYPE,
+    _GTK_MENU_TYPE,
+    _GTK_MENU_BAR_TYPE,
+    _GTK_MENU_ITEM_TYPE,
+    _GTK_NOTEBOOK_TYPE,
+    _GTK_LABEL_TYPE,
+    _GTK_RADIO_BUTTON_TYPE,
+    _GTK_RADIO_MENU_ITEM_TYPE,
+    _GTK_SCROLLED_WINDOW_TYPE,
+    _GTK_SEPARATOR_MENU_ITEM_TYPE,
+    _GTK_SEPARATOR_TOOL_ITEM_TYPE,
+    _GTK_SPIN_BUTTON_TYPE,
+    _GTK_TEXT_VIEW_TYPE,
+    _GTK_TOGGLE_BUTTON_TYPE,
+    _GTK_TOOLBAR_TYPE,
+    _GTK_TOOLTIP_TYPE,
+    _GTK_TREE_VIEW_TYPE,
+    _GTK_VIEWPORT_TYPE,
+    _GTK_VPANED_TYPE,
+    _GTK_VPROGRESS_BAR_TYPE,
+    _GTK_VSCALE_TYPE,
+    _GTK_VSCROLLBAR_TYPE,
+    _GTK_VSEPARATOR_TYPE,
+    _GTK_WINDOW_TYPE,
+    _GTK_DIALOG_TYPE,
+    _GTK_WIDGET_TYPE_SIZE
+} GtkWidgetType;
+
+typedef enum
+{
+  GTK_STATE_NORMAL,
+  GTK_STATE_ACTIVE,
+  GTK_STATE_PRELIGHT,
+  GTK_STATE_SELECTED,
+  GTK_STATE_INSENSITIVE,
+  GTK_STATE_INCONSISTENT,
+  GTK_STATE_FOCUSED
+} GtkStateType;
+
+typedef enum
+{
+  GTK_SHADOW_NONE,
+  GTK_SHADOW_IN,
+  GTK_SHADOW_OUT,
+  GTK_SHADOW_ETCHED_IN,
+  GTK_SHADOW_ETCHED_OUT
+} GtkShadowType;
+
+typedef enum
+{
+  GTK_EXPANDER_COLLAPSED,
+  GTK_EXPANDER_SEMI_COLLAPSED,
+  GTK_EXPANDER_SEMI_EXPANDED,
+  GTK_EXPANDER_EXPANDED
+} GtkExpanderStyle;
+
+typedef enum
+{
+  GTK_ICON_SIZE_INVALID,
+  GTK_ICON_SIZE_MENU,
+  GTK_ICON_SIZE_SMALL_TOOLBAR,
+  GTK_ICON_SIZE_LARGE_TOOLBAR,
+  GTK_ICON_SIZE_BUTTON,
+  GTK_ICON_SIZE_DND,
+  GTK_ICON_SIZE_DIALOG
+} GtkIconSize;
+
+typedef enum
+{
+  GTK_ORIENTATION_HORIZONTAL,
+  GTK_ORIENTATION_VERTICAL
+} GtkOrientation;
+
+typedef enum
+{
+    FOREGROUND,
+    BACKGROUND,
+    TEXT_FOREGROUND,
+    TEXT_BACKGROUND,
+    FOCUS,
+    LIGHT,
+    DARK,
+    MID,
+    BLACK,
+    WHITE
+} ColorType;
+
+typedef enum
+{
+    GTK_FONT_NAME,
+    GTK_ICON_SIZES,
+    GTK_CURSOR_BLINK,
+    GTK_CURSOR_BLINK_TIME
+} Setting;
+
+typedef enum
+{
+  GTK_ARROW_UP,
+  GTK_ARROW_DOWN,
+  GTK_ARROW_LEFT,
+  GTK_ARROW_RIGHT,
+  GTK_ARROW_NONE
+} GtkArrowType;
+
+typedef enum
+{
+  GTK_TEXT_DIR_NONE,
+  GTK_TEXT_DIR_LTR,
+  GTK_TEXT_DIR_RTL
+} GtkTextDirection;
+
+typedef enum
+{
+  GTK_POS_LEFT,
+  GTK_POS_RIGHT,
+  GTK_POS_TOP,
+  GTK_POS_BOTTOM
+} GtkPositionType;
+
+/* SynthConstants */
+static const gint ENABLED    = 1 << 0;
+static const gint MOUSE_OVER = 1 << 1;
+static const gint PRESSED    = 1 << 2;
+static const gint DISABLED   = 1 << 3;
+static const gint FOCUSED    = 1 << 8;
+static const gint SELECTED   = 1 << 9;
+static const gint DEFAULT    = 1 << 10;
+
+typedef enum
+{
+  GTK_ANY,
+  GTK_1,
+  GTK_2,
+  GTK_3
+} GtkVersion;
+
+//------------------------------
+
+
+
+typedef enum {
+  GTK_RESPONSE_NONE = -1,
+  GTK_RESPONSE_REJECT = -2,
+  GTK_RESPONSE_ACCEPT = -3,
+  GTK_RESPONSE_DELETE_EVENT = -4,
+  GTK_RESPONSE_OK = -5,
+  GTK_RESPONSE_CANCEL = -6,
+  GTK_RESPONSE_CLOSE = -7,
+  GTK_RESPONSE_YES = -8,
+  GTK_RESPONSE_NO = -9,
+  GTK_RESPONSE_APPLY = -10,
+  GTK_RESPONSE_HELP = -11
+} GtkResponseType;
+
+typedef enum {
+  GTK_FILE_CHOOSER_ACTION_OPEN,
+  GTK_FILE_CHOOSER_ACTION_SAVE,
+  GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+  GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
+} GtkFileChooserAction;
+
+typedef enum {
+  GTK_FILE_FILTER_FILENAME = 1 << 0,
+  GTK_FILE_FILTER_URI = 1 << 1,
+  GTK_FILE_FILTER_DISPLAY_NAME = 1 << 2,
+  GTK_FILE_FILTER_MIME_TYPE = 1 << 3
+} GtkFileFilterFlags;
+
+typedef enum {
+  GDK_COLORSPACE_RGB
+} GdkColorspace;
+
+typedef enum {
+    GDK_INTERP_NEAREST,
+    GDK_INTERP_TILES,
+    GDK_INTERP_BILINEAR,
+    GDK_INTERP_HYPER
+} GdkInterpType;
+
+typedef enum {
+  G_CONNECT_AFTER = 1 << 0, G_CONNECT_SWAPPED = 1 << 1
+} GConnectFlags;
+//------------------------------
+
+
+typedef void GError;
+typedef void GdkScreen;
+typedef void GtkWindow;
+typedef void GdkWindow;
+typedef void GClosure;
+typedef void GtkFileChooser;
+typedef void GtkFileFilter;
+typedef struct {
+    GtkFileFilterFlags contains;
+    const gchar *filename;
+    const gchar *uri;
+    const gchar *display_name;
+    const gchar *mime_type;
+} GtkFileFilterInfo;
+typedef gboolean (*GtkFileFilterFunc)(const GtkFileFilterInfo *filter_info,
+                                                                 gpointer data);
+typedef void (*GClosureNotify)(gpointer data, GClosure *closure);
+typedef void (*GDestroyNotify)(gpointer data);
+typedef void (*GCallback)(void);
+
+
+typedef struct GtkApi {
+    int version;
+    gboolean (*show_uri_load)(JNIEnv *env);
+    gboolean (*unload)();
+    void (*flush_event_loop)();
+    gchar* (*gtk_check_version)(guint required_major, guint required_minor,
+                                guint required_micro);
+    jobject (*get_setting)(JNIEnv *env, Setting property);
+
+    void (*paint_arrow)(WidgetType widget_type, GtkStateType state_type,
+        GtkShadowType shadow_type, const gchar *detail,
+        gint x, gint y, gint width, gint height,
+        GtkArrowType arrow_type, gboolean fill);
+    void (*paint_box)(WidgetType widget_type, GtkStateType state_type,
+                        GtkShadowType shadow_type, const gchar *detail,
+                        gint x, gint y, gint width, gint height,
+                        gint synth_state, GtkTextDirection dir);
+    void (*paint_box_gap)(WidgetType widget_type, GtkStateType state_type,
+            GtkShadowType shadow_type, const gchar *detail,
+            gint x, gint y, gint width, gint height,
+            GtkPositionType gap_side, gint gap_x, gint gap_width);
+    void (*paint_expander)(WidgetType widget_type, GtkStateType state_type,
+            const gchar *detail, gint x, gint y, gint width, gint height,
+            GtkExpanderStyle expander_style);
+    void (*paint_extension)(WidgetType widget_type, GtkStateType state_type,
+            GtkShadowType shadow_type, const gchar *detail,
+            gint x, gint y, gint width, gint height, GtkPositionType gap_side);
+    void (*paint_flat_box)(WidgetType widget_type, GtkStateType state_type,
+            GtkShadowType shadow_type, const gchar *detail,
+            gint x, gint y, gint width, gint height, gboolean has_focus);
+    void (*paint_focus)(WidgetType widget_type, GtkStateType state_type,
+            const char *detail, gint x, gint y, gint width, gint height);
+    void (*paint_handle)(WidgetType widget_type, GtkStateType state_type,
+           GtkShadowType shadow_type, const gchar *detail,
+           gint x, gint y, gint width, gint height, GtkOrientation orientation);
+    void (*paint_hline)(WidgetType widget_type, GtkStateType state_type,
+            const gchar *detail, gint x, gint y, gint width, gint height);
+    void (*paint_vline)(WidgetType widget_type, GtkStateType state_type,
+            const gchar *detail, gint x, gint y, gint width, gint height);
+    void (*paint_option)(WidgetType widget_type, gint synth_state,
+             const gchar *detail, gint x, gint y, gint width, gint height);
+    void (*paint_shadow)(WidgetType widget_type, GtkStateType state_type,
+                           GtkShadowType shadow_type, const gchar *detail,
+                           gint x, gint y, gint width, gint height,
+                           gint synth_state, GtkTextDirection dir);
+    void (*paint_slider)(WidgetType widget_type, GtkStateType state_type,
+            GtkShadowType shadow_type, const gchar *detail,
+            gint x, gint y, gint width, gint height, GtkOrientation orientation,
+            gboolean has_focus);
+    void (*paint_background)(WidgetType widget_type, GtkStateType state_type,
+            gint x, gint y, gint width, gint height);
+    void (*paint_check)(WidgetType widget_type, gint synth_state,
+        const gchar *detail, gint x, gint y, gint width, gint height);
+    void (*set_range_value)(WidgetType widget_type, jdouble value,
+                              jdouble min, jdouble max, jdouble visible);
+
+    void (*init_painting)(JNIEnv *env, gint w, gint h);
+    gint (*copy_image)(gint *dest, gint width, gint height);
+
+    gint (*get_xthickness)(JNIEnv *env, WidgetType widget_type);
+    gint (*get_ythickness)(JNIEnv *env, WidgetType widget_type);
+    gint (*get_color_for_state)(JNIEnv *env, WidgetType widget_type,
+                                  GtkStateType state_type, ColorType color_type);
+    jobject (*get_class_value)(JNIEnv *env, WidgetType widget_type,
+                               const char* key);
+
+    jstring (*get_pango_font_name)(JNIEnv *env, WidgetType widget_type);
+    jboolean (*get_icon_data)(JNIEnv *env, gint widget_type,
+                    const gchar *stock_id, GtkIconSize size,
+                    GtkTextDirection direction, const char *detail,
+                    jmethodID icon_upcall_method, jobject this);
+    jboolean (*get_file_icon_data)(JNIEnv *env, const char *filename,
+                    GError **error, jmethodID icon_upcall_method, jobject this);
+    void (*gdk_threads_enter)(void);
+    void (*gdk_threads_leave)(void);
+    gboolean (*gtk_show_uri)(GdkScreen *screen, const gchar *uri,
+                                             guint32 timestamp, GError **error);
+    gboolean (*get_drawable_data)(JNIEnv *env, jintArray pixelArray,
+                                       jint x, jint y, jint width, jint height,
+                                       jint jwidth, int dx, int dy, jint scale);
+    void (*g_free)(gpointer mem);
+
+
+    gchar* (*gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
+    void (*gtk_widget_hide)(void* widget);
+    void (*gtk_main_quit)(void);
+    void* (*gtk_file_chooser_dialog_new)(const gchar *title,
+        GtkWindow *parent, GtkFileChooserAction action,
+        const gchar *first_button_text, ...);
+    gboolean (*gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
+        const gchar *filename);
+    gboolean (*gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
+        const char *filename);
+    void (*gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
+        const gchar *name);
+    void (*gtk_file_filter_add_custom)(GtkFileFilter *filter,
+        GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
+        GDestroyNotify notify);
+    void (*gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
+        GtkFileFilter *filter);
+    GType (*gtk_file_chooser_get_type)(void);
+    GtkFileFilter* (*gtk_file_filter_new)(void);
+    void (*gtk_file_chooser_set_do_overwrite_confirmation)(
+        GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
+    void (*gtk_file_chooser_set_select_multiple)(
+        GtkFileChooser *chooser, gboolean select_multiple);
+    gchar* (*gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
+    GSList* (*gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
+    guint (*gtk_g_slist_length)(GSList *list);
+    gulong (*g_signal_connect_data)(gpointer instance,
+        const gchar *detailed_signal, GCallback c_handler, gpointer data,
+        GClosureNotify destroy_data, GConnectFlags connect_flags);
+    void (*gtk_widget_show)(void *widget);
+    void (*gtk_main)(void);
+    guint (*gtk_main_level)(void);
+    gchar* (*g_path_get_dirname) (const gchar *file_name);
+    XID (*gdk_x11_drawable_get_xid) (void *drawable);
+    void (*gtk_widget_destroy)(void *widget);
+    void (*gtk_window_present)(void *window);
+    void (*gtk_window_move)(void *window, gint x, gint y);
+    void (*gtk_window_resize)(void *window, gint width, gint height);
+    GdkWindow *(*get_window)(void *widget);
+
+    void (*g_object_unref)(gpointer object);
+    GList* (*g_list_append) (GList *list, gpointer data);
+    void (*g_list_free) (GList *list);
+    void (*g_list_free_full) (GList *list, GDestroyNotify free_func);
+} GtkApi;
+
+gboolean gtk_load(JNIEnv *env, GtkVersion version, gboolean verbose);
+gboolean gtk_check_version(GtkVersion version);
+
+extern GtkApi* gtk;
+
+#endif /* !_GTK_INTERFACE_H */
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -28,11 +28,12 @@
 #include <jni_util.h>
 #include <string.h>
 #include <X11/X.h>
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
 #include "sun_awt_X11_GtkFileDialogPeer.h"
 #include "java_awt_FileDialog.h"
 #include "debug_assert.h"
 
+typedef void GtkWidget;
 static JavaVM *jvm;
 
 /* To cache some method IDs */
@@ -90,20 +91,20 @@
     {
         // Callbacks from GTK signals are made within the GTK lock
         // So, within a signal handler there is no need to call
-        // gdk_threads_enter() / fp_gdk_threads_leave()
+        // gdk_threads_enter() / gtk->gdk_threads_leave()
         if (!isSignalHandler) {
-            fp_gdk_threads_enter();
+            gtk->gdk_threads_enter();
         }
 
-        fp_gtk_widget_hide (dialog);
-        fp_gtk_widget_destroy (dialog);
+        gtk->gtk_widget_hide (dialog);
+        gtk->gtk_widget_destroy (dialog);
 
-        fp_gtk_main_quit ();
+        gtk->gtk_main_quit ();
 
         (*env)->SetLongField(env, jpeer, widgetFieldID, 0);
 
         if (!isSignalHandler) {
-            fp_gdk_threads_leave();
+            gtk->gdk_threads_leave();
         }
     }
 
@@ -133,16 +134,16 @@
 {
     GtkWidget * dialog;
 
-    fp_gdk_threads_enter();
+    gtk->gdk_threads_enter();
 
     dialog = (GtkWidget*)jlong_to_ptr(
             (*env)->GetLongField(env, jpeer, widgetFieldID));
 
     if (dialog != NULL) {
-        fp_gtk_window_present((GtkWindow*)dialog);
+        gtk->gtk_window_present((GtkWindow*)dialog);
     }
 
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -155,21 +156,21 @@
 {
     GtkWindow* dialog;
 
-    fp_gdk_threads_enter();
+    gtk->gdk_threads_enter();
 
     dialog = (GtkWindow*)jlong_to_ptr(
         (*env)->GetLongField(env, jpeer, widgetFieldID));
 
     if (dialog != NULL) {
         if (x >= 0 && y >= 0) {
-            fp_gtk_window_move(dialog, (gint)x, (gint)y);
+            gtk->gtk_window_move(dialog, (gint)x, (gint)y);
         }
         if (width > 0 && height > 0) {
-            fp_gtk_window_resize(dialog, (gint)width, (gint)height);
+            gtk->gtk_window_resize(dialog, (gint)width, (gint)height);
         }
     }
 
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -182,18 +183,18 @@
     gboolean isAllDirsSame = TRUE;
 
     while (it) {
-        gchar* dir = fp_g_path_get_dirname((gchar*) it->data);
+        gchar* dir = gtk->g_path_get_dirname((gchar*) it->data);
 
         if (prevDir && strcmp(prevDir, dir) != 0) {
             isAllDirsSame = FALSE;
-            fp_g_free(dir);
+            gtk->g_free(dir);
             break;
         }
 
         if (!prevDir) {
             prevDir = strdup(dir);
         }
-        fp_g_free(dir);
+        gtk->g_free(dir);
 
         it = it->next;
     }
@@ -233,7 +234,7 @@
         return NULL;
     }
 
-    array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls, NULL);
+    array = (*env)->NewObjectArray(env, gtk->gtk_g_slist_length(list), stringCls, NULL);
     if (array == NULL) {
         (*env)->ExceptionClear(env);
         JNU_ThrowInternalError(env, "Could not instantiate array files array");
@@ -287,7 +288,7 @@
     filenames = NULL;
 
     if (responseId == GTK_RESPONSE_ACCEPT) {
-        filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
+        filenames = gtk->gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
     }
 
     jfilenames = toFilenamesArray(env, filenames, &jcurrent_folder);
@@ -318,7 +319,7 @@
         JNU_CHECK_EXCEPTION(env);
     }
 
-    fp_gdk_threads_enter();
+    gtk->gdk_threads_enter();
 
     const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0);
     if (title == NULL) {
@@ -329,19 +330,19 @@
 
     if (mode == java_awt_FileDialog_SAVE) {
         /* Save action */
-        dialog = fp_gtk_file_chooser_dialog_new(title, NULL,
+        dialog = gtk->gtk_file_chooser_dialog_new(title, NULL,
                 GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
                 GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
     }
     else {
         /* Default action OPEN */
-        dialog = fp_gtk_file_chooser_dialog_new(title, NULL,
+        dialog = gtk->gtk_file_chooser_dialog_new(title, NULL,
                 GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL,
                 GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
 
         /* Set multiple selection mode, that is allowed only in OPEN action */
         if (multiple) {
-            fp_gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog),
+            gtk->gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog),
                     multiple);
         }
     }
@@ -358,7 +359,7 @@
             JNU_ThrowOutOfMemoryError(env, "Could not get dir");
             return;
         }
-        fp_gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir);
+        gtk->gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir);
         (*env)->ReleaseStringUTFChars(env, jdir, dir);
     }
 
@@ -371,47 +372,48 @@
             return;
         }
         if (mode == java_awt_FileDialog_SAVE) {
-            fp_gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
+            gtk->gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
         } else {
-            fp_gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename);
+            gtk->gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename);
         }
         (*env)->ReleaseStringUTFChars(env, jfile, filename);
     }
 
     /* Set the file filter */
     if (jfilter != NULL) {
-        filter = fp_gtk_file_filter_new();
-        fp_gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
+        filter = gtk->gtk_file_filter_new();
+        gtk->gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
                 filenameFilterCallback, jpeer, NULL);
-        fp_gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
+        gtk->gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
     }
 
     /* Other Properties */
-    if (fp_gtk_check_version(2, 8, 0) == NULL) {
-        fp_gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(
+    if (gtk->gtk_check_version(2, 8, 0) == NULL ||
+                                     gtk->gtk_check_version(3, 0, 0) == NULL) {
+        gtk->gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(
                 dialog), TRUE);
     }
 
     /* Set the initial location */
     if (x >= 0 && y >= 0) {
-        fp_gtk_window_move((GtkWindow*)dialog, (gint)x, (gint)y);
+        gtk->gtk_window_move((GtkWindow*)dialog, (gint)x, (gint)y);
 
         // NOTE: it doesn't set the initial size for the file chooser
         // as it seems like the file chooser overrides the size internally
     }
 
-    fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
-            handle_response), jpeer);
+    gtk->g_signal_connect_data(dialog, "response", G_CALLBACK(
+            handle_response), jpeer, 0, 0);
 
     (*env)->SetLongField(env, jpeer, widgetFieldID, ptr_to_jlong(dialog));
 
-    fp_gtk_widget_show(dialog);
+    gtk->gtk_widget_show(dialog);
 
-    XID xid = fp_gdk_x11_drawable_get_xid(dialog->window);
+    XID xid = gtk->gdk_x11_drawable_get_xid(gtk->get_window(dialog));
     if( (*env)->CallBooleanMethod(env, jpeer, setWindowMethodID, xid) ) {
-        fp_gtk_main();
+        gtk->gtk_main();
     }
 
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -24,9 +24,24 @@
  */
 
 #include <stdlib.h>
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
 #include "com_sun_java_swing_plaf_gtk_GTKEngine.h"
 
+/* Static buffer for conversion from java.lang.String to UTF-8 */
+static char conversionBuffer[CONV_BUFFER_SIZE];
+
+const char *getStrFor(JNIEnv *env, jstring val)
+{
+    int length = (*env)->GetStringLength(env, val);
+    if (length > CONV_BUFFER_SIZE-1)
+    {
+        length = CONV_BUFFER_SIZE-1;
+    }
+
+    (*env)->GetStringUTFRegion(env, val, 0, length, conversionBuffer);
+    return conversionBuffer;
+}
+
 /*
  * Class:     com_sun_java_swing_plaf_gtk_GTKEngine
  * Method:    native_paint_arrow
@@ -38,10 +53,10 @@
         jint widget_type, jint state, jint shadow_type, jstring detail,
         jint x, jint y, jint w, jint h, jint arrow_type)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_arrow(widget_type, state, shadow_type, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_arrow(widget_type, state, shadow_type, getStrFor(env, detail),
             x, y, w, h, arrow_type, TRUE);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -56,10 +71,10 @@
         jint x, jint y, jint w, jint h,
         jint synth_state, jint dir)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_box(widget_type, state, shadow_type, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_box(widget_type, state, shadow_type, getStrFor(env, detail),
                    x, y, w, h, synth_state, dir);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -74,10 +89,10 @@
         jint x, jint y, jint w, jint h,
         jint gap_side, jint gap_x, jint gap_w)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_box_gap(widget_type, state, shadow_type, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_box_gap(widget_type, state, shadow_type, getStrFor(env, detail),
             x, y, w, h, gap_side, gap_x, gap_w);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -91,10 +106,10 @@
         jint widget_type, jint synth_state, jstring detail,
         jint x, jint y, jint w, jint h)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_check(widget_type, synth_state, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_check(widget_type, synth_state, getStrFor(env, detail),
                      x, y, w, h);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -108,10 +123,10 @@
         jint widget_type, jint state, jstring detail,
         jint x, jint y, jint w, jint h, jint expander_style)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_expander(widget_type, state, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_expander(widget_type, state, getStrFor(env, detail),
             x, y, w, h, expander_style);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -125,10 +140,10 @@
         jint widget_type, jint state, jint shadow_type, jstring detail,
         jint x, jint y, jint w, jint h, jint placement)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_extension(widget_type, state, shadow_type,
+    gtk->gdk_threads_enter();
+    gtk->paint_extension(widget_type, state, shadow_type,
             getStrFor(env, detail), x, y, w, h, placement);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -142,10 +157,10 @@
         jint widget_type, jint state, jint shadow_type, jstring detail,
         jint x, jint y, jint w, jint h, jboolean has_focus)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_flat_box(widget_type, state, shadow_type,
+    gtk->gdk_threads_enter();
+    gtk->paint_flat_box(widget_type, state, shadow_type,
             getStrFor(env, detail), x, y, w, h, has_focus);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -159,10 +174,10 @@
         jint widget_type, jint state, jstring detail,
         jint x, jint y, jint w, jint h)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_focus(widget_type, state, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_focus(widget_type, state, getStrFor(env, detail),
             x, y, w, h);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -176,10 +191,10 @@
         jint widget_type, jint state, jint shadow_type, jstring detail,
         jint x, jint y, jint w, jint h, jint orientation)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_handle(widget_type, state, shadow_type, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_handle(widget_type, state, shadow_type, getStrFor(env, detail),
             x, y, w, h, orientation);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -193,10 +208,10 @@
         jint widget_type, jint state, jstring detail,
         jint x, jint y, jint w, jint h)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_hline(widget_type, state, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_hline(widget_type, state, getStrFor(env, detail),
             x, y, w, h);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -210,10 +225,10 @@
         jint widget_type, jint synth_state, jstring detail,
         jint x, jint y, jint w, jint h)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_option(widget_type, synth_state, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_option(widget_type, synth_state, getStrFor(env, detail),
                       x, y, w, h);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -228,10 +243,10 @@
         jint x, jint y, jint w, jint h,
         jint synth_state, jint dir)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_shadow(widget_type, state, shadow_type, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_shadow(widget_type, state, shadow_type, getStrFor(env, detail),
                       x, y, w, h, synth_state, dir);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -243,12 +258,12 @@
 Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1slider(
         JNIEnv *env, jobject this,
         jint widget_type, jint state, jint shadow_type, jstring detail,
-        jint x, jint y, jint w, jint h, jint orientation)
+        jint x, jint y, jint w, jint h, jint orientation, jboolean has_focus)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_slider(widget_type, state, shadow_type, getStrFor(env, detail),
-            x, y, w, h, orientation);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    gtk->paint_slider(widget_type, state, shadow_type, getStrFor(env, detail),
+            x, y, w, h, orientation, has_focus);
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -262,10 +277,10 @@
         jint widget_type, jint state, jstring detail,
         jint x, jint y, jint w, jint h)
 {
-    fp_gdk_threads_enter();
-    gtk2_paint_vline(widget_type, state, getStrFor(env, detail),
+    gtk->gdk_threads_enter();
+    gtk->paint_vline(widget_type, state, getStrFor(env, detail),
             x, y, w, h);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -278,9 +293,9 @@
         JNIEnv *env, jobject this, jint widget_type, jint state,
         jint x, jint y, jint w, jint h)
 {
-    fp_gdk_threads_enter();
-    gtk_paint_background(widget_type, state, x, y, w, h);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    gtk->paint_background(widget_type, state, x, y, w, h);
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -292,9 +307,9 @@
 Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting(
         JNIEnv *env, jobject this, jint w, jint h)
 {
-    fp_gdk_threads_enter();
-    gtk2_init_painting(env, w, h);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    gtk->init_painting(env, w, h);
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -308,9 +323,9 @@
 {
     jint transparency;
     gint *buffer = (gint*) (*env)->GetPrimitiveArrayCritical(env, dest, 0);
-    fp_gdk_threads_enter();
-    transparency = gtk2_copy_image(buffer, width, height);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    transparency = gtk->copy_image(buffer, width, height);
+    gtk->gdk_threads_leave();
     (*env)->ReleasePrimitiveArrayCritical(env, dest, buffer, 0);
     return transparency;
 }
@@ -324,7 +339,9 @@
         JNIEnv *env, jobject this)
 {
     // Note that flush_gtk_event_loop takes care of locks (7053002)
-    flush_gtk_event_loop();
+    gtk->gdk_threads_enter();
+    gtk->flush_event_loop();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -336,9 +353,9 @@
         JNIEnv *env, jobject this, jint property)
 {
     jobject obj;
-    fp_gdk_threads_enter();
-    obj = gtk2_get_setting(env, property);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    obj = gtk->get_setting(env, property);
+    gtk->gdk_threads_leave();
     return obj;
 }
 
@@ -352,7 +369,7 @@
         JNIEnv *env, jobject this, jint widget_type,
         jdouble value, jdouble min, jdouble max, jdouble visible)
 {
-    fp_gdk_threads_enter();
-    gtk2_set_range_value(widget_type, value, min, max, visible);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    gtk->set_range_value(widget_type, value, min, max, visible);
+    gtk->gdk_threads_leave();
 }
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKStyle.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKStyle.c	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -24,9 +24,12 @@
  */
 
 #include <stdlib.h>
-#include "gtk2_interface.h"
+#include <stdio.h>
+#include "gtk_interface.h"
 #include "com_sun_java_swing_plaf_gtk_GTKStyle.h"
 
+const char *getStrFor(JNIEnv *env, jstring val);
+
 /*
  * Class:     com_sun_java_swing_plaf_gtk_GTKStyle
  * Method:    nativeGetXThickness
@@ -37,9 +40,9 @@
     JNIEnv *env, jclass klass, jint widget_type)
 {
     jint ret;
-    fp_gdk_threads_enter();
-    ret = gtk2_get_xthickness(env, widget_type);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    ret = gtk->get_xthickness(env, widget_type);
+    gtk->gdk_threads_leave();
     return ret;
 }
 
@@ -53,9 +56,9 @@
     JNIEnv *env, jclass klass, jint widget_type)
 {
     jint ret;
-    fp_gdk_threads_enter();
-    ret = gtk2_get_ythickness(env, widget_type);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    ret = gtk->get_ythickness(env, widget_type);
+    gtk->gdk_threads_leave();
     return ret;
 }
 
@@ -70,9 +73,9 @@
     jint state_type, jint type_id)
 {
     jint ret;
-    fp_gdk_threads_enter();
-    ret = gtk2_get_color_for_state(env, widget_type, state_type, type_id);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    ret = gtk->get_color_for_state(env, widget_type, state_type, type_id);
+    gtk->gdk_threads_leave();
     return ret;
 }
 
@@ -86,9 +89,9 @@
     JNIEnv *env, jclass klass, jint widget_type, jstring key)
 {
     jobject ret;
-    fp_gdk_threads_enter();
-    ret = gtk2_get_class_value(env, widget_type, key);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    ret = gtk->get_class_value(env, widget_type, getStrFor(env, key));
+    gtk->gdk_threads_leave();
     return ret;
 }
 
@@ -102,8 +105,8 @@
     JNIEnv *env, jclass klass, jint widget_type)
 {
     jstring ret;
-    fp_gdk_threads_enter();
-    ret = gtk2_get_pango_font_name(env, widget_type);
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    ret = gtk->get_pango_font_name(env, widget_type);
+    gtk->gdk_threads_leave();
     return ret;
 }
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c	Mon Apr 25 09:25:26 2016 -0700
@@ -354,7 +354,6 @@
 
 static void     waitForEvents(JNIEnv *, jlong);
 static void     awt_pipe_init();
-static void     processOneEvent(XtInputMask iMask);
 static Boolean  performPoll(JNIEnv *, jlong);
 static void     wakeUp();
 static void     update_poll_timeout(int timeout_control);
@@ -614,7 +613,7 @@
 } /* get_poll_timeout() */
 
 /*
- * Waits for X/Xt events to appear on the pipe. Returns only when
+ * Waits for X events to appear on the pipe. Returns only when
  * it is likely (but not definite) that there are events waiting to
  * be processed.
  *
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Desktop.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Desktop.c	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -24,7 +24,7 @@
  */
 
 #include "jni_util.h"
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
 #include "gnome_interface.h"
 
 static gboolean gtk_has_been_loaded = FALSE;
@@ -36,14 +36,14 @@
  * Signature: ()Z
  */
 JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_init
-  (JNIEnv *env, jclass cls)
+  (JNIEnv *env, jclass cls, jint version, jboolean verbose)
 {
 
     if (gtk_has_been_loaded || gnome_has_been_loaded) {
         return JNI_TRUE;
     }
 
-    if (gtk2_load(env) && gtk2_show_uri_load(env)) {
+    if (gtk_load(env, version, verbose) && gtk->show_uri_load(env)) {
         gtk_has_been_loaded = TRUE;
         return JNI_TRUE;
     } else if (gnome_load()) {
@@ -74,9 +74,9 @@
     }
 
     if (gtk_has_been_loaded) {
-        fp_gdk_threads_enter();
-        success = fp_gtk_show_uri(NULL, url_c, GDK_CURRENT_TIME, NULL);
-        fp_gdk_threads_leave();
+        gtk->gdk_threads_enter();
+        success = gtk->gtk_show_uri(NULL, url_c, GDK_CURRENT_TIME, NULL);
+        gtk->gdk_threads_leave();
     } else if (gnome_has_been_loaded) {
         success = (*gnome_url_show)(url_c, NULL);
     }
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c	Mon Apr 25 09:25:26 2016 -0700
@@ -109,7 +109,7 @@
  * Signature: (Ljava/lang/String;)Z
  */
 JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XTaskbarPeer_init
-(JNIEnv *env, jclass cls, jstring jname) {
+(JNIEnv *env, jclass cls, jstring jname, jint version, jboolean verbose) {
     jclass clazz;
 
     jTaskbarCls = (*env)->NewGlobalRef(env, cls);
@@ -121,7 +121,7 @@
     CHECK_NULL_RETURN(
             jMenuItemGetLabel = (*env)->GetMethodID(env, clazz, "getLabel", "()Ljava/lang/String;"), JNI_FALSE);
 
-    if (gtk2_load(env) && unity_load()) {
+    if (gtk_load(env, version, verbose) && unity_load()) {
         const gchar* name = (*env)->GetStringUTFChars(env, jname, NULL);
         if (name) {
             entry = fp_unity_launcher_entry_get_for_desktop_file(name);
@@ -139,9 +139,9 @@
  */
 JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_runloop
 (JNIEnv *env, jclass cls) {
-    fp_gdk_threads_enter();
-    fp_gtk_main();
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_enter();
+    gtk->gtk_main();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -151,14 +151,14 @@
  */
 JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setBadge
 (JNIEnv *env, jobject obj, jlong value, jboolean visible) {
-    fp_gdk_threads_enter();
+    gtk->gdk_threads_enter();
     fp_unity_launcher_entry_set_count(entry, value);
     fp_unity_launcher_entry_set_count_visible(entry, visible);
     DbusmenuMenuitem* m;
     if (m = fp_unity_launcher_entry_get_quicklist(entry)) {
         fp_unity_launcher_entry_set_quicklist(entry, m);
     }
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -168,13 +168,13 @@
  */
 JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setUrgent
 (JNIEnv *env, jobject obj, jboolean urgent) {
-    fp_gdk_threads_enter();
+    gtk->gdk_threads_enter();
     fp_unity_launcher_entry_set_urgent(entry, urgent);
     DbusmenuMenuitem* m;
     if (m = fp_unity_launcher_entry_get_quicklist(entry)) {
         fp_unity_launcher_entry_set_quicklist(entry, m);
     }
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 /*
@@ -184,14 +184,14 @@
  */
 JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_updateProgress
 (JNIEnv *env, jobject obj, jdouble value, jboolean visible) {
-    fp_gdk_threads_enter();
+    gtk->gdk_threads_enter();
     fp_unity_launcher_entry_set_progress(entry, value);
     fp_unity_launcher_entry_set_progress_visible(entry, visible);
     DbusmenuMenuitem* m;
     if (m = fp_unity_launcher_entry_get_quicklist(entry)) {
         fp_unity_launcher_entry_set_quicklist(entry, m);
     }
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
 
 void deleteGlobalRef(gpointer data) {
@@ -209,7 +209,7 @@
         }
         elem = (*env)->NewGlobalRef(env, elem);
 
-        globalRefs = fp_g_list_append(globalRefs, elem);
+        globalRefs = gtk->g_list_append(globalRefs, elem);
 
         jstring jlabel = (jstring) (*env)->CallObjectMethod(env, elem, jMenuItemGetLabel);
         if (!(*env)->ExceptionCheck(env) && jlabel) {
@@ -224,7 +224,8 @@
 
                 (*env)->ReleaseStringUTFChars(env, jlabel, label);
                 fp_dbusmenu_menuitem_child_append(menu, mi);
-                fp_g_signal_connect(mi, "item_activated", G_CALLBACK(callback), elem);
+                gtk->g_signal_connect_data(mi, "item_activated",
+                                           G_CALLBACK(callback), elem, NULL, 0);
             }
         }
     }
@@ -238,7 +239,7 @@
 JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setNativeMenu
 (JNIEnv *env, jobject obj, jobjectArray items) {
 
-    fp_gdk_threads_enter();
+    gtk->gdk_threads_enter();
 
     if (!menu) {
         menu = fp_dbusmenu_menuitem_new();
@@ -247,14 +248,14 @@
     fp_unity_launcher_entry_set_quicklist(entry, menu);
 
     GList* list = fp_dbusmenu_menuitem_take_children(menu);
-    fp_g_list_free_full(list, fp_g_object_unref);
+    gtk->g_list_free_full(list, gtk->g_object_unref);
 
-    fp_g_list_free_full(globalRefs, deleteGlobalRef);
+    gtk->g_list_free_full(globalRefs, deleteGlobalRef);
     globalRefs = NULL;
 
     if (items) {
         fill_menu(env, items);
     }
 
-    fp_gdk_threads_leave();
+    gtk->gdk_threads_leave();
 }
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h	Mon Apr 25 09:25:26 2016 -0700
@@ -26,7 +26,7 @@
 #ifndef AWT_TASKBAR_H
 #define AWT_TASKBAR_H
 
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
 
 typedef void UnityLauncherEntry;
 typedef void DbusmenuMenuitem;
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/gnome_interface.h	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/gnome_interface.h	Mon Apr 25 09:25:26 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
@@ -25,7 +25,7 @@
 
 #ifndef _GNOME_INTERFACE_H
 #define _GNOME_INTERFACE_H
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
 #include <dlfcn.h>
 #include <jvm_md.h>
 #include <jni.h>
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -28,7 +28,6 @@
 import java.awt.peer.*;
 import java.awt.image.VolatileImage;
 import sun.awt.RepaintArea;
-import sun.awt.CausedFocusEvent;
 import sun.awt.image.SunVolatileImage;
 import sun.awt.image.ToolkitImage;
 import java.awt.image.BufferedImage;
@@ -321,7 +320,7 @@
                   WKeyboardFocusManagerPeer.shouldFocusOnClick((Component)target))
               {
                   WKeyboardFocusManagerPeer.requestFocusFor((Component)target,
-                                                            CausedFocusEvent.Cause.MOUSE_EVENT);
+                                                            FocusEvent.Cause.MOUSE_EVENT);
               }
               break;
         }
@@ -687,7 +686,7 @@
     @Override
     public boolean requestFocus(Component lightweightChild, boolean temporary,
                                 boolean focusedWindowChangeAllowed, long time,
-                                CausedFocusEvent.Cause cause)
+                                FocusEvent.Cause cause)
     {
         if (WKeyboardFocusManagerPeer.
             processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -25,6 +25,7 @@
 package sun.awt.windows;
 
 import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
 import java.awt.dnd.DropTarget;
 import java.awt.peer.*;
 import java.io.File;
@@ -34,7 +35,6 @@
 import java.util.ResourceBundle;
 import java.util.MissingResourceException;
 import java.util.Vector;
-import sun.awt.CausedFocusEvent;
 import sun.awt.AWTAccessor;
 
 final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
@@ -282,7 +282,7 @@
     @Override
     public boolean requestFocus
          (Component lightweightChild, boolean temporary,
-          boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
+          boolean focusedWindowChangeAllowed, long time, Cause cause)
     {
         return false;
     }
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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,7 +32,7 @@
 import sun.awt.AWTAccessor;
 import sun.awt.AWTAccessor.ComponentAccessor;
 import sun.awt.KeyboardFocusManagerPeerImpl;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent.Cause;
 
 final class WKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
     static native void setNativeFocusOwner(ComponentPeer peer);
@@ -75,7 +75,7 @@
                                        boolean temporary,
                                        boolean focusedWindowChangeAllowed,
                                        long time,
-                                       CausedFocusEvent.Cause cause)
+                                       Cause cause)
     {
         // TODO: do something to eliminate this forwarding
         return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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,11 +26,11 @@
 package sun.awt.windows;
 
 import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
 import java.awt.peer.DialogPeer;
 import java.awt.peer.ComponentPeer;
 import java.awt.dnd.DropTarget;
 import java.util.Vector;
-import sun.awt.CausedFocusEvent;
 import sun.awt.AWTAccessor;
 
 class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
@@ -153,7 +153,7 @@
     @Override
     public boolean requestFocus
          (Component lightweightChild, boolean temporary,
-          boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
+          boolean focusedWindowChangeAllowed, long time, Cause cause)
     {
 
         return false;
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -300,11 +300,11 @@
         return getNativeWindowSize();
     }
 
-    public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
+    public boolean requestWindowFocus(FocusEvent.Cause cause) {
         if (!focusAllowedFor()) {
             return false;
         }
-        return requestWindowFocus(cause == CausedFocusEvent.Cause.MOUSE_EVENT);
+        return requestWindowFocus(cause == FocusEvent.Cause.MOUSE_EVENT);
     }
     private native boolean requestWindowFocus(boolean isMouseEventCause);
 
--- a/jdk/src/java.desktop/windows/native/libfontmanager/lcdglyph.c	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/src/java.desktop/windows/native/libfontmanager/lcdglyph.c	Mon Apr 25 09:25:26 2016 -0700
@@ -157,6 +157,9 @@
     if (hBitmap != 0) { \
         DeleteObject(hBitmap); \
     } \
+    if (tmpBitmap != 0) { \
+        DeleteObject(tmpBitmap); \
+    } \
     if (dibImage != NULL) { \
         free(dibImage); \
     } \
@@ -196,6 +199,7 @@
     int bmWidth, bmHeight;
     int x, y;
     HBITMAP hBitmap = NULL, hOrigBM;
+    HBITMAP tmpBitmap = NULL;
     int gamma, orient;
 
     HWND hWnd = NULL;
@@ -250,6 +254,12 @@
     }
     oldFont = SelectObject(hMemoryDC, hFont);
 
+    tmpBitmap = CreateCompatibleBitmap(hDesktopDC, 1, 1);
+    if (tmpBitmap == NULL) {
+        FREE_AND_RETURN;
+    }
+    hOrigBM = (HBITMAP)SelectObject(hMemoryDC, tmpBitmap);
+
     memset(&textMetric, 0, sizeof(TEXTMETRIC));
     err = GetTextMetrics(hMemoryDC, &textMetric);
     if (err == 0) {
@@ -334,7 +344,7 @@
     if (hBitmap == NULL) {
         FREE_AND_RETURN;
     }
-    hOrigBM = (HBITMAP)SelectObject(hMemoryDC, hBitmap);
+    SelectObject(hMemoryDC, hBitmap);
 
     /* Fill in black */
     rect.left = 0;
@@ -478,6 +488,7 @@
     ReleaseDC(hWnd, hDesktopDC);
     DeleteObject(hMemoryDC);
     DeleteObject(hBitmap);
+    DeleteObject(tmpBitmap);
 
     return ptr_to_jlong(glyphInfo);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/Cause/FocusCauseTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,224 @@
+/*
+ * 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 8080395
+  @summary consider making sun.awt.CausedFocusEvent functionality public
+  @run main FocusCauseTest
+*/
+
+
+import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.lang.IllegalArgumentException;
+import java.lang.Override;
+import java.lang.RuntimeException;
+import java.util.Arrays;
+
+public class FocusCauseTest {
+
+    private static Cause[] causes1 = {Cause.ACTIVATION,
+            Cause.UNKNOWN, Cause.UNKNOWN, Cause.TRAVERSAL_FORWARD,
+            Cause.TRAVERSAL_FORWARD, Cause.TRAVERSAL_BACKWARD,
+            Cause.TRAVERSAL_BACKWARD, Cause.TRAVERSAL_UP,
+            Cause.TRAVERSAL_DOWN, Cause.CLEAR_GLOBAL_FOCUS_OWNER};
+    private static Cause[] causes2 = new Cause[10];
+    private static int cnt;
+
+    static byte[] data =
+            {-84, -19, 0, 5, 115, 114, 0, 24, 115, 117, 110, 46, 97, 119,
+            116, 46, 67, 97, 117, 115, 101, 100, 70, 111, 99, 117, 115, 69, 118,
+            101, 110, 116, -51, 98, 39, -75, 86, 52, 107, 30, 2, 0, 1, 76, 0, 5,
+            99, 97, 117, 115, 101, 116, 0, 32, 76, 115, 117, 110, 47, 97, 119,
+            116, 47, 67, 97, 117, 115, 101, 100, 70, 111, 99, 117, 115, 69, 118,
+            101, 110, 116, 36, 67, 97, 117, 115, 101, 59, 120, 114, 0, 25, 106,
+            97, 118, 97, 46, 97, 119, 116, 46, 101, 118, 101, 110, 116, 46, 70,
+            111, 99, 117, 115, 69, 118, 101, 110, 116, 7, 68, -65, 75, 55, -113,
+            98, -52, 2, 0, 1, 90, 0, 9, 116, 101, 109, 112, 111, 114, 97, 114,
+            121, 120, 114, 0, 29, 106, 97, 118, 97, 46, 97, 119, 116, 46, 101,
+            118, 101, 110, 116, 46, 67, 111, 109, 112, 111, 110, 101, 110, 116,
+            69, 118, 101, 110, 116, 112, 109, -6, -107, 79, -87, -38, 69, 2, 0,
+            0, 120, 114, 0, 17, 106, 97, 118, 97, 46, 97, 119, 116, 46, 65, 87,
+            84, 69, 118, 101, 110, 116, -26, -85, 45, -31, 24, -33, -118, -61,
+            2, 0, 3, 90, 0, 8, 99, 111, 110, 115, 117, 109, 101, 100, 73, 0, 2,
+            105, 100, 91, 0, 5, 98, 100, 97, 116, 97, 116, 0, 2, 91, 66, 120,
+            114, 0, 21, 106, 97, 118, 97, 46, 117, 116, 105, 108, 46, 69, 118,
+            101, 110, 116, 79, 98, 106, 101, 99, 116, 76, -115, 9, 78, 24, 109,
+            125, -88, 2, 0, 0, 120, 112, 0, 0, 0, 3, -20, 112, 0, 126, 114, 0,
+            30, 115, 117, 110, 46, 97, 119, 116, 46, 67, 97, 117, 115, 101, 100,
+            70, 111, 99, 117, 115, 69, 118, 101, 110, 116, 36, 67, 97, 117, 115,
+            101, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 120, 114, 0, 14, 106, 97,
+            118, 97, 46, 108, 97, 110, 103, 46, 69, 110, 117, 109, 0, 0, 0, 0,
+            0, 0, 0, 0, 18, 0, 0, 120, 112, 116, 0};
+
+    static byte[] dataOld =
+            {-84, -19, 0, 5, 115, 114, 0, 25, 106, 97, 118, 97, 46, 97, 119,
+            116, 46, 101, 118, 101, 110, 116, 46, 70, 111, 99, 117, 115, 69,
+            118, 101, 110, 116, 7, 68, -65, 75, 55, -113, 98, -52, 2, 0, 1, 90,
+            0, 9, 116, 101, 109, 112, 111, 114, 97, 114, 121, 120, 114, 0, 29,
+            106, 97, 118, 97, 46, 97, 119, 116, 46, 101, 118, 101, 110, 116, 46,
+            67, 111, 109, 112, 111, 110, 101, 110, 116, 69, 118, 101, 110, 116,
+            112, 109, -6, -107, 79, -87, -38, 69, 2, 0, 0, 120, 114, 0, 17, 106,
+            97, 118, 97, 46, 97, 119, 116, 46, 65, 87, 84, 69, 118, 101, 110,
+            116, -26, -85, 45, -31, 24, -33, -118, -61, 2, 0, 3, 90, 0, 8, 99,
+            111, 110, 115, 117, 109, 101, 100, 73, 0, 2, 105, 100, 91, 0, 5, 98,
+            100, 97, 116, 97, 116, 0, 2, 91, 66, 120, 114, 0, 21, 106, 97, 118,
+            97, 46, 117, 116, 105, 108, 46, 69, 118, 101, 110, 116, 79, 98, 106,
+            101, 99, 116, 76, -115, 9, 78, 24, 109, 125, -88, 2, 0, 0, 120, 112,
+            0, 0, 0, 0, 100, 112, 0};
+
+    static String[] causesIn = {"UNKNOWN", "MOUSE_EVENT", "TRAVERSAL",
+            "TRAVERSAL_UP", "TRAVERSAL_DOWN", "TRAVERSAL_FORWARD",
+            "TRAVERSAL_BACKWARD", "MANUAL_REQUEST", "AUTOMATIC_TRAVERSE"
+            ,"ROLLBACK", "NATIVE_SYSTEM", "ACTIVATION",
+            "CLEAR_GLOBAL_FOCUS_OWNER", "RETARGETED"};
+
+    static FocusEvent.Cause[] causesOut = {FocusEvent.Cause.UNKNOWN,
+            FocusEvent.Cause.MOUSE_EVENT,
+            FocusEvent.Cause.TRAVERSAL, FocusEvent.Cause.TRAVERSAL_UP,
+            FocusEvent.Cause.TRAVERSAL_DOWN, FocusEvent.Cause.TRAVERSAL_FORWARD,
+            FocusEvent.Cause.TRAVERSAL_BACKWARD, FocusEvent.Cause.UNKNOWN,
+            FocusEvent.Cause.UNKNOWN, FocusEvent.Cause.ROLLBACK,
+            FocusEvent.Cause.UNEXPECTED, FocusEvent.Cause.ACTIVATION,
+            FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER, FocusEvent.Cause.UNKNOWN
+    };
+
+    public static void main(String[] args) throws Exception {
+        testCauses();
+        testNullCause();
+        testCausedFocusEventDeserialization();
+        testFocusEventDeserialization();
+        System.out.println("ok");
+    }
+
+    private static void testNullCause() {
+        try {
+            new FocusEvent(new Frame(), FocusEvent.FOCUS_GAINED, true,
+                    null, null);
+            throw new RuntimeException("Exception is not thrown when the " +
+                    "cause is null");
+        } catch (IllegalArgumentException e) {
+        }
+    }
+
+    private static void testCauses() throws Exception {
+        cnt = 0;
+        Frame frame = new Frame();
+        TextField comp1 = new TextField();
+        comp1.addFocusListener(new FocusListener() {
+            @Override
+            public void focusGained(FocusEvent e) {
+                System.out.println(e.getCause());
+                causes2[cnt++] = e.getCause();
+            }
+
+            @Override
+            public void focusLost(FocusEvent e) {
+                System.out.println(e.getCause());
+                causes2[cnt++] = e.getCause();
+            }
+        });
+        TextField comp2 = new TextField();
+        comp2.addFocusListener(new FocusListener() {
+            @Override
+            public void focusGained(FocusEvent e) {
+                System.out.println(e.getCause());
+                causes2[cnt++] = e.getCause();
+            }
+
+            @Override
+            public void focusLost(FocusEvent e) {
+                System.out.println(e.getCause());
+                causes2[cnt++] = e.getCause();
+            }
+        });
+        frame.add(comp1, BorderLayout.NORTH);
+        frame.add(comp2, BorderLayout.SOUTH);
+        frame.setVisible(true);
+
+        Robot robot = new Robot();
+        robot.delay(200);
+        robot.waitForIdle();
+        comp2.requestFocus();
+        robot.waitForIdle();
+        comp2.transferFocus();
+        robot.waitForIdle();
+        comp1.transferFocusBackward();
+        robot.waitForIdle();
+        comp2.transferFocusUpCycle();
+        robot.waitForIdle();
+        frame.transferFocusDownCycle();
+        robot.waitForIdle();
+        frame.dispose();
+        robot.waitForIdle();
+        if (!Arrays.equals(causes1, causes2)) {
+            throw new RuntimeException("wrong cause " + causes2);
+        }
+    }
+
+    private static void  testCausedFocusEventDeserialization() throws
+            Exception {
+        for (int i = 0; i < causesIn.length; i++) {
+            final String causeIn = causesIn[i];
+            ObjectInputStream oi = new ObjectInputStream(new InputStream() {
+                int cnt = 0;
+                @Override
+                public int read() throws IOException {
+                    if(cnt < data.length) {
+                        return data[cnt++];
+                    } else if(cnt == data.length){
+                        cnt++;
+                        return causeIn.length();
+                    } else if(cnt - data.length - 1 < causeIn.length()) {
+                        return causeIn.getBytes()[cnt++ - data.length - 1];
+                    }
+                    return -1;
+                }
+            });
+            FocusEvent ev = (FocusEvent) oi.readObject();
+            System.out.println(ev);
+            if(ev.getCause() != causesOut[i]) {
+                throw new RuntimeException("Wrong cause read :" +ev.getCause());
+            }
+        }
+    }
+
+    private static void testFocusEventDeserialization() throws
+            Exception {
+        ObjectInputStream oi = new ObjectInputStream(
+                new ByteArrayInputStream(dataOld));
+        FocusEvent ev = (FocusEvent)oi.readObject();
+        if(ev.getCause() != FocusEvent.Cause.UNKNOWN) {
+            throw new RuntimeException("Wrong cause in deserialized FocusEvent "
+                    + ev.getCause());
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/PrintJob/NullFrameTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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 8154057
+ * @summary  getPrintJob doesn't throw NPE if frame is null
+ * @run main NullFrameTest
+ */
+import java.awt.JobAttributes;
+import java.awt.Toolkit;
+
+public class NullFrameTest {
+    public static void main(String[] args) {
+        JobAttributes ja = new JobAttributes();
+        ja.setDialog(JobAttributes.DialogType.COMMON);
+        boolean npeThrown = false;
+        try {
+            Toolkit.getDefaultToolkit().getPrintJob(null,
+                                               "test Printing", ja, null);
+        } catch (NullPointerException ex) {
+            npeThrown = true;
+        }
+        if (!npeThrown) {
+            throw
+            new RuntimeException("getPrintJob didn't throw NPE for null Frame");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TrayIcon/UpdatePopupMenu/UpdatePopupMenu.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,233 @@
+/*
+ * 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 8147841
+ @summary Updating Tray Icon popup menu does not update menu items on Mac OS X
+ @run main/manual UpdatePopupMenu
+ */
+
+import java.awt.SystemTray;
+import java.awt.TrayIcon;
+import java.awt.PopupMenu;
+import java.awt.MenuItem;
+import java.awt.Image;
+import java.awt.Graphics2D;
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.awt.RenderingHints;
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class UpdatePopupMenu implements ActionListener {
+
+    private static final int imageSize = 32;
+    private static final int imageInset = 4;
+    private static GridBagLayout layout;
+    private static Panel mainControlPanel;
+    private static Panel resultButtonPanel;
+    private static TextArea instructionTextArea;
+    private static Button passButton;
+    private static Button failButton;
+    private static Frame mainFrame;
+    private static Thread mainThread = null;
+    private static boolean testPassed = false;
+    private static boolean isInterrupted = false;
+    private static final int testTimeOut = 300000;
+
+    private Image createSystemTrayIconImage() {
+        final BufferedImage trayImage = new BufferedImage(
+                imageSize,
+                imageSize,
+                BufferedImage.TYPE_INT_ARGB);
+
+        final Graphics2D imageGraphics = (Graphics2D) trayImage.getGraphics();
+
+        imageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                RenderingHints.VALUE_ANTIALIAS_ON);
+
+        imageGraphics.setColor(new Color(255, 255, 255, 0));
+        imageGraphics.fillRect(0, 0, trayImage.getWidth(),
+                trayImage.getHeight());
+
+        imageGraphics.setColor(Color.green);
+
+        int imageWidth = trayImage.getWidth() - 2 * imageInset;
+        int imageHeight = trayImage.getHeight() - 2 * imageInset;
+
+        imageGraphics.fillOval(imageInset, imageInset, imageWidth, imageHeight);
+        imageGraphics.setColor(Color.darkGray);
+        imageGraphics.drawOval(imageInset, imageInset, imageWidth, imageHeight);
+
+        return trayImage;
+    }
+
+    private PopupMenu createPopupMenu(final TrayIcon trayIcon,
+            final int menuCount) {
+
+        final PopupMenu trayIconPopupMenu = new PopupMenu();
+
+        for (int i = 1; i <= menuCount; ++i) {
+            final MenuItem popupMenuItem = new MenuItem("MenuItem_" + i);
+
+            popupMenuItem.addActionListener(new ActionListener() {
+                @Override
+                public void actionPerformed(final ActionEvent ae) {
+                    trayIcon.setPopupMenu(createPopupMenu(trayIcon,
+                            menuCount + 1));
+                }
+            });
+
+            trayIconPopupMenu.add(popupMenuItem);
+        }
+
+        return trayIconPopupMenu;
+    }
+
+    private void createSystemTrayIcons() {
+
+        final TrayIcon trayIcon = new TrayIcon(createSystemTrayIconImage());
+        trayIcon.setImageAutoSize(true);
+        trayIcon.setToolTip("Update Popup Menu items");
+
+        try {
+            trayIcon.setPopupMenu(createPopupMenu(trayIcon, 2));
+            SystemTray.getSystemTray().add(trayIcon);
+
+        } catch (AWTException ex) {
+            throw new RuntimeException("System Tray cration failed");
+        }
+    }
+
+    private void createInstructionUI() {
+        mainFrame = new Frame("Updating TrayIcon Popup Menu Item Test");
+        layout = new GridBagLayout();
+        mainControlPanel = new Panel(layout);
+        resultButtonPanel = new Panel(layout);
+
+        GridBagConstraints gbc = new GridBagConstraints();
+        String instructions
+                = "INSTRUCTIONS:"
+                + "\n   1. Click on the System Tray Icon"
+                + "\n   2. Click on any of the displayed Menu items"
+                + "\n   3. Repeat step 1 and count the number of items in the "
+                + "Menu"
+                + "\n   4. The number of items in the Menu should increase by 1"
+                + "\n   5. Repeating steps 1, 2 and 3 should not break 4th step"
+                + "\n   6. Click Fail if the 4th step is broken, Otherwise "
+                + "click Pass ";
+
+        instructionTextArea = new TextArea();
+        instructionTextArea.setText(instructions);
+        instructionTextArea.setEnabled(false);
+        instructionTextArea.setBackground(Color.white);
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(instructionTextArea, gbc);
+
+        passButton = new Button("Pass");
+        passButton.setName("Pass");
+        passButton.addActionListener(this);
+
+        failButton = new Button("Fail");
+        failButton.setName("Fail");
+        failButton.addActionListener(this);
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        resultButtonPanel.add(passButton, gbc);
+        gbc.gridx = 1;
+        gbc.gridy = 0;
+        resultButtonPanel.add(failButton, gbc);
+        gbc.gridx = 0;
+        gbc.gridy = 1;
+        mainControlPanel.add(resultButtonPanel, gbc);
+
+        mainFrame.add(mainControlPanel);
+        mainFrame.pack();
+        mainFrame.setVisible(true);
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent ae) {
+        if (ae.getSource() instanceof Button) {
+            Button btn = (Button) ae.getSource();
+            switch (btn.getName()) {
+                case "Pass":
+                    testPassed = true;
+                    isInterrupted = true;
+                    mainThread.interrupt();
+                    break;
+
+                case "Fail":
+                    testPassed = false;
+                    isInterrupted = true;
+                    mainThread.interrupt();
+                    break;
+            }
+        }
+    }
+
+    private static void cleanUp() {
+        mainFrame.dispose();
+    }
+
+    public static void main(final String[] args) throws Exception {
+        if (SystemTray.isSupported()) {
+
+            UpdatePopupMenu updatePopupMenu = new UpdatePopupMenu();
+            updatePopupMenu.createInstructionUI();
+            updatePopupMenu.createSystemTrayIcons();
+
+            mainThread = Thread.currentThread();
+            try {
+                mainThread.sleep(testTimeOut);
+            } catch (InterruptedException ex) {
+                if (!testPassed) {
+                    throw new RuntimeException("Updating TrayIcon popup menu"
+                            + " items FAILED");
+                }
+            } finally {
+                cleanUp();
+            }
+
+            if (!isInterrupted) {
+                throw new RuntimeException("Test Timed out after "
+                        + testTimeOut / 1000 + " seconds");
+            }
+
+        } else {
+            System.out.println("System Tray is not supported on this platform");
+        }
+    }
+}
--- a/jdk/test/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/test/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java	Mon Apr 25 09:25:26 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
@@ -56,17 +56,24 @@
             }
         });
 
-        Util.waitForIdle(null);
+        Robot testRobot = null;
         try {
-            Point loc = textArea.getLocationOnScreen();
-            Util.drag(new Robot(),
-                    new Point((int) loc.x + 3, (int) loc.y + 3),
-                    new Point((int) loc.x + 40, (int) loc.y + 40),
-                    InputEvent.BUTTON1_MASK);
-        } catch (AWTException ex) {
-            throw new RuntimeException("Could not initiate a drag operation");
+            testRobot = new Robot();
+        } catch(AWTException ex) {
+            throw new RuntimeException("Error while creating Robot");
         }
-        Util.waitForIdle(null);
+
+        Util.waitForIdle(testRobot);
+
+        Point loc = textArea.getLocationOnScreen();
+        Util.drag(testRobot,
+                new Point((int) loc.x + 3, (int) loc.y + 3),
+                new Point((int) loc.x + 40, (int) loc.y + 40),
+                InputEvent.BUTTON1_MASK);
+
+        Util.waitForIdle(testRobot);
+
+        testRobot.delay(200);
     }
 
     private static void constructTestUI() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/DummyPrintTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,247 @@
+/*
+ * 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      6921664
+ * @summary  Verifies number of copies and the job name are passed to a
+ *           3rd party PrintService.
+ * @run      main DummyPrintTest
+ */
+import java.awt.Graphics;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import java.util.HashSet;
+import java.util.Set;
+import javax.print.Doc;
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.ServiceUIFactory;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.HashPrintJobAttributeSet;
+import javax.print.attribute.HashPrintServiceAttributeSet;
+import javax.print.attribute.PrintJobAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.PrintServiceAttribute;
+import javax.print.attribute.PrintServiceAttributeSet;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.PrinterName;
+import javax.print.attribute.standard.PrinterState;
+import javax.print.event.PrintJobAttributeListener;
+import javax.print.event.PrintJobListener;
+import javax.print.event.PrintServiceAttributeListener;
+
+
+public class DummyPrintTest {
+
+    public static void main(String[] args) throws Exception {
+        // register custom print service implementation
+        String printerName = "myDummyPrintService";
+        PrintServiceLookup.registerService(new DummyPrintService(printerName));
+        // calling third party print logic
+        thirdPartyPrintLogic(printerName);
+    }
+
+    static void thirdPartyPrintLogic(String printerName) throws Exception {
+        PrinterJob printerjob = PrinterJob.getPrinterJob();
+        printerjob.setCopies(2);
+        printerjob.setJobName("myJobName");
+        printerjob.setPrintable(new DummyPrintable());
+        for (PrintService printService : PrinterJob.lookupPrintServices()) {
+            System.out.println("check printer name of service " + printService);
+            if (printerName.equals(printService.getName())) {
+                System.out.println("correct printer service do print...");
+                printerjob.setPrintService(printService);
+                printerjob.print();
+                break;
+            }
+        }
+    }
+}
+
+class DummyPrintService implements PrintService {
+    private final String _name;
+    private final Set<DocFlavor> _supportedFlavors;
+    private final PrintServiceAttributeSet _printServiceAttributeSet;
+
+    public DummyPrintService(String name) {
+        _name = name;
+        _supportedFlavors = new HashSet<DocFlavor>();
+        _supportedFlavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
+        _supportedFlavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
+        _printServiceAttributeSet = new HashPrintServiceAttributeSet();
+        _printServiceAttributeSet.add(new PrinterName(name, null));
+        _printServiceAttributeSet.add(PrinterState.IDLE);
+    }
+
+    @Override
+    public String toString() {
+        return "Dummy Printer : " + getName();
+    }
+
+    @Override
+    public String getName() {
+        return _name;
+    }
+
+    @Override
+    public DocPrintJob createPrintJob() {
+        return new DummyDocPrintJob(this);
+    }
+
+    @Override
+    public boolean isDocFlavorSupported(DocFlavor flavor) {
+        return _supportedFlavors.contains(flavor);
+    }
+
+    @Override
+    public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) {
+        return category.cast(_printServiceAttributeSet.get(category));
+    }
+
+    @Override
+    public PrintServiceAttributeSet getAttributes() {
+        return _printServiceAttributeSet;
+    }
+
+    @Override
+    public DocFlavor[] getSupportedDocFlavors() {
+        return _supportedFlavors.toArray(new DocFlavor[_supportedFlavors.size()]);
+    }
+
+    @Override
+    public Object getDefaultAttributeValue(Class<? extends Attribute> category) {
+        return null;
+    }
+
+    @Override
+    public ServiceUIFactory getServiceUIFactory() {
+        return null;
+    }
+
+    @Override
+    public Class<?>[] getSupportedAttributeCategories() {
+        return null;
+    }
+
+    @Override
+    public Object getSupportedAttributeValues(Class<? extends Attribute> category,
+                                    DocFlavor flavor, AttributeSet attributes) {
+        return null;
+    }
+
+    @Override
+    public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
+                                                 AttributeSet attributes) {
+        return null;
+    }
+
+    @Override
+    public boolean isAttributeCategorySupported(Class<? extends Attribute> category) {
+        return false;
+    }
+
+    @Override
+    public boolean isAttributeValueSupported(Attribute attrval,
+                                             DocFlavor flavor,
+                                             AttributeSet attributes) {
+        return false;
+    }
+
+    @Override
+    public void addPrintServiceAttributeListener(PrintServiceAttributeListener listener) {
+    }
+
+    @Override
+    public void removePrintServiceAttributeListener(PrintServiceAttributeListener listener) {
+    }
+}
+
+class DummyDocPrintJob implements DocPrintJob {
+    private static int _counter;
+    private final PrintService _printService;
+    private final PrintJobAttributeSet _printJobAttributeSet;
+
+    public DummyDocPrintJob(PrintService printService) {
+        _counter++;
+        _printService = printService;
+        _printJobAttributeSet = new HashPrintJobAttributeSet();
+    }
+
+    @Override
+    public PrintService getPrintService() {
+        return _printService;
+    }
+
+    @Override
+    public PrintJobAttributeSet getAttributes() {
+        return _printJobAttributeSet;
+    }
+
+    @Override
+    public void addPrintJobAttributeListener(PrintJobAttributeListener listener,
+                                    PrintJobAttributeSet printJobAttributeSet) {
+    }
+
+    @Override
+    public void removePrintJobAttributeListener(PrintJobAttributeListener listener) {
+    }
+
+    @Override
+    public void addPrintJobListener(PrintJobListener listener) {
+    }
+
+    @Override
+    public void removePrintJobListener(PrintJobListener listener) {
+    }
+
+    @Override
+    public void print(Doc doc,
+                      PrintRequestAttributeSet printRequestAttributeSet)
+          throws PrintException {
+        System.out.println("job name: " + printRequestAttributeSet.get(JobName.class));
+        System.out.println("copies: " + printRequestAttributeSet.get(Copies.class));
+        if(printRequestAttributeSet.get(JobName.class) == null ||
+            printRequestAttributeSet.get(Copies.class) == null) {
+            throw new RuntimeException("Copies and JobName is not passed correctly");
+        }
+    }
+}
+
+class DummyPrintable implements Printable {
+    @Override
+    public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
+            throws PrinterException {
+        if (pageIndex == 0) {
+            return Printable.PAGE_EXISTS;
+        } else {
+            return Printable.NO_SUCH_PAGE;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/GetUserNameTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,49 @@
+/*
+ * 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 6197099
+ * @summary Verifies PrinterJob's getUserName() throws a security exception when
+ *          username permission is not given
+ * @run main/othervm/java.security.policy=GetUserNameTest.policy GetUserNameTest
+ */
+import java.awt.print.PrinterJob;
+
+public class GetUserNameTest {
+
+    public static void main(String args[]) {
+        System.setSecurityManager(new SecurityManager());
+        PrinterJob pj = PrinterJob.getPrinterJob();
+        boolean secExcpn = false;
+        try {
+            System.out.println(pj.getUserName());
+        } catch (SecurityException ex) {
+            secExcpn = true;
+            System.out.println("SecurityException thrown as user.name permission "
+                    + "not given");
+        }
+        if (!secExcpn) {
+            throw new RuntimeException("SecurityException not thrown");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/GetUserNameTest.policy	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+grant {
+  permission java.lang.RuntimePermission "setSecurityManager";
+  permission java.lang.RuntimePermission "createSecurityManager";
+  permission java.lang.RuntimePermission "usePolicy";
+  permission java.lang.RuntimePermission "queuePrintJob";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/PageDialogMarginTest.java	Mon Apr 25 09:25:26 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      6801613
+ * @summary  Verifies if cross-platform pageDialog and printDialog top margin
+ *           entry is working
+ * @run      main/manual PageDialogMarginTest
+ */
+import java.awt.Component;
+import java.awt.print.PageFormat;
+import java.awt.print.PrinterJob;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.MediaPrintableArea;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+public class PageDialogMarginTest {
+
+    public static void main(String args[]) throws Exception {
+        String[] instructions
+                = {
+                    "Page Dialog will be shown.",
+                    "Change top(in) margin value from 1.0 to 2.0",
+                    "Then select OK."
+                };
+        SwingUtilities.invokeAndWait(() -> {
+            JOptionPane.showMessageDialog((Component) null,
+                    instructions, "Instructions",
+                    JOptionPane.INFORMATION_MESSAGE);
+        });
+        PrinterJob pj = PrinterJob.getPrinterJob();
+        try {
+            HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+            PageFormat pf;
+            pf = pj.pageDialog(aset);
+            double left = pf.getImageableX();
+            double top = pf.getImageableY();
+            System.out.println("pageDialog - left/top from pageFormat: " + left / 72
+                    + " " + top / 72);
+            System.out.println("pageDialog - left/top from attribute set: "
+                    + getPrintableXFromASet(aset) + " "
+                    + getPrintableYFromASet(aset));
+            if (top / 72 != 2.0f || getPrintableYFromASet(aset) != 2.0f) {
+                throw new RuntimeException("Top margin value not updated");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    static double getPrintableXFromASet(PrintRequestAttributeSet aset) {
+        try {
+            return ((MediaPrintableArea) aset.get(
+                    MediaPrintableArea.class)).getX(MediaPrintableArea.INCH);
+        } catch (Exception e) {
+            return -1.0;
+        }
+    }
+
+    static double getPrintableYFromASet(PrintRequestAttributeSet aset) {
+        try {
+            return ((MediaPrintableArea) aset.get(
+                    MediaPrintableArea.class)).getY(MediaPrintableArea.INCH);
+        } catch (Exception e) {
+            return -1.0;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,867 @@
+/*
+ * 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.
+ */
+
+import java.beans.BeanInfo;
+import java.beans.BeanProperty;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+
+import java.util.Arrays;
+
+
+/**
+ * @test
+ * @bug 8132973 8132732 8155013
+ * @summary Some check for BeanProperty annotation
+ * @author a.stepanov
+ * @run main AnonymousClassBeanPropertyTest
+ */
+
+
+public class AnonymousClassBeanPropertyTest {
+
+    private final static String  DESCRIPTION = "TEST";
+    private final static boolean BOUND       = true;
+    private final static boolean EXPERT      = false;
+    private final static boolean HIDDEN      = true;
+    private final static boolean PREFERRED   = false;
+    private final static boolean REQUIRED    = true;
+    private final static boolean UPDATE      = false;
+
+    private final static double X = java.lang.Math.PI;
+
+    private final static String
+        V_NAME  = "java.lang.Math.PI",
+        V_SHORT = "PI",
+        V = Double.toString(X);
+
+    private final static String DESCRIPTION_2 = "XYZ";
+
+
+    // ---------- test cases (interfaces) ----------
+
+    private interface IGet {
+        double getX();
+    }
+
+    private interface ISet {
+        void setX(double v);
+    }
+
+    private interface IGetByIndex {
+        double getX(int i);
+    }
+
+    private interface ISetByIndex {
+        void setX(int i, double v);
+    }
+
+    private interface IGetArray {
+        double[] getX();
+    }
+
+    private interface ISetArray {
+        void setX(double a[]);
+    }
+
+    private interface IGetBoth {
+        double   getX(int i);
+        double[] getX();
+    }
+
+    private interface ISetBoth {
+        void setX(int i, double v);
+        void setX(double a[]);
+    }
+
+    private interface IGetSet {
+        double getX();
+        void setX(double v);
+    }
+
+    private interface IGetSetByIndex {
+        double getX(int i);
+        void setX(int i, double v);
+    }
+
+    private interface IGetSetBoth {
+        double   getX(int i);
+        double[] getX();
+        void setX(int i, double v);
+        void setX(double a[]);
+    }
+
+
+    // ---------- checks ----------
+
+    private static boolean check(String what, boolean v, boolean ref) {
+
+        boolean ok = (v == ref);
+        if (!ok) { System.out.println(
+            "invalid " + what + ": " + v + ", expected: " + ref); }
+        return ok;
+    }
+
+    private static boolean checkInfo(Class<?> c, String what) {
+
+        BeanInfo i;
+        try { i = Introspector.getBeanInfo(c, Object.class); }
+        catch (IntrospectionException e) { throw new RuntimeException(e); }
+
+        System.out.println("\nchecking info for " + what);
+
+        PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+        int nd = descriptors.length;
+        if (nd != 1) {
+            System.out.println("invalid number of descriptors: " + nd);
+            return false;
+        }
+
+        PropertyDescriptor d = descriptors[0];
+
+        String descr = d.getShortDescription();
+        boolean ok = descr.equals(DESCRIPTION);
+        if (!ok) { System.out.println("invalid description: " + descr +
+                ", expected: " + DESCRIPTION); }
+
+        ok &= check("isBound",  d.isBound(),  BOUND);
+        ok &= check("isExpert", d.isExpert(), EXPERT);
+        ok &= check("isHidden", d.isHidden(), HIDDEN);
+        ok &= check("isPreferred", d.isPreferred(), PREFERRED);
+        ok &= check("required", (boolean) d.getValue("required"), REQUIRED);
+        ok &= check("visualUpdate",
+            (boolean) d.getValue("visualUpdate"), UPDATE);
+
+        Object vals[] = (Object[]) d.getValue("enumerationValues");
+        if (vals == null) {
+            System.out.println("null enumerationValues");
+            return false;
+        }
+
+        if (vals.length == 0) {
+            System.out.println("empty enumerationValues");
+            return false;
+        }
+
+        boolean okVals = (
+            (vals.length == 3) &&
+             vals[0].toString().equals(V_SHORT) &&
+             vals[1].toString().equals(V)       &&
+             vals[2].toString().equals(V_NAME));
+
+        if (!okVals) {
+            System.out.println("invalid enumerationValues:");
+            for (Object v: vals) { System.out.println(v.toString()); }
+        }
+
+        return (ok && okVals);
+    }
+
+    private static boolean checkAlternativeInfo(Class<?> c, String what) {
+
+        BeanInfo i;
+        try { i = Introspector.getBeanInfo(c, Object.class); }
+        catch (IntrospectionException e) { throw new RuntimeException(e); }
+
+        System.out.println("checking alternative info for " + what);
+
+        PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+        int nd = descriptors.length;
+        if (nd != 1) {
+            System.out.println("invalid number of descriptors: " + nd);
+            return false;
+        }
+
+        PropertyDescriptor d = descriptors[0];
+
+        String descr = d.getShortDescription();
+        boolean ok = descr.equals(DESCRIPTION_2);
+        if (!ok) { System.out.println("invalid alternative description: " +
+            descr + ", expected: " + DESCRIPTION_2); }
+
+        ok &= check("isBound",  d.isBound(),  !BOUND);
+        ok &= check("isExpert", d.isExpert(), !EXPERT);
+        ok &= check("isHidden", d.isHidden(), !HIDDEN);
+        ok &= check("isPreferred", d.isPreferred(), !PREFERRED);
+        ok &= check("required", (boolean) d.getValue("required"), !REQUIRED);
+        ok &= check("visualUpdate",
+            (boolean) d.getValue("visualUpdate"), !UPDATE);
+
+        Object vals[] = (Object[]) d.getValue("enumerationValues");
+        if (vals != null || vals.length > 0) {
+            System.out.println("non-empty enumerationValues");
+            return false;
+        }
+
+        return ok;
+    }
+
+
+
+    // ---------- run tests ----------
+
+    public static void main(String[] args) {
+
+        boolean passed = true, ok, ok2;
+
+        //----------------------------------------------------------------------
+
+        IGet testGet = new IGet() {
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX() { return X; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGet.getClass(), "IGet");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+        //----------------------------------------------------------------------
+
+        ISet testSet = new ISet() {
+
+            private double x;
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public void setX(double v) { x = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testSet.getClass(), "ISet");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+        //----------------------------------------------------------------------
+
+        IGetByIndex testGetByIndex = new IGetByIndex() {
+
+            private final double x[] = {X, X};
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX(int i) { return x[i]; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetByIndex.getClass(), "IGetByIndex");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+        //----------------------------------------------------------------------
+
+        ISetByIndex testSetByIndex = new ISetByIndex() {
+
+            private final double x[] = {X, X, X};
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public void setX(int i, double v) { x[i] = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testSetByIndex.getClass(), "ISetByIndex");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+        //----------------------------------------------------------------------
+
+        // TODO: please uncomment/update after 8155013 fix
+        /*
+        IGetArray testGetArray = new IGetArray() {
+
+            private final double x[] = {X, X};
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double[] getX() { return x; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetArray.getClass(), "IGetArray");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+        */
+
+        //----------------------------------------------------------------------
+
+        // TODO: please uncomment/update after 8155013 fix
+        /*
+        ISetArray testSetArray = new ISetArray() {
+
+            private double x[];
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public void setX(double a[]) { x = Arrays.copyOf(a, a.length); }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testSetArray.getClass(), "ISetArray");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+        */
+
+        //----------------------------------------------------------------------
+
+        IGetBoth testGetBoth_1 = new IGetBoth() {
+
+            private final double x[] = {X, X};
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX(int i) { return x[i]; }
+            @Override
+            public double[] getX() { return x; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetBoth_1.getClass(), "IGetBoth-1");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+        // TODO: please uncomment/update after 8155013 fix
+        /*
+        IGetBoth testGetBoth_2 = new IGetBoth() {
+
+            private final double x[] = {X, X};
+
+            @Override
+            public double getX(int i) { return x[i]; }
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double[] getX() { return x; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetBoth_2.getClass(), "IGetBoth-2");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+        */
+
+        // TODO: please uncomment/update after 8132732 fix
+        /*
+        IGetBoth testGetBoth_3 = new IGetBoth() {
+
+            private final double x[] = {X, X};
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX(int i) { return x[i]; }
+            @BeanProperty(
+                description  = DESCRIPTION_2,
+                bound        = !BOUND,
+                expert       = !EXPERT,
+                hidden       = !HIDDEN,
+                preferred    = !PREFERRED,
+                required     = !REQUIRED,
+                visualUpdate = !UPDATE)
+            @Override
+            public double[] getX() { return x; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetBoth_3.getClass(), "IGetBoth-3");
+        System.out.println("OK = " + ok);
+        ok2 = checkAlternativeInfo(testGetBoth_3.getClass(), "IGetBoth-3");
+        System.out.println("OK = " + ok2);
+        passed = passed && ok && ok2;
+        */
+
+        //----------------------------------------------------------------------
+
+        ISetBoth testSetBoth_1 = new ISetBoth() {
+
+            private double x[] = new double[3];
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public void setX(int i, double v) { x[i] = v; }
+            @Override
+            public void setX(double[] a) { x = Arrays.copyOf(a, a.length); }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testSetBoth_1.getClass(), "ISetBoth-1");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+        // TODO: please uncomment/update after 8155013 fix
+        /*
+        ISetBoth testSetBoth_2 = new ISetBoth() {
+
+            private double x[] = new double[3];
+
+            @Override
+            public void setX(int i, double v) { x[i] = v; }
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public void setX(double[] a) { x = Arrays.copyOf(a, a.length); }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testSetBoth_2.getClass(), "ISetBoth-2");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+        */
+
+        // TODO: please uncomment/update after 8132732 fix
+        /*
+        ISetBoth testSetBoth_3 = new ISetBoth() {
+
+            private double x[] = {X, X};
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public void setX(int i, double v) { x[i] = v; }
+            @BeanProperty(
+                description  = DESCRIPTION_2,
+                bound        = !BOUND,
+                expert       = !EXPERT,
+                hidden       = !HIDDEN,
+                preferred    = !PREFERRED,
+                required     = !REQUIRED,
+                visualUpdate = !UPDATE)
+            @Override
+            public void setX(double[] a) { x = Arrays.copyOf(a, a.length); }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testSetBoth_3.getClass(), "ISetBoth-3");
+        System.out.println("OK = " + ok);
+        ok2 = checkAlternativeInfo(testSetBoth_3.getClass(), "ISetBoth-3");
+        System.out.println("OK = " + ok2);
+        passed = passed && ok && ok2;
+        */
+
+        //----------------------------------------------------------------------
+
+        IGetSet testGetSet_1 = new IGetSet() {
+
+            private double x;
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX() { return x; }
+            @Override
+            public void setX(double v) { x = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetSet_1.getClass(), "IGetSet-1");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+
+        IGetSet testGetSet_2 = new IGetSet() {
+
+            private double x;
+
+            @Override
+            public double getX() { return x; }
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public void setX(double v) { x = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetSet_2.getClass(), "IGetSet-2");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+        // TODO: please uncomment/update after 8132973 fix
+        /*
+        IGetSet testGetSet_3 = new IGetSet() {
+
+            private double x;
+
+            @Override
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            public double getX() { return x; }
+            @BeanProperty(
+                description  = DESCRIPTION_2,
+                bound        = !BOUND,
+                expert       = !EXPERT,
+                hidden       = !HIDDEN,
+                preferred    = !PREFERRED,
+                required     = !REQUIRED,
+                visualUpdate = !UPDATE)
+            @Override
+            public void setX(double v) { x = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetSet_3.getClass(), "IGetSet-3");
+        System.out.println("OK = " + ok);
+        ok2 = checkAlternativeInfo(testGetSet_3.getClass(), "IGetSet-3");
+        System.out.println("OK = " + ok2);
+        passed = passed && ok && ok2;
+        */
+
+        //----------------------------------------------------------------------
+
+        IGetSetByIndex testGetSetByIndex_1 = new IGetSetByIndex() {
+
+            private final double x[] = {X, X};
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX(int i) { return x[i]; }
+            @Override
+            public void setX(int i, double v) { x[i] = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetSetByIndex_1.getClass(), "IGetSetByIndex-1");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+
+        IGetSetByIndex testGetSetByIndex_2 = new IGetSetByIndex() {
+
+            private final double x[] = {X, X};
+
+            @Override
+            public double getX(int i) { return x[i]; }
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public void setX(int i, double v) { x[i] = v; }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetSetByIndex_2.getClass(), "IGetSetByIndex-2");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+
+        // TODO: please uncomment/update after 8132973 fix
+        /*
+        IGetSetByIndex testGetSetByIndex_3 = new IGetSetByIndex() {
+
+            private double x[] = {X, X};
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX(int i) {
+                return x[i];
+            }
+            @BeanProperty(
+                description  = DESCRIPTION_2,
+                bound        = !BOUND,
+                expert       = !EXPERT,
+                hidden       = !HIDDEN,
+                preferred    = !PREFERRED,
+                required     = !REQUIRED,
+                visualUpdate = !UPDATE)
+            @Override
+            public void setX(int i, double v) {
+                x[i] = v;
+            }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetSetByIndex_3.getClass(), "IGetSetByIndex-3");
+        System.out.println("OK = " + ok);
+        ok2 = checkAlternativeInfo(
+            testGetSetByIndex_3.getClass(), "IGetSetByIndex-3");
+        System.out.println("OK = " + ok2);
+        passed = passed && ok && ok2;
+        */
+
+        //----------------------------------------------------------------------
+
+        // TODO: please uncomment/update after 8155013 fix
+        /*
+        IGetSetBoth testGetSetBoth_1 = new IGetSetBoth() {
+
+            private double x[] = {X, X};
+
+            @Override
+            public double getX(int i) { return x[i]; }
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double[] getX() { return x; }
+            @Override
+            public void setX(int i, double v) { x[i] = v; }
+            @Override
+            public void setX(double[] a) { x = Arrays.copyOf(a, a.length); }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetSetBoth_1.getClass(), "IGetSetBoth-1");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+        */
+
+        // TODO: please uncomment/update after 8155013 fix
+        /*
+        IGetSetBoth testGetSetBoth_2 = new IGetSetBoth() {
+
+            private double x[] = {X, X};
+
+            @Override
+            public double getX(int i) { return x[i]; }
+            @Override
+            public double[] getX() { return x; }
+            @Override
+            public void setX(int i, double v) { x[i] = v; }
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public void setX(double[] a) { x = Arrays.copyOf(a, a.length); }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetSetBoth_2.getClass(), "IGetSetBoth-2");
+        System.out.println("OK = " + ok);
+        passed = passed && ok;
+        */
+
+        // TODO: please uncomment/update after 8132973 fix
+        /*
+        IGetSetBoth testGetSetBoth_3 = new IGetSetBoth() {
+
+            private double x[] = {X, X};
+
+            @BeanProperty(
+                description  = DESCRIPTION,
+                bound        = BOUND,
+                expert       = EXPERT,
+                hidden       = HIDDEN,
+                preferred    = PREFERRED,
+                required     = REQUIRED,
+                visualUpdate = UPDATE,
+                enumerationValues = {V_NAME})
+            @Override
+            public double getX(int i) { return x[i]; }
+            @Override
+            public double[] getX() { return x; }
+            @Override
+            public void setX(int i, double v) { x[i] = v; }
+            @BeanProperty(
+                description  = DESCRIPTION_2,
+                bound        = !BOUND,
+                expert       = !EXPERT,
+                hidden       = !HIDDEN,
+                preferred    = !PREFERRED,
+                required     = !REQUIRED,
+                visualUpdate = !UPDATE)
+            @Override
+            public void setX(double[] a) { x = Arrays.copyOf(a, a.length); }
+
+            public void addPropertyChangeListener(PropertyChangeListener l)    {}
+            public void removePropertyChangeListener(PropertyChangeListener l) {}
+        };
+        ok = checkInfo(testGetSetBoth_3.getClass(), "IGetSetBoth-3");
+        System.out.println("OK = " + ok);
+        ok2 = checkAlternativeInfo(
+            testGetSetBoth_3.getClass(), "IGetSetBoth-3");
+        System.out.println("OK = " + ok2);
+        passed = passed && ok && ok2;
+        */
+
+        if (!passed) { throw new RuntimeException("test failed"); }
+        System.out.println("\ntest passed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/BeanPropertyTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,1009 @@
+/*
+ * 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.
+ */
+
+import java.beans.BeanInfo;
+import java.beans.BeanProperty;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+
+import java.util.Arrays;
+
+
+/**
+ * @test
+ * @bug 8132703 8132163 8132732 8132973 8154756 8132888
+ * @summary Some check for BeanProperty annotation
+ * @author a.stepanov
+ * @run main BeanPropertyTest
+ */
+
+
+public class BeanPropertyTest {
+
+    private final static String  DESCRIPTION = "TEST";
+    private final static boolean BOUND       = true;
+    private final static boolean EXPERT      = false;
+    private final static boolean HIDDEN      = true;
+    private final static boolean PREFERRED   = false;
+    private final static boolean REQUIRED    = true;
+    private final static boolean UPDATE      = false;
+    private final static String
+        V_NAME  = "javax.swing.SwingConstants.TOP",
+        V_SHORT = "TOP",
+        V = Integer.toString(javax.swing.SwingConstants.TOP);
+    private final static int X = javax.swing.SwingConstants.TOP;
+
+    private final static String DESCRIPTION_2 = "XYZ";
+
+
+    // ---------- test cases ----------
+
+    public static class G01 {
+
+        private final static String TESTCASE = "arbitrary getter name";
+
+        private final int x = X;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int get1() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class S01 {
+
+        private final static String TESTCASE = "arbitrary setter name";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setXXXXX(int v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132703
+    public static class G02 {
+
+        private final static String TESTCASE = "arbitrary getter name";
+
+        private final int x = X;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int get() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132703
+    public static class S02 {
+
+        private final static String TESTCASE = "arbitrary setter name";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void set(int v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132703
+    public static class G03 {
+
+        private final static String TESTCASE = "arbitrary getter name";
+
+        private final int x = X;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int GetX() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132703
+    public static class S03 {
+
+        private final static String TESTCASE = "arbitrary setter name";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void SetX(int v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132163
+    public static class G04 {
+
+        private final static String TESTCASE = "arbitrary getter return type";
+
+        private final int x = X;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public Object getX() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132163
+    public static class S04 {
+
+        private final static String TESTCASE = "arbitrary setter argument type";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(short v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class G05 {
+
+        private final static String TESTCASE =
+            "annotated getter + arbitrary setter argument type";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int getX() { return x; }
+        public void setX(short v) { x = v; }
+
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132163
+    public static class S05 {
+
+        private final static String TESTCASE =
+            "annotated setter + arbitrary getter return type";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int v) { x = v; }
+        public Object getX() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class G06 {
+
+        private final static String TESTCASE = "indexed getter";
+
+        private final int x[] = {X, X, X};
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int getX(int i) { return x[i]; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class S06 {
+
+        private final static String TESTCASE = "indexed setter";
+
+        private final int x[] = {X, X, X};
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int i, int v) { x[i] = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class G07 {
+
+        private final static String TESTCASE =
+            "indexed (annotated) + non-indexed getters";
+
+        private final int x[] = {X, X, X};
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int getX(int i) { return x[i]; }
+
+        public int[] getX() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class S07 {
+
+        private final static String TESTCASE =
+            "indexed (annotated) + non-indexed setters";
+
+        private int x[] = new int[3];
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int i, int v) { x[i] = v; }
+
+        public void setX(int a[]) { x = Arrays.copyOf(a, a.length); }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132732
+    public static class G08 {
+
+        private final static String TESTCASE =
+            "non-indexed (annotated) + indexed getters";
+
+        private final int x[] = {X, X, X};
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int[] getX() { return x; }
+
+        public int getX(int i) { return x[i]; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132732
+    public static class S08 {
+
+        private final static String TESTCASE =
+            "non-indexed (annotated) + indexed setters";
+
+        private int x[] = new int[3];
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int a[]) { x = Arrays.copyOf(a, a.length); }
+
+        public void setX(int i, int v) { x[i] = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132732
+    public static class G09 {
+
+        private final static String TESTCASE = "two annotated getters";
+
+        private final int x[] = {X, X, X};
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int[] getX() { return x; }
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public int getX(int i) { return x[i]; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132732
+    public static class S09 {
+
+        private final static String TESTCASE = "two annotated setters";
+
+        private int x[] = new int[3];
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int a[]) { x = Arrays.copyOf(a, a.length); }
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public void setX(int i, int v) { x[i] = v; }
+
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class G10 {
+
+        private final static String TESTCASE =
+            "getter + similarly named field";
+
+        public int prop, Prop, setProp, getProp;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int getProp() { return X; }
+        public void setProp(int v) { prop = Prop = setProp = getProp = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class S10 {
+
+        private final static String TESTCASE =
+            "setter + similarly named field";
+
+        public int prop, Prop, setProp, getProp;
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int getProp() { return x; }
+        public void setProp(int v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class G11 {
+
+        private final static String TESTCASE =
+            "getter + similarly named field of other type";
+
+        public Object prop, Prop, setProp, getProp;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int getProp() { return X; }
+        public void setProp(int v) { prop = Prop = setProp = getProp = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class S11 {
+
+        private final static String TESTCASE =
+            "setter + similarly named field of other type";
+
+        public String prop, Prop, setProp, getProp;
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int getProp() { return x; }
+        public void setProp(int v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132163
+    public static class G12 {
+
+        private final static String TESTCASE =
+            "getter having wrapper class return type";
+
+        private final int x = X;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public Integer getProp() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132163
+    public static class S12 {
+
+        private final static String TESTCASE =
+            "setter with wrapper class argument type";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(Integer v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class G13 {
+
+        private final static String TESTCASE =
+            "getter + overloading methods";
+
+        private final int x = X;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int getX() { return x; }
+        public int getX(boolean arg) { return (arg ? x : 0); }
+        public int getX(int ... dummy) { return 0; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8154756
+    public static class S13 {
+
+        private final static String TESTCASE =
+            "setter + overloading methods";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int v) { x = v; }
+        public int  setX() { return (x = X); }
+        public void setX(int ... dummy) {}
+        private void setX(Object ... dummy) {}
+
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+
+    // JDK-8132888
+    public static class G14 {
+
+        private final static String TESTCASE = "non-public getter";
+
+        private final int x = X;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        int getX() { return x; } // getter is not public
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132888
+    public static class S14 {
+
+        private final static String TESTCASE = "non-public setter";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        void setX(int v) { x = v; } // setter is not public
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class getX {
+
+        private final static String TESTCASE =
+            "class name coincides with getter name";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int  getX() { return x; }
+        public void setX(int v) { x = v; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class setX {
+
+        private final static String TESTCASE =
+            "class name coincides with setter name";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public void setX(int v) { x = v; }
+        public int  getX() { return x; }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    // JDK-8132973
+    public static class GS {
+
+        private final static String TESTCASE =
+            "both getter and setter are annotated";
+
+        private int x;
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE,
+            enumerationValues = {V_NAME})
+        public int getX() { return x; }
+
+        @BeanProperty(
+            description  = DESCRIPTION_2,
+            bound        = !BOUND,
+            expert       = !EXPERT,
+            hidden       = !HIDDEN,
+            preferred    = !PREFERRED,
+            required     = !REQUIRED,
+            visualUpdate = !UPDATE)
+        public void setX(int v) { x = v; }
+
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class Self {
+
+        private final static String TESTCASE = "trivial singleton";
+
+        private static Self instance = null;
+        private Self() {}
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public Self getSelf() {
+            if (instance == null) { instance = new Self(); }
+            return instance;
+        }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+    public static class SelfArr {
+
+        private final static String TESTCASE = "trivial singleton + array";
+
+        private static SelfArr arr[] = null;
+        private SelfArr() {}
+
+        @BeanProperty(
+            description  = DESCRIPTION,
+            bound        = BOUND,
+            expert       = EXPERT,
+            hidden       = HIDDEN,
+            preferred    = PREFERRED,
+            required     = REQUIRED,
+            visualUpdate = UPDATE)
+        public SelfArr[] getSelfArr() {
+            if (arr == null) { arr = new SelfArr[]{new SelfArr(), new SelfArr()}; }
+            return arr;
+        }
+
+        public void addPropertyChangeListener(PropertyChangeListener l)    {}
+        public void removePropertyChangeListener(PropertyChangeListener l) {}
+    }
+
+
+    // ---------- checks ----------
+
+    private static boolean check(String what, boolean v, boolean ref) {
+
+        boolean ok = (v == ref);
+        if (!ok) { System.out.println(
+            "invalid " + what + ": " + v + ", expected: " + ref); }
+        return ok;
+    }
+
+    private static boolean checkInfo(BeanInfo i, boolean checkVals) {
+
+        System.out.println("checking info...");
+
+        PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+        int nd = descriptors.length;
+        if (nd != 1) {
+            System.out.println("invalid number of descriptors: " + nd);
+            return false;
+        }
+
+        PropertyDescriptor d = descriptors[0];
+
+        String descr = d.getShortDescription();
+        boolean ok = descr.equals(DESCRIPTION);
+        if (!ok) { System.out.println("invalid description: " + descr +
+                ", expected: " + DESCRIPTION); }
+
+        ok &= check("isBound",  d.isBound(),  BOUND);
+        ok &= check("isExpert", d.isExpert(), EXPERT);
+        ok &= check("isHidden", d.isHidden(), HIDDEN);
+        ok &= check("isPreferred", d.isPreferred(), PREFERRED);
+        ok &= check("required", (boolean) d.getValue("required"), REQUIRED);
+        ok &= check("visualUpdate",
+            (boolean) d.getValue("visualUpdate"), UPDATE);
+
+        if (!checkVals) { return ok; }
+
+        Object vals[] = (Object[]) d.getValue("enumerationValues");
+        if (vals == null) {
+            System.out.println("null enumerationValues");
+            return false;
+        }
+
+        boolean okVals = (
+            (vals.length == 3) &&
+             vals[0].toString().equals(V_SHORT) &&
+             vals[1].toString().equals(V)       &&
+             vals[2].toString().equals(V_NAME));
+
+        if (!okVals) { System.out.println("invalid enumerationValues"); }
+
+        return (ok && okVals);
+    }
+
+    private static boolean checkAlternativeInfo(BeanInfo i) {
+
+        System.out.println("checking alternative info...");
+
+        PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
+        int nd = descriptors.length;
+        if (nd != 1) {
+            System.out.println("invalid number of descriptors: " + nd);
+            return false;
+        }
+
+        PropertyDescriptor d = descriptors[0];
+
+        String descr = d.getShortDescription();
+        boolean ok = descr.equals(DESCRIPTION_2);
+        if (!ok) { System.out.println("invalid alternative description: " +
+            descr + ", expected: " + DESCRIPTION_2); }
+
+        ok &= check("isBound",  d.isBound(),  !BOUND);
+        ok &= check("isExpert", d.isExpert(), !EXPERT);
+        ok &= check("isHidden", d.isHidden(), !HIDDEN);
+        ok &= check("isPreferred", d.isPreferred(), !PREFERRED);
+        ok &= check("required", (boolean) d.getValue("required"), !REQUIRED);
+        ok &= check("visualUpdate",
+            (boolean) d.getValue("visualUpdate"), !UPDATE);
+
+        Object vals[] = (Object[]) d.getValue("enumerationValues");
+        if (vals != null || vals.length > 0) {
+            System.out.println("non-null enumerationValues");
+            return false;
+        }
+
+        return ok;
+    }
+
+
+    private static boolean checkAlternative(Class<?> c) {
+        return (
+            c.equals(G09.class) ||
+            c.equals(S09.class) ||
+            c.equals(GS.class));
+    }
+
+    private static boolean ignoreVals(Class<?> c) {
+        return (c.equals(Self.class) || c.equals(SelfArr.class));
+    }
+
+
+    // ---------- run test ----------
+
+    public static void main(String[] args) throws Exception {
+
+        Class<?> cases[] = {
+
+            G01.class, S01.class,
+            // G02.class, S02.class, // TODO: please update after 8132703 fix
+            // G03.class, S03.class, // TODO: please update after 8132703 fix
+            // G04.class, S04.class, // TODO: please update after 8132163 fix
+            G05.class, // S05.class, // TODO: please update after 8132163 fix
+            G06.class, S06.class,
+            G07.class, S07.class,
+            // G08.class, S08.class, // TODO: please update after 8132732 fix
+            // G09.class, S09.class, // TODO: please update after 8132732 fix
+            G10.class, S10.class,
+            G11.class, S11.class,
+            // G12.class, S12.class, // TODO: please update after 8132163 fix
+            G13.class, // S13.class, // TODO: please update after 8154756 fix
+            // G14.class, S14.class, // TODO: please update after 8132888 fix or
+                                     // remove these cases if it is not an issue
+            // GS.class, // TODO: please update after 8132973 fix
+            getX.class, setX.class,
+            Self.class, SelfArr.class
+        };
+
+        boolean passed = true;
+
+        for (Class<?> c: cases) {
+
+            java.lang.reflect.Field f = c.getDeclaredField("TESTCASE");
+            f.setAccessible(true);
+            String descr = f.get(c).toString();
+
+            System.out.println("\n" + c.getSimpleName() + " (" + descr + "):");
+            BeanInfo i;
+            try { i = Introspector.getBeanInfo(c, Object.class); }
+            catch (IntrospectionException e) { throw new RuntimeException(e); }
+            boolean ok = checkInfo(i, !ignoreVals(c));
+            if (checkAlternative(c)) {
+                ok |= checkAlternativeInfo(i);
+            }
+            System.out.println(ok ? "OK" : "NOK");
+            passed = passed && ok;
+        }
+
+        if (!passed) { throw new RuntimeException("test failed"); }
+        System.out.println("\ntest passed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/ClientProperty/UIClientPropertyKeyTest/UIClientPropertyKeyTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+
+import java.awt.EventQueue;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import javax.swing.UIClientPropertyKey;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+import static javax.swing.UIManager.getInstalledLookAndFeels;
+
+/**
+ * @test
+ * @bug 8141544
+ */
+public final class UIClientPropertyKeyTest {
+
+    private static Object key = new UIClientPropertyKey() {
+    };
+
+    public static void main(final String[] args) throws Exception {
+        EventQueue.invokeAndWait(UIClientPropertyKeyTest::testSetUI);
+        EventQueue.invokeAndWait(UIClientPropertyKeyTest::testSerialization);
+    }
+
+    /**
+     * UIClientPropertyKey should be removed after deserialization.
+     */
+    private static void testSerialization() {
+        JComponent comp = new JButton();
+        comp.putClientProperty("key1", "value1");
+        comp.putClientProperty(key, "value2");
+
+        comp = serializeDeserialize(comp);
+
+        validate(comp);
+    }
+
+    /**
+     * UIClientPropertyKey should be removed on updateUI().
+     */
+    private static void testSetUI() {
+        JComponent comp = new JButton();
+        comp.putClientProperty("key1", "value1");
+        for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
+            comp.putClientProperty(key, "value2");
+            setLookAndFeel(laf);
+            SwingUtilities.updateComponentTreeUI(comp);
+            validate(comp);
+        }
+    }
+
+    private static void validate(JComponent comp) {
+        Object value = comp.getClientProperty("key1");
+        if (!value.equals("value1")) {
+            throw new RuntimeException("Incorrect value: " + value);
+        }
+        value = comp.getClientProperty(key);
+        if (value != null) {
+            throw new RuntimeException("Incorrect value: " + value);
+        }
+    }
+
+    private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) {
+        try {
+            UIManager.setLookAndFeel(laf.getClassName());
+            System.out.println("LookAndFeel: " + laf.getClassName());
+        } catch (ClassNotFoundException | InstantiationException |
+                UnsupportedLookAndFeelException | IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static JComponent serializeDeserialize(JComponent comp) {
+        try {
+            ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+            ObjectOutputStream out = new ObjectOutputStream(byteOut);
+            out.writeObject(comp);
+            out.close();
+            return (JComponent) new ObjectInputStream(new ByteArrayInputStream(
+                    byteOut.toByteArray())).readObject();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JButton/PressedButtonRightClickTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+/*
+ * @test
+ * @bug  8049069
+ * @summary Tests whether right mouse click releases a pressed JButton
+ */
+
+public class PressedButtonRightClickTest {
+
+    private static Robot testRobot;
+    private static JFrame myFrame;
+    private static JButton myButton;
+
+    public static void main(String[] args) throws Throwable {
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                constructTestUI();
+            }
+        });
+
+        try {
+            testRobot = new Robot();
+        } catch (AWTException ex) {
+            throw new RuntimeException("Exception in Robot creation");
+        }
+
+        testRobot.waitForIdle();
+
+        // Method performing auto test operation
+        test();
+
+        disposeTestUI();
+    }
+
+    private static void test() {
+        Point loc = myFrame.getLocationOnScreen();
+
+        testRobot.mouseMove((loc.x + 100), (loc.y + 100));
+
+        // Press the left mouse button
+        testRobot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        myButton.setText("Left button pressed");
+        testRobot.delay(1000);
+
+        // Press the right mouse button
+        testRobot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
+        myButton.setText("Left button pressed + Right button pressed");
+        testRobot.delay(1000);
+
+        // Release the right mouse button
+        testRobot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
+        myButton.setText("Right button released");
+        testRobot.delay(1000);
+
+        // Test whether the button is still pressed
+        if (myButton.getModel().isPressed() == false) {
+            disposeTestUI();
+            throw new RuntimeException("Test Failed!");
+        }
+    }
+
+    private static void disposeTestUI() {
+        myFrame.setVisible(false);
+        myFrame.dispose();
+    }
+
+    public static void constructTestUI() {
+        myFrame = new JFrame();
+        myFrame.setLayout(new BorderLayout());
+        myButton = new JButton("Whatever");
+        myFrame.add(myButton, BorderLayout.CENTER);
+        myFrame.setSize(400, 300);
+        myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        myFrame.setVisible(true);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JEditorPane/5076514/bug5076514.java	Mon Apr 25 09:25:26 2016 -0700
@@ -0,0 +1,58 @@
+/*
+ * 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 5076514 8025430
+   @summary Tests if SecurityManager.checkPermission()
+                  used for clipboard access with permission 'accessClipboard'
+   @run main bug5076514
+*/
+
+import java.security.Permission;
+import javax.swing.JEditorPane;
+
+public class bug5076514 {
+    private final static String ACCESS_CLIPBOARD = "accessClipboard";
+    private static boolean isCheckPermissionCalled = false;
+
+    public static void main(String[] args) {
+        System.setSecurityManager(new MySecurityManager());
+        JEditorPane editor = new JEditorPane();
+        editor.copy();
+        if (!isCheckPermissionCalled) {
+            throw new RuntimeException("JEditorPane's clipboard operations "
+                    + "didn't call SecurityManager.checkPermission() with "
+                    + "permission 'accessClipboard' when there is a security"
+                    + " manager installed");
+        }
+    }
+
+    private static class MySecurityManager extends SecurityManager {
+        @Override
+        public void checkPermission(Permission perm) {
+            if (ACCESS_CLIPBOARD.equals(perm.getName())) {
+                isCheckPermissionCalled = true;
+            }
+        }
+    }
+}
--- a/jdk/test/javax/swing/JFileChooser/ShellFolderQueries/ShellFolderQueriesTest.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/test/javax/swing/JFileChooser/ShellFolderQueries/ShellFolderQueriesTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -30,7 +30,6 @@
  * @run main ShellFolderQueriesTest
  */
 
-import sun.awt.OSInfo;
 
 import javax.swing.filechooser.FileSystemView;
 import java.io.File;
@@ -50,7 +49,8 @@
     static String scriptEnd = "\"\noShellLink.WindowStyle = 1\noShellLink.Save";
 
     public static void main(String[] args) throws Exception {
-        if(OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
+        if(System.getProperty("os.name").toLowerCase().contains("windows")) {
+            System.out.println("Windows detected: will run shortcut test");
             testGet();
             testLink();
         } else {
--- a/jdk/test/javax/swing/LookAndFeel/6439354/TitledBorderTest.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/test/javax/swing/LookAndFeel/6439354/TitledBorderTest.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, 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
@@ -23,7 +23,7 @@
 
  /*
  * @test
- * @bug 6439354
+ * @bug 8153056 8152647 6439354
  * @summary Verify TitleBorder appearance Color/Visibility for WLAF
  * @requires (os.family == "windows")
  * @run main/manual TitledBorderTest
@@ -33,6 +33,7 @@
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.util.concurrent.CountDownLatch;
 import javax.swing.BorderFactory;
 import javax.swing.JButton;
 import javax.swing.JFrame;
@@ -41,7 +42,26 @@
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 
-public class TitledBorderTest implements ActionListener {
+public class TitledBorderTest {
+
+    public static void main(String args[]) throws Exception {
+        final CountDownLatch latch = new CountDownLatch(1);
+
+        TitledBorder test = new TitledBorder(latch);
+        Thread T1 = new Thread(test);
+        T1.start();
+
+        // wait for latch to complete
+        latch.await();
+
+        if (test.testResult == false) {
+            throw new RuntimeException("User Clicked Fail!"
+                    + " TitledBorder Not Valid");
+        }
+    }
+}
+
+class TitledBorder implements Runnable {
 
     private static GridBagLayout layout;
     private static JPanel mainControlPanel;
@@ -50,88 +70,98 @@
     private static JButton passButton;
     private static JButton failButton;
     private static JFrame mainFrame;
+    private final CountDownLatch latch;
+    public boolean testResult = false;
 
-    public static void main(String[] args) throws Exception {
-        TitledBorderTest titledBorderTest = new TitledBorderTest();
+    public TitledBorder(CountDownLatch latch) throws Exception {
+        this.latch = latch;
     }
 
-    public TitledBorderTest() throws Exception {
-        createUI();
+    @Override
+    public void run() {
+
+        try {
+            createUI();
+        } catch (Exception ex) {
+            if (mainFrame != null) {
+                mainFrame.dispose();
+            }
+            latch.countDown();
+            throw new RuntimeException("createUI Failed: " + ex.getMessage());
+        }
+
     }
 
     public final void createUI() throws Exception {
 
         UIManager.setLookAndFeel("com.sun.java.swing.plaf."
                 + "windows.WindowsLookAndFeel");
-
-        SwingUtilities.invokeAndWait(() -> {
-
-            mainFrame = new JFrame("Window LAF TitledBorder Test");
-            layout = new GridBagLayout();
-            mainControlPanel = new JPanel(layout);
-            resultButtonPanel = new JPanel(layout);
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                mainFrame = new JFrame("Window LAF TitledBorder Test");
+                layout = new GridBagLayout();
+                mainControlPanel = new JPanel(layout);
+                resultButtonPanel = new JPanel(layout);
 
-            GridBagConstraints gbc = new GridBagConstraints();
-            String instructions
-                    = "INSTRUCTIONS:"
-                    + "\n set Windows Theme to HighContrast#1."
-                    + "\n (ControlPanel->Personalization->High Contrast#1)"
-                    + "\n If Titled Border(Border Line) is visible then test"
-                    + " passes else failed.";
+                GridBagConstraints gbc = new GridBagConstraints();
+                String instructions
+                        = "INSTRUCTIONS:"
+                        + "\n set Windows Theme to HighContrast#1."
+                        + "\n (ControlPanel->Personalization->High Contrast#1)"
+                        + "\n If Titled Border(Border Line) is visible then test"
+                        + " passes else failed.";
 
-            instructionTextArea = new JTextArea();
-            instructionTextArea.setText(instructions);
-            instructionTextArea.setEnabled(false);
-            instructionTextArea.setDisabledTextColor(Color.black);
-            instructionTextArea.setBackground(Color.white);
+                instructionTextArea = new JTextArea();
+                instructionTextArea.setText(instructions);
+                instructionTextArea.setEnabled(false);
+                instructionTextArea.setDisabledTextColor(Color.black);
+                instructionTextArea.setBackground(Color.white);
 
-            gbc.gridx = 0;
-            gbc.gridy = 0;
-            gbc.fill = GridBagConstraints.HORIZONTAL;
-            mainControlPanel.add(instructionTextArea, gbc);
+                gbc.gridx = 0;
+                gbc.gridy = 0;
+                gbc.fill = GridBagConstraints.HORIZONTAL;
+                mainControlPanel.add(instructionTextArea, gbc);
 
-            mainControlPanel.setBorder(BorderFactory.
-                    createTitledBorder("Titled Border"));
+                mainControlPanel.setBorder(BorderFactory.
+                        createTitledBorder("Titled Border"));
 
-            passButton = new JButton("Pass");
-            passButton.setActionCommand("Pass");
-            passButton.addActionListener(TitledBorderTest.this);
-            failButton = new JButton("Fail");
-            failButton.setActionCommand("Fail");
-            failButton.addActionListener(TitledBorderTest.this);
-            gbc.gridx = 0;
-            gbc.gridy = 0;
-            resultButtonPanel.add(passButton, gbc);
-            gbc.gridx = 1;
-            gbc.gridy = 0;
-            resultButtonPanel.add(failButton, gbc);
+                passButton = new JButton("Pass");
+                passButton.setActionCommand("Pass");
+                passButton.addActionListener((ActionEvent e) -> {
+                    System.out.println("Pass Button pressed!");
+                    testResult = true;
+                    mainFrame.dispose();
+                    latch.countDown();
 
-            gbc.gridx = 0;
-            gbc.gridy = 1;
-            mainControlPanel.add(resultButtonPanel, gbc);
+                });
+                failButton = new JButton("Fail");
+                failButton.setActionCommand("Fail");
+                failButton.addActionListener(new ActionListener() {
+                    @Override
+                    public void actionPerformed(ActionEvent e) {
+                        System.out.println("Fail Button pressed!");
+                        testResult = false;
+                        mainFrame.dispose();
+                        latch.countDown();
+                    }
+                });
+                gbc.gridx = 0;
+                gbc.gridy = 0;
+                resultButtonPanel.add(passButton, gbc);
+                gbc.gridx = 1;
+                gbc.gridy = 0;
+                resultButtonPanel.add(failButton, gbc);
 
-            mainFrame.add(mainControlPanel);
-            mainFrame.pack();
-            mainFrame.setVisible(true);
+                gbc.gridx = 0;
+                gbc.gridy = 1;
+                mainControlPanel.add(resultButtonPanel, gbc);
+
+                mainFrame.add(mainControlPanel);
+                mainFrame.pack();
+                mainFrame.setVisible(true);
+            }
         });
+
     }
-
-    @Override
-    public void actionPerformed(ActionEvent evt) {
-        if (evt.getSource() instanceof JButton) {
-            JButton btn = (JButton) evt.getSource();
-            cleanUp();
-            switch (btn.getActionCommand()) {
-                case "Pass":
-                    break;
-                case "Fail":
-                    throw new AssertionError("User Clicked Fail!");
-            }
-        }
-    }
-
-    private static void cleanUp() {
-        mainFrame.dispose();
-    }
-
 }
--- a/jdk/test/javax/swing/undo/UndoManager/AbstractDocumentUndoConcurrentTest.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/test/javax/swing/undo/UndoManager/AbstractDocumentUndoConcurrentTest.java	Mon Apr 25 09:25:26 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
@@ -104,8 +104,12 @@
                     e.printStackTrace();
                 }
                 for (int i = 0; i < 1000; i++) {
-                    undoManager.undoOrRedo();
-                    undoManager.undo();
+                    if(undoManager.canUndoOrRedo()) {
+                        undoManager.undoOrRedo();
+                    }
+                    if(undoManager.canUndo()) {
+                        undoManager.undo();
+                    }
                 }
                 System.out.println("t3 done");
             }
--- a/jdk/test/sun/java2d/OpenGL/GradientPaints.java	Wed Jul 05 21:38:12 2017 +0200
+++ b/jdk/test/sun/java2d/OpenGL/GradientPaints.java	Mon Apr 25 09:25:26 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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,11 +23,11 @@
 
 /*
  * @test
- * @bug 6521533 6525997
+ * @bug 6521533 6525997 7102282
  * @summary Verifies that the OGL-accelerated codepaths for GradientPaint,
  * LinearGradientPaint, and RadialGradientPaint produce results that are
  * sufficiently close to those produced by the software codepaths.
- * @run main/othervm -Dsun.java2d.opengl=True GradientPaints
+ * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True GradientPaints
  * @author campbelc
  */