Java Reference
In-Depth Information
@Marker
public class Test {
// Code goes here
}
Meta-Annotation Types
Meta-annotations types are annotation types, which are used to annotate other annotation types. The following
annotation types are meta-annotation types:
Target
Retention
Inherited
Documented
Repeatable
Native
Meta-annotation types are part of the Java class library. They are declared in the package java.lang.annotation .
The Target Annotation Type
The Target annotation type is used to annotate an annotation type to specify the context in which the annotation
type can be used. It has only one element named value . Its value element is an array of java.lang.annotation.
ElementType enum type. Table 1-1 lists all constants in the ElementType enum.
Table 1-1. List of Constants in the java.lang.annotation.ElementType enum
Constant Name
Description
ANNOTATION_TYPE
The annotation can be used to annotate another annotation type declaration. This makes the
annotation type a meta-annotation.
CONSTRUCTOR
The annotation can be used to annotate constructors.
FIELD
The annotation can be used to annotate fields and enum constants.
LOCAL_VARIABLE
The annotation can be used to annotate local variables.
METHOD
The annotation can be used to annotate methods.
PACKAGE
The annotation can be used to annotate package declarations.
PARAMETER
The annotation can be used to annotate parameters.
TYPE
The annotation can be used to annotate class, interface (including annotation type), or enum
declarations.
TYPE_PARAMETER
The annotation can be used to annotate type parameters in generic classes, interfaces,
methods, etc. It was added in Java 8.
TYPE_USE
The annotation can be used to annotate all uses of types. It was added in Java 8. The
annotation can also be used where an annotation with ElementType.TYPE and
ElementType.TYPE_PARAMETER can be used. It can also be used before constructors in
which case it represents the objects created by the constructor.
 
Search WWH ::




Custom Search