KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When you define a Java interface, it's possible to declare a method with type parameters, for example like this: public interface ExampleInterface { <E extends Enum<E>> Class<E> options(); } The same thing does not work in an annotation. This, for example, is illegal: public @interface ExampleAnnotation { <E extends Enum<E>> Class<E> options(); } I can get what I'm after by using the raw type Enum : public @interface ExampleAnnotation { @SuppressWarnings("rawtypes") Class<? extends Enum> options(); } What exactly is the reason why it is not possible to declare annotation attributes with type parameters?
Tags (comma-separated)
Save Edits
Cancel