Interface Annotation
public sealed interface Annotation
Annotation is a preview API of the Java platform.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models an
annotation structure (JVMS 4.7.16) or part of a
type_annotation structure (JVMS 4.7.20). This model indicates the
interface of the annotation and a set of element-value pairs.
This model can reconstruct an annotation, given the location of the modeled structure in the class file and the definition of the annotation interface.
Two Annotation objects should be compared using the equals method.
- API Note:
- For Java programs, the location of the modeled structure indicates the source code element or type (JLS 9.7.4) on which the reconstructed annotation appears, and the annotation interface definition determines whether the reconstructed annotation has elements with default values (JLS 9.6.2), and whether the reconstructed annotation is a container annotation for multiple annotations (JLS 9.7.5).
- Since:
- 22
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the constant pool entry holding the descriptor string of the annotation interface.default ClassDescReturns the annotation interface, as a symbolic descriptor.elements()Returns the element-value pairs of the annotation.static AnnotationPREVIEWof(Utf8EntryPREVIEW annotationClass, AnnotationElementPREVIEW... elements) Returns an annotation.static AnnotationPREVIEWReturns an annotation.static AnnotationPREVIEWof(ClassDesc annotationClass, AnnotationElementPREVIEW... elements) Returns an annotation.static AnnotationPREVIEWof(ClassDesc annotationClass, List<AnnotationElementPREVIEW> elements) Returns an annotation.
-
Method Details
-
className
Returns the constant pool entry holding the descriptor string of the annotation interface.- Returns:
- the constant pool entry holding the descriptor string of the annotation interface
-
classSymbol
Returns the annotation interface, as a symbolic descriptor.- Returns:
- the annotation interface, as a symbolic descriptor
-
elements
List<AnnotationElementPREVIEW> elements()Returns the element-value pairs of the annotation.- Returns:
- the element-value pairs of the annotation
-
of
static AnnotationPREVIEW of(Utf8EntryPREVIEW annotationClass, List<AnnotationElementPREVIEW> elements) Returns an annotation.- Parameters:
annotationClass- the constant pool entry holding the descriptor string of the annotation interfaceelements- the element-value pairs of the annotation- Returns:
- an annotation
-
of
Returns an annotation.- Parameters:
annotationClass- the constant pool entry holding the descriptor string of the annotation interfaceelements- the element-value pairs of the annotation- Returns:
- an annotation
-
of
Returns an annotation.- Parameters:
annotationClass- the descriptor of the annotation interfaceelements- the element-value pairs of the annotation- Returns:
- an annotation
-
of
Returns an annotation.- Parameters:
annotationClass- the descriptor of the annotation interfaceelements- the element-value pairs of the annotation- Returns:
- an annotation
-
Annotationwhen preview features are enabled.