nashorn script engine should support the usage multiple global objects with same engine instance

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 8
    • Affects Version/s: None
    • Component/s: core-libs
    • None
    • b82
    • generic
    • generic

      User should be able to create new global object using ScriptEngine.createBindings API.

      ScriptEngine engine; // initialization skipped

      Bindings newGlobal = engine.createBindings();
      ScriptContext ctx = new ScriptContext();
      ctx.setBindings(newGlobal, ScriptContext.ENGINE_SCOPE);


      engine.eval("Object"); // refers to "Object" from default context's engine bindings
      engine.eval("Object", ctx); // refers to "Object" from given context's engine bindings.

      If engine_scope bindings of a ScriptContext is not nashorn engine created (by createBindings call), nashorn can fallback to use default global scope created for default context.

      This essentially exposes nashorn's multiple-global-per-context feature (used in testruns) via standard API.

            Assignee:
            Sundararajan Athijegannathan
            Reporter:
            Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: