[
https://issues.apache.org/jira/browse/GROOVY-7709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15072030#comment-15072030
]
ASF GitHub Bot commented on GROOVY-7709:
----------------------------------------
Github user jwagenleitner commented on a diff in the pull request:
https://github.com/apache/groovy/pull/226#discussion_r48451502
--- Diff: src/main/org/codehaus/groovy/runtime/ConversionHandler.java ---
@@ -189,4 +202,15 @@ public static boolean isCoreObjectMethod(Method
method) {
return Object.class.equals(method.getDeclaringClass());
}
+ private MetaClass setMetaClass(MetaClass mc) {
+ metaClass = mc;
+ return mc;
+ }
+
+ private MetaClass getMetaClass(Object proxy) {
+ if (metaClass == null) {
+ metaClass = ((MetaClassRegistryImpl)
GroovySystem.getMetaClassRegistry()).getMetaClass(proxy);
--- End diff --
Not sure if this is the right way to get the `metaClass` for the `Proxy`
object.
> 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)