changeset 10885:018c75e3aad8

Merge
author kcr
date Fri, 23 Mar 2018 16:46:29 -0700
parents 4ee4ff338d62 bc09cce3617a
children 0cd88e183e61
files
diffstat 28 files changed, 616 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/build.gradle	Tue Mar 20 18:56:10 2018 -0700
+++ b/build.gradle	Fri Mar 23 16:46:29 2018 -0700
@@ -1581,9 +1581,6 @@
 
 // Qualified exports needed by javafx.* modules (excluding javafx.swing)
 def qualExportsCore = [
-    "--add-exports=java.base/sun.reflect.misc=javafx.base",
-    "--add-exports=java.base/sun.reflect.misc=javafx.fxml",
-    "--add-exports=java.base/sun.reflect.misc=javafx.web",
     "--add-exports=java.base/sun.util.logging=javafx.base",
     "--add-exports=java.base/sun.util.logging=javafx.controls",
     "--add-exports=java.base/sun.util.logging=javafx.fxml",
--- a/dependencies/java.base/module-info.java.extra	Tue Mar 20 18:56:10 2018 -0700
+++ b/dependencies/java.base/module-info.java.extra	Fri Mar 23 16:46:29 2018 -0700
@@ -23,9 +23,6 @@
  * questions.
  */
 
-exports sun.reflect.misc to javafx.base;
-exports sun.reflect.misc to javafx.fxml;
-exports sun.reflect.misc to javafx.web;
 exports sun.util.logging to javafx.base;
 exports sun.util.logging to javafx.controls;
 exports sun.util.logging to javafx.fxml;
--- a/modules/javafx.base/src/main/java/com/sun/javafx/property/MethodHelper.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/property/MethodHelper.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 /**
  * Utility class to wrap method invocation.
--- a/modules/javafx.base/src/main/java/com/sun/javafx/property/PropertyReference.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/property/PropertyReference.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 
 import javafx.beans.property.ReadOnlyProperty;
 
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 /**
  * A handle to a specific property defined on some {@link Bean}.
--- a/modules/javafx.base/src/main/java/com/sun/javafx/property/adapter/JavaBeanPropertyBuilderHelper.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/property/adapter/JavaBeanPropertyBuilderHelper.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * 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,7 @@
 package com.sun.javafx.property.adapter;
 
 import java.lang.reflect.Method;
-
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 /**
  */
--- a/modules/javafx.base/src/main/java/com/sun/javafx/property/adapter/ReadOnlyJavaBeanPropertyBuilderHelper.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/property/adapter/ReadOnlyJavaBeanPropertyBuilderHelper.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * 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,7 @@
 package com.sun.javafx.property.adapter;
 
 import java.lang.reflect.Method;
-
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 /**
  */
--- a/modules/javafx.base/src/main/java/com/sun/javafx/property/adapter/ReadOnlyPropertyDescriptor.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/property/adapter/ReadOnlyPropertyDescriptor.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * 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 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 import static java.util.Locale.ENGLISH;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/reflect/ConstructorUtil.java	Fri Mar 23 16:46:29 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.reflect;
+
+import java.lang.reflect.Constructor;
+
+public final class ConstructorUtil {
+
+    private ConstructorUtil() {
+    }
+
+    public static Constructor<?> getConstructor(Class<?> cls, Class<?>[] params)
+        throws NoSuchMethodException {
+        ReflectUtil.checkPackageAccess(cls);
+        return cls.getConstructor(params);
+    }
+
+    public static Constructor<?>[] getConstructors(Class<?> cls) {
+        ReflectUtil.checkPackageAccess(cls);
+        return cls.getConstructors();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/reflect/FieldUtil.java	Fri Mar 23 16:46:29 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.reflect;
+
+import java.lang.reflect.Field;
+
+public final class FieldUtil {
+
+    private FieldUtil() {
+    }
+
+    public static Field getField(Class<?> cls, String name)
+        throws NoSuchFieldException {
+        ReflectUtil.checkPackageAccess(cls);
+        return cls.getField(name);
+    }
+}
--- a/modules/javafx.base/src/main/java/com/sun/javafx/reflect/MethodUtil.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/reflect/MethodUtil.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 
 class Trampoline {
@@ -89,15 +89,13 @@
         super();
     }
 
-    /*public*/
-    static Method getMethod(Class<?> cls, String name, Class<?>[] args)
+    public static Method getMethod(Class<?> cls, String name, Class<?>[] args)
         throws NoSuchMethodException {
         ReflectUtil.checkPackageAccess(cls);
         return cls.getMethod(name, args);
     }
 
-    /*public*/
-    static Method[] getMethods(Class<?> cls) {
+    public static Method[] getMethods(Class<?> cls) {
         ReflectUtil.checkPackageAccess(cls);
         return cls.getMethods();
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/reflect/ReflectUtil.java	Fri Mar 23 16:46:29 2018 -0700
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+package com.sun.javafx.reflect;
+
+import java.lang.reflect.Proxy;
+
+public final class ReflectUtil {
+
+    private ReflectUtil() {
+    }
+
+    /**
+     * Checks package access on the given class.
+     *
+     * If it is a {@link Proxy#isProxyClass(java.lang.Class)} that implements
+     * a non-public interface (i.e. may be in a non-restricted package),
+     * also check the package access on the proxy interfaces.
+     */
+    public static void checkPackageAccess(Class<?> clazz) {
+        SecurityManager s = System.getSecurityManager();
+        if (s != null) {
+            privateCheckPackageAccess(s, clazz);
+        }
+    }
+
+    /**
+     * NOTE: should only be called if a SecurityManager is installed
+     */
+    private static void privateCheckPackageAccess(SecurityManager s, Class<?> clazz) {
+        while (clazz.isArray()) {
+            clazz = clazz.getComponentType();
+        }
+
+        String pkg = clazz.getPackageName();
+        if (pkg != null && !pkg.isEmpty()) {
+            s.checkPackageAccess(pkg);
+        }
+
+        if (isNonPublicProxyClass(clazz)) {
+            privateCheckProxyPackageAccess(s, clazz);
+        }
+    }
+
+    /**
+     * Checks package access on the given classname.
+     * This method is typically called when the Class instance is not
+     * available and the caller attempts to load a class on behalf
+     * the true caller (application).
+     */
+    public static void checkPackageAccess(String name) {
+        SecurityManager s = System.getSecurityManager();
+        if (s != null) {
+            String cname = name.replace('/', '.');
+            if (cname.startsWith("[")) {
+                int b = cname.lastIndexOf('[') + 2;
+                if (b > 1 && b < cname.length()) {
+                    cname = cname.substring(b);
+                }
+            }
+            int i = cname.lastIndexOf('.');
+            if (i != -1) {
+                s.checkPackageAccess(cname.substring(0, i));
+            }
+        }
+    }
+
+    public static boolean isPackageAccessible(Class<?> clazz) {
+        try {
+            checkPackageAccess(clazz);
+        } catch (SecurityException e) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * NOTE: should only be called if a SecurityManager is installed
+     */
+    private static void privateCheckProxyPackageAccess(SecurityManager s, Class<?> clazz) {
+        // check proxy interfaces if the given class is a proxy class
+        if (Proxy.isProxyClass(clazz)) {
+            for (Class<?> intf : clazz.getInterfaces()) {
+                privateCheckPackageAccess(s, intf);
+            }
+        }
+    }
+
+    // Note that bytecode instrumentation tools may exclude 'sun.*'
+    // classes but not generated proxy classes and so keep it in com.sun.*
+    public static final String PROXY_PACKAGE = "com.sun.proxy";
+
+    /**
+     * Test if the given class is a proxy class that implements
+     * non-public interface.  Such proxy class may be in a non-restricted
+     * package that bypasses checkPackageAccess.
+     */
+    public static boolean isNonPublicProxyClass(Class<?> cls) {
+        if (!Proxy.isProxyClass(cls)) {
+            return false;
+        }
+        String pkg = cls.getPackageName();
+        return pkg == null || !pkg.startsWith(PROXY_PACKAGE);
+    }
+}
--- a/modules/javafx.fxml/src/main/java/com/sun/javafx/fxml/BeanAdapter.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.fxml/src/main/java/com/sun/javafx/fxml/BeanAdapter.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * 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,9 +40,9 @@
 import java.security.PrivilegedAction;
 
 import javafx.beans.value.ObservableValue;
-import sun.reflect.misc.FieldUtil;
-import sun.reflect.misc.MethodUtil;
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.FieldUtil;
+import com.sun.javafx.reflect.MethodUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 /**
  * Exposes Java Bean properties of an object via the {@link Map} interface.
--- a/modules/javafx.fxml/src/main/java/com/sun/javafx/fxml/MethodHelper.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.fxml/src/main/java/com/sun/javafx/fxml/MethodHelper.java	Fri Mar 23 16:46:29 2018 -0700
@@ -30,7 +30,7 @@
 import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 /**
  * Utility class to wrap method invocation.
--- a/modules/javafx.fxml/src/main/java/com/sun/javafx/fxml/builder/ProxyBuilder.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.fxml/src/main/java/com/sun/javafx/fxml/builder/ProxyBuilder.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,8 +45,8 @@
 import java.util.TreeSet;
 import javafx.beans.NamedArg;
 import javafx.util.Builder;
-import sun.reflect.misc.ConstructorUtil;
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ConstructorUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 /**
  * Using this builder assumes that some of the constructors of desired class
--- a/modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -90,9 +90,9 @@
 import java.util.EnumMap;
 import java.util.Locale;
 import java.util.StringTokenizer;
-import sun.reflect.misc.ConstructorUtil;
-import sun.reflect.misc.MethodUtil;
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ConstructorUtil;
+import com.sun.javafx.reflect.MethodUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 /**
  * Loads an object hierarchy from an XML document.
--- a/modules/javafx.fxml/src/main/java/javafx/fxml/JavaFXBuilderFactory.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.fxml/src/main/java/javafx/fxml/JavaFXBuilderFactory.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,8 +63,8 @@
 import javafx.scene.text.Font;
 import javafx.util.Builder;
 import javafx.util.BuilderFactory;
-import sun.reflect.misc.ConstructorUtil;
-import sun.reflect.misc.MethodUtil;
+import com.sun.javafx.reflect.ConstructorUtil;
+import com.sun.javafx.reflect.MethodUtil;
 
 /**
  * JavaFX builder factory.
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkApplication.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkApplication.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -146,7 +146,7 @@
 
         final int gtkVersion = forcedGtkVersion == 0 ?
             AccessController.doPrivileged((PrivilegedAction<Integer>) () -> {
-                String v = System.getProperty("jdk.gtk.version","2");
+                String v = System.getProperty("jdk.gtk.version","3");
                 int ret = 0;
                 if ("3".equals(v) || v.startsWith("3.")) {
                     ret = 3;
--- a/modules/javafx.graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinter.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinter.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * 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 javax.print.attribute.standard.Chromaticity;
 import javax.print.attribute.standard.Copies;
 import javax.print.attribute.standard.CopiesSupported;
-import javax.print.attribute.standard.Destination;
 import javax.print.attribute.standard.Media;
 import javax.print.attribute.standard.MediaPrintableArea;
 import javax.print.attribute.standard.MediaSize;
@@ -61,8 +60,6 @@
 import javafx.print.Printer;
 import javafx.print.Printer.MarginType;
 import javafx.print.Collation;
-import javafx.print.Paper;
-import javafx.print.PaperSource;
 import javafx.print.PageRange;
 import javafx.print.PrintColor;
 import javafx.print.PageOrientation;
@@ -791,15 +788,12 @@
      * to pre-defined javafx.print Papers. For all other reported media we
      * create a printer-specific instance and store it in a per-printer map.
      */
-    private Map<MediaSizeName, Paper> mediaToPaperMap;
-    private Map<Paper, MediaSizeName> paperToMediaMap;
+    private final Map<MediaSizeName, Paper> mediaToPaperMap
+         = new HashMap<MediaSizeName, Paper>();
+    private final Map<Paper, MediaSizeName> paperToMediaMap
+         = new HashMap<Paper, MediaSizeName>();
+
     private synchronized final Paper addPaper(MediaSizeName media) {
-
-        if (mediaToPaperMap == null) {
-            mediaToPaperMap = new HashMap<MediaSizeName, Paper>();
-            paperToMediaMap = new HashMap<Paper, MediaSizeName>();
-        }
-
         Paper paper = predefinedPaperMap.get(media);
         if (paper == null ) {
             MediaSize sz = MediaSize.getMediaSizeForName(media);
--- a/modules/javafx.graphics/src/main/java/javafx/scene/shape/Box.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.graphics/src/main/java/javafx/scene/shape/Box.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,7 +92,7 @@
     public static final double DEFAULT_SIZE = 2;
 
     {
-        // To initialize the class helper at the begining each constructor of this class
+        // To initialize the class helper at the beginning of each constructor of this class
         BoxHelper.initHelper(this);
     }
 
@@ -135,7 +135,7 @@
                 public void invalidated() {
                     NodeHelper.markDirty(Box.this, DirtyBits.MESH_GEOM);
                     manager.invalidateBoxMesh(key);
-                    key = 0;
+                    key = null;
                     NodeHelper.geomChanged(Box.this);
                 }
             };
@@ -165,7 +165,7 @@
                 public void invalidated() {
                     NodeHelper.markDirty(Box.this, DirtyBits.MESH_GEOM);
                     manager.invalidateBoxMesh(key);
-                    key = 0;
+                    key = null;
                     NodeHelper.geomChanged(Box.this);
                 }
             };
@@ -195,7 +195,7 @@
                 public void invalidated() {
                     NodeHelper.markDirty(Box.this, DirtyBits.MESH_GEOM);
                     manager.invalidateBoxMesh(key);
-                    key = 0;
+                    key = null;
                     NodeHelper.geomChanged(Box.this);
                 }
             };
@@ -222,8 +222,8 @@
             if (w < 0 || h < 0 || d < 0) {
                 peer.updateMesh(null);
             } else {
-                if (key == 0) {
-                    key = generateKey(w, h, d);
+                if (key == null) {
+                    key = new BoxKey(w, h, d);
                 }
                 mesh = manager.getBoxMesh(w, h, d, key);
                 mesh.updatePG();
@@ -469,11 +469,47 @@
         return mesh;
     }
 
-    private static int generateKey(float w, float h, float d) {
-        int hash = 3;
-        hash = 97 * hash + Float.floatToIntBits(w);
-        hash = 97 * hash + Float.floatToIntBits(h);
-        hash = 97 * hash + Float.floatToIntBits(d);
-        return hash;
+    private static class BoxKey extends Key {
+
+        final double width, height, depth;
+
+        private BoxKey(double width, double height, double depth) {
+            this.width = width;
+            this.height = height;
+            this.depth = depth;
+        }
+
+        @Override
+        public int hashCode() {
+            long bits = 7L;
+            bits = 31L * bits + Double.doubleToLongBits(depth);
+            bits = 31L * bits + Double.doubleToLongBits(height);
+            bits = 31L * bits + Double.doubleToLongBits(width);
+            return Long.hashCode(bits);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (!(obj instanceof BoxKey)) {
+                return false;
+            }
+            BoxKey other = (BoxKey) obj;
+            if (Double.compare(depth, other.depth) != 0) {
+                return false;
+            }
+            if (Double.compare(height, other.height) != 0) {
+                return false;
+            }
+            if (Double.compare(width, other.width) != 0) {
+                return false;
+            }
+            return true;
+        }
     }
 }
--- a/modules/javafx.graphics/src/main/java/javafx/scene/shape/Cylinder.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.graphics/src/main/java/javafx/scene/shape/Cylinder.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -153,7 +153,7 @@
                 public void invalidated() {
                     NodeHelper.markDirty(Cylinder.this, DirtyBits.MESH_GEOM);
                     manager.invalidateCylinderMesh(key);
-                    key = 0;
+                    key = null;
                     NodeHelper.geomChanged(Cylinder.this);
                 }
             };
@@ -183,7 +183,7 @@
                 public void invalidated() {
                     NodeHelper.markDirty(Cylinder.this, DirtyBits.MESH_GEOM);
                     manager.invalidateCylinderMesh(key);
-                    key = 0;
+                    key = null;
                     NodeHelper.geomChanged(Cylinder.this);
                 }
             };
@@ -211,8 +211,8 @@
             if (h < 0 || r < 0) {
                 peer.updateMesh(null);
             } else {
-                if (key == 0) {
-                    key = generateKey(h, r, divisions);
+                if (key == null) {
+                    key = new CylinderKey(h, r, divisions);
                 }
                 mesh = manager.getCylinderMesh(h, r, divisions, key);
                 mesh.updatePG();
@@ -563,11 +563,48 @@
         return m;
     }
 
-    private static int generateKey(float h, float r, int div) {
-        int hash = 7;
-        hash = 47 * hash + Float.floatToIntBits(h);
-        hash = 47 * hash + Float.floatToIntBits(r);
-        hash = 47 * hash + div;
-        return hash;
+    private static class CylinderKey extends Key {
+
+        final double radius, height;
+        final int divisions;
+
+        private CylinderKey(double radius, double height, int divisions) {
+            this.radius = radius;
+            this.height = height;
+            this.divisions = divisions;
+        }
+
+        @Override
+        public int hashCode() {
+            long bits = 7L;
+            bits = 31L * bits + Double.doubleToLongBits(radius);
+            bits = 31L * bits + Double.doubleToLongBits(height);
+            bits = 31L * bits + divisions;
+            return Long.hashCode(bits);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (!(obj instanceof CylinderKey)) {
+                return false;
+            }
+            CylinderKey other = (CylinderKey) obj;
+            if (divisions != other.divisions) {
+                return false;
+            }
+            if (Double.compare(radius, other.radius) != 0) {
+                return false;
+            }
+            if (Double.compare(height, other.height) != 0) {
+                return false;
+            }
+            return true;
+        }
     }
 }
--- a/modules/javafx.graphics/src/main/java/javafx/scene/shape/PredefinedMeshManager.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.graphics/src/main/java/javafx/scene/shape/PredefinedMeshManager.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * 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 javafx.scene.shape;
 
 import java.util.HashMap;
+import java.util.Map;
+
+import javafx.scene.shape.Shape3D.Key;
 
 final class PredefinedMeshManager {
 
@@ -33,9 +36,9 @@
     private static final int INITAL_CAPACITY = 17; // TODO
     private static final float LOAD_FACTOR = 0.75f;
 
-    private HashMap<Integer, TriangleMesh> boxCache = null;
-    private HashMap<Integer, TriangleMesh> sphereCache = null;
-    private HashMap<Integer, TriangleMesh> cylinderCache = null;
+    private Map<Key, TriangleMesh> boxCache = null;
+    private Map<Key, TriangleMesh> sphereCache = null;
+    private Map<Key, TriangleMesh> cylinderCache = null;
 
     private PredefinedMeshManager() {}
 
@@ -43,7 +46,7 @@
         return INSTANCE;
     }
 
-    synchronized TriangleMesh getBoxMesh(float w, float h, float d, int key) {
+    synchronized TriangleMesh getBoxMesh(float w, float h, float d, Key key) {
         if (boxCache == null) {
             boxCache = BoxCacheLoader.INSTANCE;
         }
@@ -58,7 +61,7 @@
         return mesh;
     }
 
-    synchronized TriangleMesh getSphereMesh(float r, int div, int key) {
+    synchronized TriangleMesh getSphereMesh(float r, int div, Key key) {
         if (sphereCache == null) {
             sphereCache = SphereCacheLoader.INSTANCE;
         }
@@ -73,7 +76,7 @@
         return mesh;
     }
 
-    synchronized TriangleMesh getCylinderMesh(float h, float r, int div, int key) {
+    synchronized TriangleMesh getCylinderMesh(float h, float r, int div, Key key) {
         if (cylinderCache == null) {
             cylinderCache = CylinderCacheLoader.INSTANCE;
         }
@@ -88,7 +91,7 @@
         return mesh;
     }
 
-    synchronized void invalidateBoxMesh(int key) {
+    synchronized void invalidateBoxMesh(Key key) {
         if (boxCache != null) {
             TriangleMesh mesh = boxCache.get(key);
             if (mesh != null) {
@@ -101,7 +104,7 @@
         }
     }
 
-    synchronized void invalidateSphereMesh(int key) {
+    synchronized void invalidateSphereMesh(Key key) {
         if (sphereCache != null) {
             TriangleMesh mesh = sphereCache.get(key);
             if (mesh != null) {
@@ -114,7 +117,7 @@
         }
     }
 
-    synchronized void invalidateCylinderMesh(int key) {
+    synchronized void invalidateCylinderMesh(Key key) {
         if (cylinderCache != null) {
             TriangleMesh mesh = cylinderCache.get(key);
             if (mesh != null) {
@@ -155,25 +158,50 @@
         }
     }
 
+    /**
+     * Note: The only user of this method is in unit test: PredefinedMeshManagerTest.
+     */
+    void test_clearCaches() {
+        INSTANCE.dispose();
+    }
+
+    /**
+     * Note: The only user of this method is in unit test: PredefinedMeshManagerTest.
+     */
+    int test_getBoxCacheSize() {
+        return INSTANCE.boxCache.size();
+    }
+
+    /**
+     * Note: The only user of this method is in unit test: PredefinedMeshManagerTest.
+     */
+    int test_getSphereCacheSize() {
+        return INSTANCE.sphereCache.size();
+    }
+
+    /**
+     * Note: The only user of this method is in unit test: PredefinedMeshManagerTest.
+     */
+    int test_getCylinderCacheSize() {
+        return INSTANCE.cylinderCache.size();
+    }
+
     private final static class BoxCacheLoader {
 
         // lazy & thread-safe instantiation
-        private static final HashMap<Integer, TriangleMesh>
-                INSTANCE = new HashMap<Integer, TriangleMesh>(INITAL_CAPACITY, LOAD_FACTOR);
+        private static final Map<Key, TriangleMesh> INSTANCE = new HashMap<>(INITAL_CAPACITY, LOAD_FACTOR);
     }
 
     private final static class SphereCacheLoader {
 
         // lazy & thread-safe instantiation
-        private static final HashMap<Integer, TriangleMesh>
-                INSTANCE = new HashMap<Integer, TriangleMesh>(INITAL_CAPACITY, LOAD_FACTOR);
+        private static final Map<Key, TriangleMesh> INSTANCE = new HashMap<>(INITAL_CAPACITY, LOAD_FACTOR);
     }
 
     private final static class CylinderCacheLoader {
 
         // lazy & thread-safe instantiation
-        private static final HashMap<Integer, TriangleMesh>
-                INSTANCE = new HashMap<Integer, TriangleMesh>(INITAL_CAPACITY, LOAD_FACTOR);
+        private static final Map<Key, TriangleMesh> INSTANCE = new HashMap<>(INITAL_CAPACITY, LOAD_FACTOR);
     }
 
 };
--- a/modules/javafx.graphics/src/main/java/javafx/scene/shape/Shape3D.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.graphics/src/main/java/javafx/scene/shape/Shape3D.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,6 @@
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
 import javafx.beans.value.ChangeListener;
-import javafx.beans.value.ObservableValue;
 import javafx.beans.value.WeakChangeListener;
 import javafx.scene.Node;
 import javafx.scene.paint.Material;
@@ -107,7 +106,20 @@
     }
 
     PredefinedMeshManager manager = PredefinedMeshManager.getInstance();
-    int key = 0;
+    Key key;
+
+    /**
+     * Used by the caching mechanism to compare between instances of the same shape.
+     * Each shape implements equals and hashCode using its base parameters.
+     */
+    abstract static class Key {
+
+        @Override
+        public abstract boolean equals(Object obj);
+
+        @Override
+        public abstract int hashCode();
+    }
 
     /**
      * Defines the material this {@code Shape3D}.
--- a/modules/javafx.graphics/src/main/java/javafx/scene/shape/Sphere.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.graphics/src/main/java/javafx/scene/shape/Sphere.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -148,7 +148,7 @@
                 public void invalidated() {
                     NodeHelper.markDirty(Sphere.this, DirtyBits.MESH_GEOM);
                     manager.invalidateSphereMesh(key);
-                    key = 0;
+                    key = null;
                     NodeHelper.geomChanged(Sphere.this);
                 }
             };
@@ -182,8 +182,8 @@
             if (r < 0) {
                 pgSphere.updateMesh(null);
             } else {
-                if (key == 0) {
-                    key = generateKey(r, divisions);
+                if (key == null) {
+                    key = new SphereKey(r, divisions);
                 }
                 mesh = manager.getSphereMesh(r, divisions, key);
                 mesh.updatePG();
@@ -443,10 +443,43 @@
         return m;
     }
 
-    private static int generateKey(float r, int div) {
-        int hash = 5;
-        hash = 23 * hash + Float.floatToIntBits(r);
-        hash = 23 * hash + div;
-        return hash;
+    private static class SphereKey extends Key {
+
+        final double radius;
+        final int divisions;
+
+        private SphereKey(double radius, int divisions) {
+            this.radius = radius;
+            this.divisions = divisions;
+        }
+
+        @Override
+        public int hashCode() {
+            long bits = 7L;
+            bits = 31L * bits + Double.doubleToLongBits(radius);
+            bits = 31L * bits + divisions;
+            return Long.hashCode(bits);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (!(obj instanceof SphereKey)) {
+                return false;
+            }
+            SphereKey other = (SphereKey) obj;
+            if (divisions != other.divisions) {
+                return false;
+            }
+            if (Double.compare(radius, other.radius) != 0) {
+                return false;
+            }
+            return true;
+        }
     }
 }
--- a/modules/javafx.graphics/src/main/native-glass/gtk/launcher.c	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.graphics/src/main/native-glass/gtk/launcher.c	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -129,7 +129,7 @@
      }
 
      int success = 1;
-     char *** use_chain = two_to_three;
+     char *** use_chain = three_to_two;
      int i, found = 0;
 
      //at first try to detect already loaded GTK version
@@ -141,17 +141,17 @@
      }
 
      if (!found) {
-         if (wantVersion == 0 || wantVersion == 2) {
+         if (wantVersion == 0 || wantVersion == 3) {
+             use_chain = three_to_two;
+         } else if (wantVersion == 2) {
              use_chain = two_to_three;
-         } else if (wantVersion == 3) {
-             use_chain = three_to_two;
          } else {
              // Note, this should never happen, java should be protecting us
              if (gtk_versionDebug) {
-                 printf("bad GTK version specified, assuming 2\n");
+                 printf("bad GTK version specified, assuming 3\n");
              }
-             wantVersion = 2;
-             use_chain = two_to_three;
+             wantVersion = 3;
+             use_chain = three_to_two;
          }
 
          for (i = 0; use_chain[i] && !found; i++) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/javafx.graphics/src/shims/java/javafx/scene/shape/PredefinedMeshManagerShim.java	Fri Mar 23 16:46:29 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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 javafx.scene.shape;
+
+public class PredefinedMeshManagerShim {
+
+    public static void clearCaches() {
+        PredefinedMeshManager.getInstance().test_clearCaches();
+    }
+
+    public static int getBoxCacheSize() {
+        return PredefinedMeshManager.getInstance().test_getBoxCacheSize();
+    }
+
+    public static int getSphereCacheSize() {
+        return PredefinedMeshManager.getInstance().test_getSphereCacheSize();
+    }
+
+    public static int getCylinderCacheSize() {
+        return PredefinedMeshManager.getInstance().test_getCylinderCacheSize();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/javafx.graphics/src/test/java/test/javafx/scene/shape/PredefinedMeshManagerTest.java	Fri Mar 23 16:46:29 2018 -0700
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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 test.javafx.scene.shape;
+
+import static org.junit.Assert.*;
+
+import javafx.scene.shape.Box;
+import javafx.scene.shape.Cylinder;
+import javafx.scene.shape.PredefinedMeshManagerShim;
+import javafx.scene.shape.Shape3D;
+import javafx.scene.shape.Sphere;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.sun.javafx.scene.NodeHelper;
+
+public class PredefinedMeshManagerTest {
+
+    @Before
+    public void clearCaches() {
+        PredefinedMeshManagerShim.clearCaches();
+    }
+
+    private void testShapeAddition(Shape3D shape, int correctSize) {
+        NodeHelper.updatePeer(shape);
+        int size = -1;
+        String name = null;
+        if (shape instanceof Box) {
+            size = PredefinedMeshManagerShim.getBoxCacheSize();
+            name = "box";
+        }
+        else if (shape instanceof Sphere) {
+            size = PredefinedMeshManagerShim.getSphereCacheSize();
+            name = "sphere";
+        }
+        else if (shape instanceof Cylinder) {
+            size = PredefinedMeshManagerShim.getCylinderCacheSize();
+            name = "cylinder";
+        }
+        assertEquals("Added a " + name + " - cache should contain " + correctSize + " mesh.", correctSize, size);
+    }
+
+    @Test
+    public void boxCacheTest() {
+        Box box1 = new Box(9, 1, 12);
+        testShapeAddition(box1 ,1);
+
+        // JDK-8180151: size will stay 1 without the fix (due to hash collision)
+        // new dimensions to cause a collision are any w/2, h*4, d/2
+        Box box2 = new Box(4.5, 4, 6);
+        testShapeAddition(box2 ,2);
+
+        Box box1again = new Box(9, 1, 12);
+        testShapeAddition(box1again, 2);
+    }
+
+    @Test
+    public void sphereCacheTest() {
+        Sphere sphere1 = new Sphere(10, 1000);
+        testShapeAddition(sphere1, 1);
+
+        // JDK-8180151: size will stay 1 without the fix (due to hash collision)
+        // From the old hash function:
+        // div2 = 23 * (Float.floatToIntBits(r1) - Float.floatToIntBits(r2)) + div1
+        Sphere sphere2 = new Sphere(9.99997, 1713);
+        testShapeAddition(sphere2, 2);
+
+        Sphere sphere1again = new Sphere(10, 1000);
+        testShapeAddition(sphere1again, 2);
+    }
+
+    @Test
+    public void cylinderCacheTest() {
+        Cylinder cylinder1 = new Cylinder(10, 20, 1000);
+        testShapeAddition(cylinder1, 1);
+
+        // JDK-8180151: size will stay 1 without the fix (due to hash collision)
+        // From the old hash function:
+        // div2 = 47*47 * (Float.floatToIntBits(h1) - Float.floatToIntBits(h2)) +
+        //           47 * (Float.floatToIntBits(r1) - Float.floatToIntBits(r2)) + div1;
+        Cylinder cylinder2 = new Cylinder(9.9997, 19.9997, 362618);
+        testShapeAddition(cylinder2, 2);
+
+        Cylinder cylinder1again = new Cylinder(10, 20, 1000);
+        testShapeAddition(cylinder1again, 2);
+    }
+}
--- a/modules/javafx.web/src/ios/java/javafx/scene/web/ExportedJavaObject.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.web/src/ios/java/javafx/scene/web/ExportedJavaObject.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,7 @@
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 
-import sun.reflect.misc.MethodUtil;
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 
 // Java Object exported to JavaScript
--- a/modules/javafx.web/src/main/java/com/sun/webkit/MethodHelper.java	Tue Mar 20 18:56:10 2018 -0700
+++ b/modules/javafx.web/src/main/java/com/sun/webkit/MethodHelper.java	Fri Mar 23 16:46:29 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import sun.reflect.misc.ReflectUtil;
+import com.sun.javafx.reflect.ReflectUtil;
 
 /**
  * Utility class to wrap method invocation.