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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • None
    • core-libs
    • None
    • b82
    • generic
    • generic

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: