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

Passing ScriptObjectMirror Object Across Engines, hava a bug

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      <dependency>
                  <groupId>org.openjdk.nashorn</groupId>
                  <artifactId>nashorn-core</artifactId>
                  <version>15.4</version>
              </dependency>

      A DESCRIPTION OF THE PROBLEM :
      scriptObject should not be array, but it is now array

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      a
      b
      c
      ACTUAL -
      0,a
      1,b
      2,c

      ---------- BEGIN SOURCE ----------
      public class Main {
          public static void main(String[] args) throws ScriptException {
              ScriptEngine engine1 = new NashornScriptEngineFactory().getScriptEngine(new String[]{"--language=es6"});
              Object arr = engine1.eval("['a', 'b', 'c']");

              System.out.println("bug?");
              ScriptEngine engine2 = new NashornScriptEngineFactory().getScriptEngine(new String[]{"--language=es6"});
              engine2.put("arr", arr);
              engine2.eval("for (var a of arr) {\n" +
                      "\tprint(a)\n" +
                      "}");
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


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

              Created:
              Updated: