--- a/jdk/src/share/classes/javax/script/ScriptEngineManager.java Thu Feb 20 09:36:58 2014 +0400
+++ b/jdk/src/share/classes/javax/script/ScriptEngineManager.java Fri Mar 07 21:48:51 2014 +0530
@@ -81,23 +81,28 @@
nameAssociations = new HashMap<String, ScriptEngineFactory>();
extensionAssociations = new HashMap<String, ScriptEngineFactory>();
mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>();
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- initEngines(loader);
- return null;
- }
- });
+ initEngines(loader);
+ }
+
+ private ServiceLoader<ScriptEngineFactory> getServiceLoader(final ClassLoader loader) {
+ if (loader != null) {
+ return ServiceLoader.load(ScriptEngineFactory.class, loader);
+ } else {
+ return ServiceLoader.loadInstalled(ScriptEngineFactory.class);
+ }
}
private void initEngines(final ClassLoader loader) {
Iterator<ScriptEngineFactory> itr = null;
try {
- ServiceLoader<ScriptEngineFactory> sl;
- if (loader != null) {
- sl = ServiceLoader.load(ScriptEngineFactory.class, loader);
- } else {
- sl = ServiceLoader.loadInstalled(ScriptEngineFactory.class);
- }
+ ServiceLoader<ScriptEngineFactory> sl = AccessController.doPrivileged(
+ new PrivilegedAction<ServiceLoader<ScriptEngineFactory>>() {
+ @Override
+ public ServiceLoader<ScriptEngineFactory> run() {
+ return getServiceLoader(loader);
+ }
+ });
+
itr = sl.iterator();
} catch (ServiceConfigurationError err) {
System.err.println("Can't find ScriptEngineFactory providers: " +