Some Restrictions
There are a number of restrictions that apply to annotation declarations. First, no annotation
can inherit another. Second, all methods declared by an annotation must be without parameters.
Furthermore, they must return one of the following:
- A primitive type, such asintordouble
- An object of typeStringorClass
- Anenumtype
- Another annotation type
- An array of one of the preceding types
Annotations cannot be generic. In other words, they cannot take type parameters. (Generics
are described in Chapter 14.) Finally, annotation methods cannot specify athrowsclause.
284 Part I: The Java Language