Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-912

The class RhinoClassShutter disables instantiation of org.mozilla.javascript.EcmaError preventing handling of certain Javascript errors

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 1.7
    • Fix Version/s: None
    • Component/s: Scripting
    • Labels:
      None
    • Environment:
      Operating System: Mac OS X 10.4
      Platform: All

      Description

      I have a block of Javascript code that does something like:

      try {
      //reference some undeclared variable
      } catch (e) {}

      This causes Rhino to generate an EcmaError, which it then tries to wrap in a Java object. However the RhinoClassShutter prevents accessing all rhino classes (for good reason) including the EcmaError class, thereby negating the usefulness of try/catch.

      Perhaps the RhinoClassShutter should allow exception/error classes to be referenced/instantiated even if they are in the org.mozilla.javascript package. The only work around (other than making sure the Javascript never generates an EcmaError) seems to be to replace RhinoInterpreterFactory with your own, just to override the RhinoClassShutter, which has some more quirks if you are using the batik jars (which also install the RhinoInterpreterFactory).

      Access to Java class "org.mozilla.javascript.EcmaError" is prohibited. (Inline <script> http://....:-1#4)
      at org.apache.batik.transcoder.SVGAbstractTranscoder$SVGAbstractTranscoderUserAgent.displayError(SVGAbstractTranscoder.java:863)
      at org.apache.batik.bridge.BaseScriptingEnvironment.handleInterpreterException(BaseScriptingEnvironment.java:694)
      at org.apache.batik.bridge.BaseScriptingEnvironment.loadScripts(BaseScriptingEnvironment.java:522)
      at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:214)
      at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:92)
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142)
      at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)

        Attachments

          Activity

            People

            • Assignee:
              batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
              Reporter:
              vgoenka@apache.org Vishal Goenka
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: