changeset 4900:b4d1ed547a75

8006611: Improve scripting Reviewed-by: mchung, jdn
author sundar
date Fri, 05 Apr 2013 15:39:25 +0530
parents df371bf8d9a4
children 02cba1c3572a
files src/share/classes/javax/script/ScriptEngineManager.java
diffstat 1 files changed, 1 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/script/ScriptEngineManager.java	Sat Mar 30 22:45:54 2013 +0400
+++ b/src/share/classes/javax/script/ScriptEngineManager.java	Fri Apr 05 15:39:25 2013 +0530
@@ -30,8 +30,6 @@
 import java.security.*;
 import sun.misc.Service;
 import sun.misc.ServiceConfigurationError;
-import sun.reflect.Reflection;
-import sun.security.util.SecurityConstants;
 
 /**
  * The <code>ScriptEngineManager</code> implements a discovery and instantiation
@@ -64,13 +62,7 @@
      */
     public ScriptEngineManager() {
         ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader();
-        if (canCallerAccessLoader(ctxtLoader)) {
-            if (DEBUG) System.out.println("using " + ctxtLoader);
-            init(ctxtLoader);
-        } else {
-            if (DEBUG) System.out.println("using bootstrap loader");
-            init(null);
-        }
+        init(ctxtLoader);
     }
 
     /**
@@ -418,42 +410,4 @@
 
     /** Global bindings associated with script engines created by this manager. */
     private Bindings globalScope;
-
-    private boolean canCallerAccessLoader(ClassLoader loader) {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-            ClassLoader callerLoader = getCallerClassLoader();
-            if (callerLoader != null) {
-                if (loader != callerLoader || !isAncestor(loader, callerLoader)) {
-                    try {
-                        sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
-                    } catch (SecurityException exp) {
-                        if (DEBUG) exp.printStackTrace();
-                        return false;
-                    }
-                } // else fallthru..
-            } // else fallthru..
-        } // else fallthru..
-
-        return true;
-    }
-
-    // Note that this code is same as ClassLoader.getCallerClassLoader().
-    // But, that method is package private and hence we can't call here.
-    private ClassLoader getCallerClassLoader() {
-        Class caller = Reflection.getCallerClass(3);
-        if (caller == null) {
-            return null;
-        }
-        return caller.getClassLoader();
-    }
-
-    // is cl1 ancestor of cl2?
-    private boolean isAncestor(ClassLoader cl1, ClassLoader cl2) {
-        do {
-            cl2 = cl2.getParent();
-            if (cl1 == cl2) return true;
-        } while (cl2 != null);
-        return false;
-    }
 }