Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Won't Fix
-
Affects Version/s: 1.5.4
-
Fix Version/s: 1.5.5
-
Component/s: class generator
-
Labels:None
-
Number of attachments :
Description
Given a Java annotation like this:
public @interface Foo { String bar() default ""; }
When used in Groovy on a method:
class Bar {
@Foo
def myMethod() {}
}
The value of the "bar" attribute does not take into account the default value of a blank string and instead returns null when used via reflection. Hence Java code like this will throw an exception:
String foo = ann.bar().length() == 0 ? null : ann.bar();
As the Groovy annotated method returns null. The workaround is to do this:
class Bar {
@Foo(bar="")
def myMethod() {}
}
But that is nasty
setting fix version to 1.6-beta1, because annotation definitions won't go in 1.5.x for now