Java Reference
In-Depth Information
There are further restrictions on the form of an annotation type. An an-
notation type may not explicitly declare that it extends another inter-
face, but all annotation types implicitly extend the interface Annotation .
An annotation type is not allowed to be a generic type. Finally, an an-
notation type is not allowed to directly, or indirectly, have an element of
its own type. [3]
[3] This restriction is aimed at preventing the possibility of infinite recursion if an annotation type had
an element of its own type with a default value. Curiously, there are no attempts to prevent a similar
infinite recursion with class types.
If an interface explicitly extends Annotation it is not an annotation
typeand Annotation itself is not an annotation type. Similarly, if an in-
terface declares that it extends an annotation type, that interface is not
itself an annotation type. Extending or implementing an annotation type
is pointless, but if you do it, the annotation type is just a plain interface
with the declared set of methods (including those inherited from Annota-
tion ).
Finally, just like any other interface, an annotation type can declare con-
stants and (implicitly static) nested types.
 
 
Search WWH ::




Custom Search