I want to annotate some fields of this bean class with the following annotation:
@Target({FIELD}) @Retention(RUNTIME) public @interface Process { Class<? extends ProcessingStrategy> using() default DefaultImplStrategy.class; }
Without going into too much scope, each annotated property must have a ProcessStrategy defined on it, hence the use () property in the annotation. This is great and works as I would like.
I also want to indicate the default implementation of the strategy that will be used most of the time (the default value is defined below). This works great in Eclipse.
However, when I try to compile this using a regular JDK (called via maven), I get the following error:
found : java.lang.Class<DefaultImplStrategy> required: java.lang.Class<? extends ProcessingStrategy>
I guess this is a combination of generics, annotations, class literature and defaults that are to blame here, but I honestly don't know why. I looked at the rules associated with default values ββin JLS, and I seem to be breaking nothing.
Given that DefaultImplStrategy definitely implements ProcessingStrategy, what am I doing wrong here?
java generics annotations
Garyf
source share