src/share/classes/javax/script/ScriptEngineManager.java

Print this page




 406 
 407     /** Set of script engine factories discovered. */
 408     private HashSet<ScriptEngineFactory> engineSpis;
 409 
 410     /** Map of engine name to script engine factory. */
 411     private HashMap<String, ScriptEngineFactory> nameAssociations;
 412 
 413     /** Map of script file extension to script engine factory. */
 414     private HashMap<String, ScriptEngineFactory> extensionAssociations;
 415 
 416     /** Map of script script MIME type to script engine factory. */
 417     private HashMap<String, ScriptEngineFactory> mimeTypeAssociations;
 418 
 419     /** Global bindings associated with script engines created by this manager. */
 420     private Bindings globalScope;
 421 
 422     private boolean canCallerAccessLoader(ClassLoader loader) {
 423         SecurityManager sm = System.getSecurityManager();
 424         if (sm != null) {
 425             ClassLoader callerLoader = getCallerClassLoader();
 426             if (callerLoader != null) {
 427                 if (loader != callerLoader || !isAncestor(loader, callerLoader)) {
 428                     try {
 429                         sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
 430                     } catch (SecurityException exp) {
 431                         if (DEBUG) exp.printStackTrace();
 432                         return false;
 433                     }
 434                 } // else fallthru..
 435             } // else fallthru..
 436         } // else fallthru..
 437 
 438         return true;
 439     }
 440 
 441     // Note that this code is same as ClassLoader.getCallerClassLoader().
 442     // But, that method is package private and hence we can't call here.
 443     private ClassLoader getCallerClassLoader() {
 444         Class<?> caller = Reflection.getCallerClass(3);
 445         if (caller == null) {
 446             return null;


 406 
 407     /** Set of script engine factories discovered. */
 408     private HashSet<ScriptEngineFactory> engineSpis;
 409 
 410     /** Map of engine name to script engine factory. */
 411     private HashMap<String, ScriptEngineFactory> nameAssociations;
 412 
 413     /** Map of script file extension to script engine factory. */
 414     private HashMap<String, ScriptEngineFactory> extensionAssociations;
 415 
 416     /** Map of script script MIME type to script engine factory. */
 417     private HashMap<String, ScriptEngineFactory> mimeTypeAssociations;
 418 
 419     /** Global bindings associated with script engines created by this manager. */
 420     private Bindings globalScope;
 421 
 422     private boolean canCallerAccessLoader(ClassLoader loader) {
 423         SecurityManager sm = System.getSecurityManager();
 424         if (sm != null) {
 425             ClassLoader callerLoader = getCallerClassLoader();
 426             if (!sun.misc.VM.isSystemDomainLoader(callerLoader)) {
 427                 if (loader != callerLoader || !isAncestor(loader, callerLoader)) {
 428                     try {
 429                         sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
 430                     } catch (SecurityException exp) {
 431                         if (DEBUG) exp.printStackTrace();
 432                         return false;
 433                     }
 434                 } // else fallthru..
 435             } // else fallthru..
 436         } // else fallthru..
 437 
 438         return true;
 439     }
 440 
 441     // Note that this code is same as ClassLoader.getCallerClassLoader().
 442     // But, that method is package private and hence we can't call here.
 443     private ClassLoader getCallerClassLoader() {
 444         Class<?> caller = Reflection.getCallerClass(3);
 445         if (caller == null) {
 446             return null;