Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.8.2
-
None
-
None
-
OpenJDK (All Known Versions)
Description
Example say you have a method like:
def <T> T mockController(Class<T> controllerClass) {
doStuff {
println controllerClass
....
}
}
The closure passed to doStuff contains within its byte code a generated getter called "getControllerClass" with the following type signature:
public Class<T> getControllerClass() { CallSite[] arrayOfCallSite = $getCallSiteArray(); return (Class)ScriptBytecodeAdapter.castToType(this.controllerClass.get(), $get$$class$java$lang$Class()); return null; }
The generic type T is not declared anywhere. This causes exceptions on OpenJDK such as:
java.lang.NullPointerException at com.sun.beans.TypeResolver.resolve(TypeResolver.java:321) at com.sun.beans.TypeResolver.resolve(TypeResolver.java:351) at com.sun.beans.TypeResolver.resolve(TypeResolver.java:310) at com.sun.beans.TypeResolver.resolve(TypeResolver.java:157) at com.sun.beans.TypeResolver.resolveInClass(TypeResolver.java:78) at java.beans.FeatureDescriptor.getReturnType(FeatureDescriptor.java:368) at java.beans.Introspector.getTargetEventInfo(Introspector.java:1020) at java.beans.Introspector.getBeanInfo(Introspector.java:424) at java.beans.Introspector.getBeanInfo(Introspector.java:189) at grails.test.mixin.web.ControllerUnitTestMixin.mockController(ControllerUnitTestMixin.groovy:268)
This issue is the cause of http://jira.grails.org/browse/GRAILS-8031