public sealed interface Annotation
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.
| Modifier and Type | Method | Description |
|---|---|---|
Utf8Entry |
className() |
Returns the constant pool entry holding the descriptor string of the annotation interface. |
default ClassDesc |
classSymbol() |
Returns the annotation interface, as a symbolic descriptor. |
List |
elements() |
Returns the element-value pairs of the annotation. |
static Annotation |
of |
Returns an annotation. |
static Annotation |
of |
Returns an annotation. |
static Annotation |
of |
Returns an annotation. |
static Annotation |
of |
Returns an annotation. |
Utf8Entry className()
default ClassDesc classSymbol()
List<AnnotationElement> elements()
static Annotation of(Utf8Entry annotationClass, List<AnnotationElement> elements)
annotationClass - the constant pool entry holding the descriptor string of the annotation interfaceelements - the element-value pairs of the annotationstatic Annotation of(Utf8Entry annotationClass, AnnotationElement... elements)
annotationClass - the constant pool entry holding the descriptor string of the annotation interfaceelements - the element-value pairs of the annotationstatic Annotation of(ClassDesc annotationClass, List<AnnotationElement> elements)
annotationClass - the descriptor of the annotation interfaceelements - the element-value pairs of the annotationstatic Annotation of(ClassDesc annotationClass, AnnotationElement... elements)
annotationClass - the descriptor of the annotation interfaceelements - the element-value pairs of the annotation
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/classfile/Annotation.html