提交 529321ab 编写于 作者: S sundar

8036794: Collect more Collector Lambdas

Reviewed-by: attila, ahgross
上级 213357ff
...@@ -81,23 +81,28 @@ public class ScriptEngineManager { ...@@ -81,23 +81,28 @@ public class ScriptEngineManager {
nameAssociations = new HashMap<String, ScriptEngineFactory>(); nameAssociations = new HashMap<String, ScriptEngineFactory>();
extensionAssociations = new HashMap<String, ScriptEngineFactory>(); extensionAssociations = new HashMap<String, ScriptEngineFactory>();
mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>(); mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>();
AccessController.doPrivileged(new PrivilegedAction<Object>() { initEngines(loader);
public Object run() { }
initEngines(loader);
return null; 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) { private void initEngines(final ClassLoader loader) {
Iterator<ScriptEngineFactory> itr = null; Iterator<ScriptEngineFactory> itr = null;
try { try {
ServiceLoader<ScriptEngineFactory> sl; ServiceLoader<ScriptEngineFactory> sl = AccessController.doPrivileged(
if (loader != null) { new PrivilegedAction<ServiceLoader<ScriptEngineFactory>>() {
sl = ServiceLoader.load(ScriptEngineFactory.class, loader); @Override
} else { public ServiceLoader<ScriptEngineFactory> run() {
sl = ServiceLoader.loadInstalled(ScriptEngineFactory.class); return getServiceLoader(loader);
} }
});
itr = sl.iterator(); itr = sl.iterator();
} catch (ServiceConfigurationError err) { } catch (ServiceConfigurationError err) {
System.err.println("Can't find ScriptEngineFactory providers: " + System.err.println("Can't find ScriptEngineFactory providers: " +
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册