Best done with examples. Bare with me..
Let's supposed i have this interface:
public interface MyInterface {
void doStuff();
}
With a concrete implementation:
public class HardCoreConcrete implements MyInterface {
void doStuff() {
// i really do stuff, honest
}
}
And suppose i have this annotation:
@Target(ElementType.class)
@Retension(RetensionPolicy.RUNTIME)
public @interface MyAnnotation {
Class<MyInterface> clazz;
}
It would be used like this:
@MyAnnotation(clazz = HardCoreConcrete.class)
public class SomeotherClass {
...
}
Why does this not work? My compiler complains that for clazz it expected type MyInterface! But HardCoreConcrete implements MyInterface.
Am I doing something wrong? Is this not allowed? Am i out of luck?