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

ScriptEngineFactory.getOutputStatement(String) does not confirm to spec

    XMLWordPrintable

Details

    • b85
    • generic
    • generic

    Description

      Section SCR.4.3.5.2 of the spec is about "Script Generation Methods". javascript engine in Mustang does not confirm to this section. When the following test is run: (file test.js)

        var m = new Packages.javax.script.ScriptEngineManager();
        var f = m.getEngineFactories().get(0);
        print(f.getLanguageName());
        var e = f.getScriptEngine();
        print(f.getOutputStatement("foo"));
        e.eval(f.getOutputStatement("foo"));

      we get the following output:

      $ jrunscript test.js
      ECMAScript
      print(foo)
      script error in file test.js : sun.org.mozilla.javascript.internal.WrappedException: Wrapped javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "foo" is not defined. (<Unknown source>#1) in <Unknown source> at line number 1 (test.js#6) in test.js at line number 6

      As per the spec, it should just print "foo". I.e. getOutputStatement should in this case return "print(\"foo\")", not "print(foo)".

      A related issue is that whether the newline that gets printed after the string by the print function is OK or not. The spec doesn't mention it. getOutputStatement("foo") should emit the three characters "f", "o", "o", not four (those three plus "\n").

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: