groovy

Linenumber for exception during script execution is not reported

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5.4
  • Fix Version/s: 1.5.5
  • Component/s: None
  • Labels:
    None
  • Environment:
    Groovy 1.5.4
  • Number of attachments :
    0

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

Activity

Hide
blackdrag blackdrag added a comment -

to make it more clear.. the second script is probably Closure.groovy, a lin with ScriptXY.groovy is missing. From the trace it looks as if the MissingPropertyException was somehwere catched and a new Exception was thrown. This should not happen, because the line information is lost that way!

Show
blackdrag blackdrag added a comment - to make it more clear.. the second script is probably Closure.groovy, a lin with ScriptXY.groovy is missing. From the trace it looks as if the MissingPropertyException was somehwere catched and a new Exception was thrown. This should not happen, because the line information is lost that way!
Hide
blackdrag blackdrag added a comment -

looks like this issue does not happen for current 1.6

Show
blackdrag blackdrag added a comment - looks like this issue does not happen for current 1.6
Hide
blackdrag blackdrag added a comment -

fixed

Show
blackdrag blackdrag added a comment - fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: