Java Reference
In-Depth Information
It is a compile-time error if the type of the element is not commensurate (§ 9.7 ) with the
default value specified.
Example 9.6.2-1. Annotation Type Declaration With Default Values
Click here to view code image
@interface RequestForEnhancementDefault {
int id(); // No default - must be specified in
// each annotation
String synopsis(); // No default - must be specified in
// each annotation
String engineer() default "[unassigned]";
String date()
default "[unimplemented]";
}
9.6.3. Predefined Annotation Types
Several annotation types are predefined in the libraries of the Java SE platform. Some of
these predefined annotation types have special semantics. These semantics are specified
in this section. This section does not provide a complete specification for the predefined
annotations contained here in; that is the role of the appropriate API specifications. Only
those semantics that require special behavior on the part of a Java compiler or Java Virtual
Machine implementation are specified here.
9.6.3.1. @Target
The annotation type java.lang.annotation.Target is intended to be used in meta-annotations that
indicate the kind of program element that an annotation type is applicable to.
java.lang.annotation.Target has one element, of type java.lang.annotation.ElementType[] .
It is a compile-time error if a given enum constant appears more than once in an annotation
whose corresponding type is java.lang.annotation.Target .
See § 7.4.1 , § 8.1.1 , § 8.3.1 , § 8.4.1 , § 8.4.3 , § 8.8.3 , § 8.9 , § 9.1.1 , § 9.3 , § 9.4 , § 9.6 and
§ 14.4 for the other effects of java.lang.annotation.Target annotations.
9.6.3.2. @Retention
Annotations may be present only in source code, or they may be present in the binary form
of a class or interface. An annotation that is present in the binary form may or may not be
available at run time via the reflection libraries of the Java SE platform. The annotation
type java.lang.annotation.Retention is used to choose among these possibilities.
Search WWH ::




Custom Search