Java Reference
In-Depth Information
For example, annotation types share the same namespace as ordinary class and inter-
face types; and annotation type declarations are legal wherever interface declarations
are legal, and have the same scope and accessibility.
9.6.1. Annotation Type Elements
Each method declaration in an annotation type declaration defines an element of the an-
notation type.
Annotation types can have zero or more elements. An annotation type has no elements oth-
er than those defined by the methods it explicitly declares.
AnnotationTypeElementDeclaration:
AbstractMethodModifiers opt Type Identifier ( ) Dims opt DefaultValue opt ;
ConstantDeclaration
ClassDeclaration
InterfaceDeclaration
EnumDeclaration
AnnotationTypeDeclaration
;
DefaultValue:
default ElementValue
By virtue of the AnnotationTypeElementDeclaration syntax, a method declaration in
an annotation type declaration cannot have any formal parameters or type parameters,
or a throws clause.
By convention, no AbstractMethodModifiers should be present on an annotation type
element except for annotations.
Example 9.6.1-1. Annotation Type Declarations
The following annotation type declaration defines an annotation type with several ele-
ments:
Click here to view code image
/**
* Describes the "request-for-enhancement" (RFE)
* that led to the presence of the annotated API element.
*/
@interface RequestForEnhancement {
int id();
// Unique ID number associated with RFE
Search WWH ::




Custom Search