Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8034892 nashorn compatibility issues
  3. JDK-8035181

No 'println' in global scope when executing script via javax.script

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None

      Description

      import java.io.*;
      import javax.script.*;

      public class Jtest6{

          public static void main(String[] args){
              ScriptEngineManager factory = new ScriptEngineManager();
              ScriptEngine js = factory.getEngineByName("JavaScript");
              Object obj = null;
              try {
                  obj = js.eval("function f(a){println(a);return a;}");
                  obj = js.eval("f(1)");
              } catch (ScriptException e){
                  System.out.printf("exception %s\n",e);
              }
          }
      }

      results in

      exception javax.script.ScriptException: ReferenceError: "println" is not defined in <eval> at line number 1

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: