Consider this code:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Bar {
Foo foo() default FooImpl.FooConstant;
}
Compiler error:
annotation value not of an allowable type
If I replace Foo with FooImpl the code is accepted.
What’s the reason for this behavior?
I would be very surprised if this compiled, unless FooImpl is an enum.
Annotation members may only contain the following:
Source: JLS