changeset 11014:9ad45ae7a5b0

8208610: Incorrect check for calling class in FXMLLoader::getDefaultClassLoader Reviewed-by: prr, aghaisas
author kcr
date Thu, 02 Aug 2018 11:18:26 -0700
parents e6fb2b3967be
children 8451c9f32969
files modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java
diffstat 1 files changed, 4 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java	Thu Aug 02 18:54:08 2018 +0530
+++ b/modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java	Thu Aug 02 11:18:26 2018 -0700
@@ -3041,34 +3041,18 @@
         return Class.forName(className, true, getDefaultClassLoader());
     }
 
-    private static boolean needsClassLoaderPermissionCheck(ClassLoader from, ClassLoader to) {
-        if (from == to) {
+    private static boolean needsClassLoaderPermissionCheck(Class caller) {
+        if (caller == null) {
             return false;
         }
-        if (from == null) {
-            return false;
-        }
-        if (to == null) {
-            return true;
-        }
-        ClassLoader acl = to;
-        do {
-            acl = acl.getParent();
-            if (from == acl) {
-                return false;
-            }
-        } while (acl != null);
-        return true;
+        return !FXMLLoader.class.getModule().equals(caller.getModule());
     }
 
     private static ClassLoader getDefaultClassLoader(Class caller) {
         if (defaultClassLoader == null) {
             final SecurityManager sm = System.getSecurityManager();
             if (sm != null) {
-                final ClassLoader callerClassLoader = (caller != null) ?
-                        caller.getClassLoader() :
-                        null;
-                if (needsClassLoaderPermissionCheck(callerClassLoader, FXMLLoader.class.getClassLoader())) {
+                if (needsClassLoaderPermissionCheck(caller)) {
                     sm.checkPermission(GET_CLASSLOADER_PERMISSION);
                 }
             }