Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1522

catch block without explicit exception type results in VerifyError

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-JSR-6
    • 1.1-beta-1
    • bytecode
    • None
    • Windows 2000, JDK 1.6.0 b93 - using Groovy 1.0-jsr-6 through jsr-223 script engine.

    Description

      When I tried the following script:

      try {
      throw new Exception();
      } catch(e) {
      e.printStackTrace();
      }

      I got the following VerifyError:

      Exception in thread "main" java.lang.VerifyError: (class: Script1, method: run s
      ignature: ()Ljava/lang/Object catch_type not a subclass of Throwable
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2388)
      at java.lang.Class.getConstructor0(Class.java:2698)
      at java.lang.Class.newInstance0(Class.java:326)
      at java.lang.Class.newInstance(Class.java:308)
      at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:529)
      at com.sun.script.groovy.GroovyScriptEngine.eval(GroovyScriptEngine.java:190)
      at com.sun.script.groovy.GroovyScriptEngine.eval(GroovyScriptEngine.java:82)
      at com.sun.script.groovy.GroovyScriptEngine.eval(GroovyScriptEngine.java:76)
      at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:232)
      at com.sun.tools.script.shell.Main.evaluateReader(Main.java:314)
      at com.sun.tools.script.shell.Main.evaluateStream(Main.java:350)
      at com.sun.tools.script.shell.Main.processSource(Main.java:267)
      at com.sun.tools.script.shell.Main.access$100(Main.java:19)
      at com.sun.tools.script.shell.Main$2.run(Main.java:182)
      at com.sun.tools.script.shell.Main.main(Main.java:30)

      I suspect that for variable "e" in the catch clause above, "java.lang.Object" type is inferred. Either there should be error that says "use Throwable or subtype in catch clauses" or infer "java.lang.Throwable" as type when type is not specified. The VerifyError would be confusing to developers.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            sundararajan Sundararajan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: