New issue 331 by innekattens: Cannot invoke method plus() on null object
http://code.google.com/p/groovypptest/issues/detail?id=331
Hi,
decaring a variable=0 seem to end up in variable being declared as null
object when using, groovy-plus-plus-0.4.101
Try this code and see if 0 is printed out.
@Typed public class Test{
public static void main(def str){
int i=0
println i
}
}
---------------------
Here is a snippet from my code
int index=0
...
headerLines.each{
...
index++
}
And here is the exception
Exception in thread "Thread-38" java.lang.NullPointerException: Cannot
invoke method plus() on null object
at
org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at
org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at StreamForwarder$_run_closure1.doCall(StreamForwarder.groovy:99)
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:597)
at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
at
groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1070)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at groovy.lang.Closure.call(Closure.java:276)
at groovy.lang.Closure.call(Closure.java:289)
at
org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1198)
at
org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1174)
at org.codehaus.groovy.runtime.dgm$109.invoke(Unknown Source)
at
org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:270)
at
org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at StreamForwarder.run(StreamForwarder.groovy:66)
at java.lang.Thread.run(Thread.java:662)
I am not sure I understand the problem. For me first code snippet does
print 0.
Stacktrace of second snippet shows that the code dispatched dynamically.
I am afraid we need something more reproducable.
Comment #2 on issue 331 by roshandawrani: Cannot invoke method plus() on
null object
http://code.google.com/p/groovypptest/issues/detail?id=331
Since there is no code here that reproduces the problem, I am closing this
issue. Please fill a new issue with clear steps to reproduce it if you
observe the issue again. Thanks.