src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java

Print this page

        

*** 139,157 **** --- 139,178 ---- public ScriptEngine getScriptEngine() { return new NashornScriptEngine(this, getAppClassLoader()); } /** + * Create a new Script engine initialized by given class loader. + * + * @param appLoader class loader to be used as script "app" class loader. + * @return newly created script engine. + */ + public ScriptEngine getScriptEngine(final ClassLoader appLoader) { + return new NashornScriptEngine(this, appLoader); + } + + /** * Create a new Script engine initialized by given arguments. * * @param args arguments array passed to script engine. * @return newly created script engine. */ public ScriptEngine getScriptEngine(final String[] args) { return new NashornScriptEngine(this, args, getAppClassLoader()); } + /** + * Create a new Script engine initialized by given arguments. + * + * @param args arguments array passed to script engine. + * @param appLoader class loader to be used as script "app" class loader. + * @return newly created script engine. + */ + public ScriptEngine getScriptEngine(final String[] args, final ClassLoader appLoader) { + return new NashornScriptEngine(this, args, appLoader); + } + // -- Internals only below this point private static final List<String> names; private static final List<String> mimeTypes; private static final List<String> extensions;
*** 178,188 **** return Collections.unmodifiableList(Arrays.asList(elements)); } private static ClassLoader getAppClassLoader() { if (System.getSecurityManager() == null) { ! return ClassLoader.getSystemClassLoader(); } // Try to determine the caller class loader. Use that if it can be // found. If not, use the class loader of nashorn itself as the // "application" class loader for scripts. --- 199,209 ---- return Collections.unmodifiableList(Arrays.asList(elements)); } private static ClassLoader getAppClassLoader() { if (System.getSecurityManager() == null) { ! return Thread.currentThread().getContextClassLoader(); } // Try to determine the caller class loader. Use that if it can be // found. If not, use the class loader of nashorn itself as the // "application" class loader for scripts.