I want to annotate some of the fields of a given bean class with the following annotation:
@Target({FIELD})
@Retention(RUNTIME)
public @interface Process {
Class<? extends ProcessingStrategy> using() default DefaultImplStrategy.class;
}
Without going into the domain too much, each annotated property needs to have a ProcessingStrategy defined on it, hence the using() property on the annotation. That's fine and works the way I'd like it to.
I also want to specify a default implementation of the strategy, to be used most of the time (the default defined below). This works fine in Eclipse.
However, when I try to compile this using a regular JDK (invoked through maven) I get the following error:
found : java.lang.Class<DefaultImplStrategy>
required: java.lang.Class<? extends ProcessingStrategy>
I'm guessing it's some combination of generics, annotations, class literals and defaulting that are at fault here but I honestly do not know why. I've had a look at the rules around default values in the JLS and I don't seem to be violating anything.
Given that DefaultImplStrategy definitely implements ProcessingStrategy, what am I doing wrong here?