[ 
https://issues.apache.org/jira/browse/GROOVY-7709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15072013#comment-15072013
 ] 

Shil Sinha edited comment on GROOVY-7709 at 12/26/15 11:41 PM:
---------------------------------------------------------------

Yes, the meta class used to create the PogoMetaClassSite (in 
CallSiteArray#createPogoSite) is the value returned by the closure, which in 
this case will be null. If the closure is changed to \{ 1 \} for example, the 
test will instead fail with:
{code}
java.lang.ClassCastException: java.lang.Integer cannot be cast to 
groovy.lang.MetaClass
{code}


was (Author: shils):
Yes, the meta class used to create the PogoMetaClassSite (in 
CallSiteArray#createPogoSite) is the value returned by the closure, which in 
this case will be null. If the closure is changed to { 1 } for example, the 
test will instead fail with:
{code}
java.lang.ClassCastException: java.lang.Integer cannot be cast to 
groovy.lang.MetaClass
{code}

> NPE with ConvertedClosure
> -------------------------
>
>                 Key: GROOVY-7709
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7709
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.5
>            Reporter: Jochen Theodorou
>
> {code}
> interface Y extends GroovyObject {}
> def cl = {println 1} as Y
> assert cl instanceof GroovyObject
> if (cl) println "!cl"
> {code}
> the code above will cause the execution of the method getMetaClass in the 
> boolean part of the "if". It looks like this code path now produces a NPE
> {code}
> java.lang.NullPointerException
>       at 
> org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:919)
>       at 
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:902)
>       at 
> org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToBoolean(DefaultTypeTransformation.java:185)
>       at 
> org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.booleanUnbox(DefaultTypeTransformation.java:74){code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to