src/share/classes/javax/script/ScriptEngineManager.java
Print this page
rev 8061 : 8011697: ScriptEngine "js" randomly means either "rhino" or "nashorn", but should instead select one
Summary: changed HashSet to ArrayList.
*** 1,7 ****
/*
! * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 75,85 ****
init(loader);
}
private void init(final ClassLoader loader) {
globalScope = new SimpleBindings();
! engineSpis = new HashSet<ScriptEngineFactory>();
nameAssociations = new HashMap<String, ScriptEngineFactory>();
extensionAssociations = new HashMap<String, ScriptEngineFactory>();
mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>();
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
--- 75,85 ----
init(loader);
}
private void init(final ClassLoader loader) {
globalScope = new SimpleBindings();
! engineSpis = new ArrayList<ScriptEngineFactory>();
nameAssociations = new HashMap<String, ScriptEngineFactory>();
extensionAssociations = new HashMap<String, ScriptEngineFactory>();
mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>();
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
*** 344,358 ****
* Returns a list whose elements are instances of all the <code>ScriptEngineFactory</code> classes
* found by the discovery mechanism.
* @return List of all discovered <code>ScriptEngineFactory</code>s.
*/
public List<ScriptEngineFactory> getEngineFactories() {
! List<ScriptEngineFactory> res = new ArrayList<ScriptEngineFactory>(engineSpis.size());
! for (ScriptEngineFactory spi : engineSpis) {
! res.add(spi);
! }
! return Collections.unmodifiableList(res);
}
/**
* Registers a <code>ScriptEngineFactory</code> to handle a language
* name. Overrides any such association found using the Discovery mechanism.
--- 344,354 ----
* Returns a list whose elements are instances of all the <code>ScriptEngineFactory</code> classes
* found by the discovery mechanism.
* @return List of all discovered <code>ScriptEngineFactory</code>s.
*/
public List<ScriptEngineFactory> getEngineFactories() {
! return Collections.unmodifiableList(engineSpis);
}
/**
* Registers a <code>ScriptEngineFactory</code> to handle a language
* name. Overrides any such association found using the Discovery mechanism.
*** 392,403 ****
public void registerEngineExtension(String extension, ScriptEngineFactory factory) {
if (extension == null || factory == null) throw new NullPointerException();
extensionAssociations.put(extension, factory);
}
! /** Set of script engine factories discovered. */
! private HashSet<ScriptEngineFactory> engineSpis;
/** Map of engine name to script engine factory. */
private HashMap<String, ScriptEngineFactory> nameAssociations;
/** Map of script file extension to script engine factory. */
--- 388,399 ----
public void registerEngineExtension(String extension, ScriptEngineFactory factory) {
if (extension == null || factory == null) throw new NullPointerException();
extensionAssociations.put(extension, factory);
}
! /** List of script engine factories discovered. */
! private ArrayList<ScriptEngineFactory> engineSpis;
/** Map of engine name to script engine factory. */
private HashMap<String, ScriptEngineFactory> nameAssociations;
/** Map of script file extension to script engine factory. */