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

JavaScript scope (Bindings) implementation is broken

XMLWordPrintable

    • b63
    • generic
    • generic

      import javax.script.*;

      public class t {
              public static void main(String[] args) throws Exception {
                      ScriptEngineManager m = new ScriptEngineManager();
                      ScriptEngine e = m.getEngineByName("js");
                      e.eval("var v = 'hello'");
                      Bindings b = e.createBindings();
                      // b is newly created scope. We don't expect 'v' in it...
                      // we expect 'b' to be empty
                      for (String s: b.keySet())
                          System.out.println(s);
              }
      }

      Running the above program prints

      context
      print
      v

      This is not expected. The newly created scope somehow gets the values created in default engine scope of the JavaScript engine. This should not happen.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: