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

Ability to extend global instance by binding properties of another object

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • core-libs
    • b100
    • generic
    • generic
    • Verified

      In node (https://kenai.com/jira/browse/NODEJS-59), there is the ability to set a JS Object as the global scope of an evaluated script.
      Today, we can extend the global scope with some definitions but we can't provide a global instance.

      A possible approach would have been to add __no_such_property to the evaluated script, provide a Well known mapping name for our global JS instance, and route to the instance.
      This does work when getting property, but not for setting them.

      So currently we don't have any solution.

      A possible approach would be to have a JSObject being a Bindings. Something like:

      var obj = {foo:2};
      var newCtxt = new javax.script.SimpleScriptContext();
      newCtxt.setBindings(obj, javax.script.SimpleScriptContext.ENGINE_SCOPE);
      ...

            sundar Sundararajan Athijegannathan
            jfdenise Jean-Francois Denise (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: