Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6-beta-2
-
None
-
None
Description
Currently, in 1.6 and 1.7, it is not possible to define annotations whose target elements don't include ElementType.TYPE.
So the following example will not compile, saying that it's not allowed on TYPE.
@Retention(RUNTIME)
@Target([METHOD, FIELD])
@interface MyAnnotation { }
The check of target is done on the annotation definition itself, although it should apply only to the elements which are annotated themselves.
Another example of annotation definition that couldn't compile in Groovy 1.6/1.7 is the @OneToMany annotation of JPA:
import java.lang.annotation.* import static java.lang.annotation.RetentionPolicy.* import static java.lang.annotation.ElementType.* enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH } @Retention(RUNTIME) @Target([METHOD, FIELD]) @interface OneToMany { CascadeType[] cascade() // ... etc ... }