Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.4.0
-
None
Description
@CompileStatic with in the following code causes NPE in TypeResolver.
@CompileStatic class ClosureInEachWithCompileStaticIssue { <T> T tryToExecuteWithFreePort(Closure<T> closure) { [1].each { return executeLogicForAvailablePort(closure) } } private <T> T executeLogicForAvailablePort(Closure<T> closure) { return closure.call() } static void main(String[] args) { new ClosureInEachWithCompileStaticIssue().executeLogicForAvailablePort { } } }
Exception in thread "main" java.lang.NullPointerException
at com.sun.beans.TypeResolver.resolve(TypeResolver.java:203)
at com.sun.beans.TypeResolver.resolve(TypeResolver.java:218)
at com.sun.beans.TypeResolver.resolve(TypeResolver.java:169)
at com.sun.beans.TypeResolver.resolve(TypeResolver.java:218)
at com.sun.beans.TypeResolver.resolveInClass(TypeResolver.java:96)
at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387)
at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:116)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:72)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:56)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1163)
at java.beans.Introspector.getBeanInfo(Introspector.java:426)
at java.beans.Introspector.getBeanInfo(Introspector.java:173)
at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:3290)
at java.security.AccessController.doPrivileged(Native Method)
at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3288)
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3264)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:251)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:282)
at info.solidsoft.rnd.issue.ClosureInEachWithCompileStaticIssue.$getStaticMetaClass(ClosureInEachWithCompileStaticIssue.groovy)
at info.solidsoft.rnd.issue.ClosureInEachWithCompileStaticIssue.<init>(ClosureInEachWithCompileStaticIssue.groovy)
at info.solidsoft.rnd.issue.ClosureInEachWithCompileStaticIssue.main(ClosureInEachWithCompileStaticIssue.groovy:19)
It works fine with @TypeChecked. I will provide a failing test case.