8036794: Collect more Collector Lambdas
authorsundar
Fri, 07 Mar 2014 21:48:51 +0530
changeset 23922 f361e6f7d154
parent 23921 1cb9d9ff4e61
child 23923 baaff2487309
8036794: Collect more Collector Lambdas Reviewed-by: attila, ahgross
jdk/src/share/classes/javax/script/ScriptEngineManager.java
--- 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: " +