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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.5 RC1
    • Fix Version/s: None
    • Component/s: Scripting
    • Labels:
    • Environment:
      Java 1.6
    • keywords:
      javascript rhino script jsr223
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      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

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response: