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

Linenumber for exception during script execution is not reported

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.4
    • 1.5.5
    • None
    • None
    • Groovy 1.5.4

    Description

      When executing the following script, groovy gives me the correct line number information (see last line of the stacktrace)

      1    Script script = new GroovyShell().parse(''' 
      2    def a = 1 
      3    def b = 2 
      4    println(unknownMeth()) 
      5    ''') 
      6     
      7    try { 
      8        script.run() 
      9    } catch (Throwable t) { 
      10       t.printStackTrace() 
      11   }
      
      groovy.lang.MissingMethodException: No signature of method: Script1.unknownMeth() is applicable for argument types: () values: {}
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:88)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrent0(ScriptBytecodeAdapter.java:109)
      	at Script1.run(Script1.groovy:4)
      

      Now I change line 4 of the script to an unknown property:

      1    Script script = new GroovyShell().parse(''' 
      2    def a = 1 
      3    def b = 2 
      4    println(unknownProp) 
      5    ''') 
      6     
      7    try { 
      8        script.run() 
      9    } catch (Throwable t) { 
      10       t.printStackTrace() 
      11   }
      

      When executing this, I don't get any line number information in the stacktrace where in the script the missing property is addressed. See stacktrace:

      groovy.lang.MissingPropertyException: No such property: unknownProp for class: Script1
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:59)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:169)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:195)
      	at Closure.run(Closure.groovy:8)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:585)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)
      	at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777)
      	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757)
      	at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:402)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:585)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
      	at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1094)
      	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:748)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
      	at Closure.main(Closure.groovy)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:585)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
      	at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1094)
      	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:748)
      	at groovy.lang.GroovyShell.runMainOrTestOrRunnable(GroovyShell.java:244)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:218)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:147)
      	at groovy.ui.GroovyMain.processOnce(GroovyMain.java:493)
      	at groovy.ui.GroovyMain.run(GroovyMain.java:308)
      	at groovy.ui.GroovyMain.process(GroovyMain.java:294)
      	at groovy.ui.GroovyMain.processArgs(GroovyMain.java:111)
      	at groovy.ui.GroovyMain.main(GroovyMain.java:92)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:585)
      	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:101)
      	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
      
      Process finished with exit code 0
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            hans_d Hans Dockter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: