1 *java.lang.annotation.Target* *Target* Indicates the kinds of program element to
3 public interface class Target
5 implements |java.lang.annotation.Annotation|
7 |java.lang.annotation.Target_Description|
8 |java.lang.annotation.Target_Fields|
9 |java.lang.annotation.Target_Constructors|
10 |java.lang.annotation.Target_Methods|
12 ================================================================================
14 *java.lang.annotation.Target_Description*
16 Indicates the kinds of program element to which an annotation type is
17 applicable. If a Target meta-annotation is not present on an annotation type
18 declaration, the declared type may be used on any program element. If such a
19 meta-annotation is present, the compiler will enforce the specified usage
22 For example, this meta-annotation indicates that the declared type is itself a
23 meta-annotation type. It can only be used on annotation type declarations:
25 Target(ElementType.ANNOTATION_TYPE) public interface MetaAnnotationType { ... }
27 This meta-annotation indicates that the declared type is intended solely for
28 use as a member type in complex annotation type declarations. It cannot be used
29 to annotate anything directly:
31 Target({}) public interface MemberType { ... }
33 It is a compile-time error for a single ElementType constant to appear more
34 than once in a Target annotation. For example, the following meta-annotation is
37 Target({ElementType.FIELD, ElementType.METHOD, ElementType.FIELD}) public
38 interface Bogus { ... }