ajwang / groovypptest

Automatically exported from code.google.com/p/groovypptest
0 stars 0 forks source link

Cannot invoke method plus() on null object #331

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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)

Original issue reported on code.google.com by innekatt...@googlemail.com on 21 Dec 2010 at 9:40

GoogleCodeExporter commented 8 years ago
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.

Original comment by alex.tka...@gmail.com on 21 Dec 2010 at 10:16

GoogleCodeExporter commented 8 years ago
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.

Original comment by roshanda...@gmail.com on 8 Jan 2011 at 1:42