Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6318609

clarification needed on ScriptEngine.getBindings(ScriptContext.GLOBAL_SCOPE)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 6
    • core-libs
    • 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

            sundar Sundararajan Athijegannathan
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: