-
Bug
-
Resolution: Fixed
-
P4
-
6
-
None
-
b53
-
generic
-
generic
Vladimir wrote:
There is a sentence in specification for javax.script.ScriptEngine.getBindings():
...
Returns a scope of named values. The possible scopes are:
ScriptContext.GLOBAL_SCOPE - A set of named values shared by all ScriptEngines created by the same ScriptEngineFactory. If the ScriptEngine is created by a ScriptEngineManager, a reference to the global scope stored by the ScriptEngineManager should be returned. May return null if no global scope is associated with this ScriptEngine.
...
So, as I understand if instance of engine created by ScriptEngineManager then the engine's getBindings(ScriptContext.GLOBAL_SCOPE) should return the same Bindings object as ScriptEngineManager.getBindings(). This is not quite true for AbstractScriptEngine and embedded in Mustang JavaScript engine:
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByExtension("js");
// in this moment engine.getBindings(ScriptContext.GLOBAL_SCOPE) == manager. getBindings() as spec required
manager.setBindings(new SimpleBinding());
// and in this moment engine.getBindings(ScriptContext.GLOBAL_SCOPE) != manager. getBindings() - spec violated
There is a sentence in specification for javax.script.ScriptEngine.getBindings():
...
Returns a scope of named values. The possible scopes are:
ScriptContext.GLOBAL_SCOPE - A set of named values shared by all ScriptEngines created by the same ScriptEngineFactory. If the ScriptEngine is created by a ScriptEngineManager, a reference to the global scope stored by the ScriptEngineManager should be returned. May return null if no global scope is associated with this ScriptEngine.
...
So, as I understand if instance of engine created by ScriptEngineManager then the engine's getBindings(ScriptContext.GLOBAL_SCOPE) should return the same Bindings object as ScriptEngineManager.getBindings(). This is not quite true for AbstractScriptEngine and embedded in Mustang JavaScript engine:
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByExtension("js");
// in this moment engine.getBindings(ScriptContext.GLOBAL_SCOPE) == manager. getBindings() as spec required
manager.setBindings(new SimpleBinding());
// and in this moment engine.getBindings(ScriptContext.GLOBAL_SCOPE) != manager. getBindings() - spec violated