Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-5586

Cannot use "print" or "println" with javascript script macro on JDK6

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Major
    • None
    • 2.5 RC1
    • Scripting
    • Java 1.6
    • javascript rhino script jsr223
    • Unknown
    • N/A
    • N/A

    Description

      Example:

      {{script language="javascript"}}
      print('hello')
      {{/script}}
      

      The macro will fail with:

      Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function print. (print#8) in print at line number 8
      	at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:110)
      	at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:124)
      	at org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.eval(AbstractJSR223ScriptMacro.java:277)
      

      Though, the "print" and "println" functions appear to be present in the script scope. Dumping all scope objects to the console with

      for (thing in this) {
         java.lang.System.out.println(thing);
         java.lang.System.out.println(this[thing]);
      }
      

      shows both functions :

      ...
      print
      sun.org.mozilla.javascript.internal.InterpretedFunction@602dce20
      ...
      println
      sun.org.mozilla.javascript.internal.InterpretedFunction@6d9c83b2
      ...
      

      Attachments

        Issue Links

          Activity

            People

              enygma Eduard Moraru
              jerome Jerome Velociter
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: