W3cubDocs

/OpenJDK 25

Interface AnnotationValue

All Known Subinterfaces:
AnnotationValue.OfAnnotation, AnnotationValue.OfArray, AnnotationValue.OfBoolean, AnnotationValue.OfByte, AnnotationValue.OfChar, AnnotationValue.OfClass, AnnotationValue.OfConstant, AnnotationValue.OfDouble, AnnotationValue.OfEnum, AnnotationValue.OfFloat, AnnotationValue.OfInt, AnnotationValue.OfLong, AnnotationValue.OfShort, AnnotationValue.OfString
public sealed interface AnnotationValue permits AnnotationValue.OfAnnotation, AnnotationValue.OfArray, AnnotationValue.OfConstant, AnnotationValue.OfClass, AnnotationValue.OfEnum
Models an element_value structure, or a value of an element-value pair of an annotation, as defined in JVMS 4.7.16.1.

Two AnnotationValue objects should be compared using the equals method.

Sealed Class Hierarchy Graph:
Sealed class hierarchy graph for AnnotationValueSealed class hierarchy graph for AnnotationValue
Since:
24
See Also:

Nested Class Summary

Modifier and Type Interface Description
static interface  AnnotationValue.OfAnnotation
Models an annotation value of an element-value pair.
static interface  AnnotationValue.OfArray
Models an array value of an element-value pair.
static interface  AnnotationValue.OfBoolean
Models a boolean value of an element-value pair.
static interface  AnnotationValue.OfByte
Models a byte value of an element-value pair.
static interface  AnnotationValue.OfChar
Models a char value of an element-value pair.
static interface  AnnotationValue.OfClass
Models a class value of an element-value pair.
static interface  AnnotationValue.OfConstant
Models a constant value of an element-value pair.
static interface  AnnotationValue.OfDouble
Models a double value of an element-value pair.
static interface  AnnotationValue.OfEnum
Models an enum value of an element-value pair.
static interface  AnnotationValue.OfFloat
Models a float value of an element-value pair.
static interface  AnnotationValue.OfInt
Models an int value of an element-value pair.
static interface  AnnotationValue.OfLong
Models a long value of an element-value pair.
static interface  AnnotationValue.OfShort
Models a short value of an element-value pair.
static interface  AnnotationValue.OfString
Models a string value of an element-value pair.

Field Summary

Modifier and Type Field Description
static final int TAG_ANNOTATION
The tag indicating the value of an element-value pair is AnnotationValue.OfAnnotation.
static final int TAG_ARRAY
The tag indicating the value of an element-value pair is AnnotationValue.OfArray.
static final int TAG_BOOLEAN
The tag indicating the value of an element-value pair is AnnotationValue.OfBoolean.
static final int TAG_BYTE
The tag indicating the value of an element-value pair is AnnotationValue.OfByte.
static final int TAG_CHAR
The tag indicating the value of an element-value pair is AnnotationValue.OfChar.
static final int TAG_CLASS
The tag indicating the value of an element-value pair is AnnotationValue.OfClass.
static final int TAG_DOUBLE
The tag indicating the value of an element-value pair is AnnotationValue.OfDouble.
static final int TAG_ENUM
The tag indicating the value of an element-value pair is AnnotationValue.OfEnum.
static final int TAG_FLOAT
The tag indicating the value of an element-value pair is AnnotationValue.OfFloat.
static final int TAG_INT
The tag indicating the value of an element-value pair is AnnotationValue.OfInt.
static final int TAG_LONG
The tag indicating the value of an element-value pair is AnnotationValue.OfLong.
static final int TAG_SHORT
The tag indicating the value of an element-value pair is AnnotationValue.OfShort.
static final int TAG_STRING
The tag indicating the value of an element-value pair is AnnotationValue.OfString.

Method Summary

Modifier and Type Method Description
static AnnotationValue of(Object value)
Returns an annotation element.
static AnnotationValue.OfAnnotation ofAnnotation(Annotation value)
Returns an annotation value for an element-value pair.
static AnnotationValue.OfArray ofArray(AnnotationValue... values)
Returns an array value for an element-value pair.
static AnnotationValue.OfArray ofArray(List<AnnotationValue> values)
Returns an array value for an element-value pair.
static AnnotationValue.OfBoolean ofBoolean(boolean value)
Returns a boolean value for an element-value pair.
static AnnotationValue.OfBoolean ofBoolean(IntegerEntry value)
Returns a boolean value for an element-value pair.
static AnnotationValue.OfByte ofByte(byte value)
Returns a byte value for an element-value pair.
static AnnotationValue.OfByte ofByte(IntegerEntry value)
Returns a byte value for an element-value pair.
static AnnotationValue.OfChar ofChar(char value)
Returns a char value for an element-value pair.
static AnnotationValue.OfChar ofChar(IntegerEntry value)
Returns a char value for an element-value pair.
static AnnotationValue.OfClass ofClass(Utf8Entry className)
Returns a class value for an element-value pair.
static AnnotationValue.OfClass ofClass(ClassDesc className)
Returns a class value for an element-value pair.
static AnnotationValue.OfDouble ofDouble(double value)
Returns a double value for an element-value pair.
static AnnotationValue.OfDouble ofDouble(DoubleEntry value)
Returns a double value for an element-value pair.
static AnnotationValue.OfEnum ofEnum(Utf8Entry className, Utf8Entry constantName)
Returns an enum value for an element-value pair.
static AnnotationValue.OfEnum ofEnum(ClassDesc className, String constantName)
Returns an enum value for an element-value pair.
static AnnotationValue.OfFloat ofFloat(float value)
Returns a float value for an element-value pair.
static AnnotationValue.OfFloat ofFloat(FloatEntry value)
Returns a float value for an element-value pair.
static AnnotationValue.OfInt ofInt(int value)
Returns an int value for an element-value pair.
static AnnotationValue.OfInt ofInt(IntegerEntry value)
Returns an int value for an element-value pair.
static AnnotationValue.OfLong ofLong(long value)
Returns a long value for an element-value pair.
static AnnotationValue.OfLong ofLong(LongEntry value)
Returns a long value for an element-value pair.
static AnnotationValue.OfShort ofShort(short value)
Returns a short value for an element-value pair.
static AnnotationValue.OfShort ofShort(IntegerEntry value)
Returns a short value for an element-value pair.
static AnnotationValue.OfString ofString(Utf8Entry value)
Returns a string value for an element-value pair.
static AnnotationValue.OfString ofString(String value)
Returns a string value for an element-value pair.
int tag()
Returns the tag character for this value as per JVMS 4.7.16.1.

Field Details

TAG_BYTE

static final int TAG_BYTE
The tag indicating the value of an element-value pair is AnnotationValue.OfByte.
See Also:

TAG_CHAR

static final int TAG_CHAR
The tag indicating the value of an element-value pair is AnnotationValue.OfChar.
See Also:

TAG_DOUBLE

static final int TAG_DOUBLE
The tag indicating the value of an element-value pair is AnnotationValue.OfDouble.
See Also:

TAG_FLOAT

static final int TAG_FLOAT
The tag indicating the value of an element-value pair is AnnotationValue.OfFloat.
See Also:

TAG_INT

static final int TAG_INT
The tag indicating the value of an element-value pair is AnnotationValue.OfInt.
See Also:

TAG_LONG

static final int TAG_LONG
The tag indicating the value of an element-value pair is AnnotationValue.OfLong.
See Also:

TAG_SHORT

static final int TAG_SHORT
The tag indicating the value of an element-value pair is AnnotationValue.OfShort.
See Also:

TAG_BOOLEAN

static final int TAG_BOOLEAN
The tag indicating the value of an element-value pair is AnnotationValue.OfBoolean.
See Also:

TAG_STRING

static final int TAG_STRING
The tag indicating the value of an element-value pair is AnnotationValue.OfString.
See Also:

TAG_ENUM

static final int TAG_ENUM
The tag indicating the value of an element-value pair is AnnotationValue.OfEnum.
See Also:

TAG_CLASS

static final int TAG_CLASS
The tag indicating the value of an element-value pair is AnnotationValue.OfClass.
See Also:

TAG_ANNOTATION

static final int TAG_ANNOTATION
The tag indicating the value of an element-value pair is AnnotationValue.OfAnnotation.
See Also:

TAG_ARRAY

static final int TAG_ARRAY
The tag indicating the value of an element-value pair is AnnotationValue.OfArray.
See Also:

Method Details

tag

int tag()
Returns the tag character for this value as per JVMS 4.7.16.1. The tag characters have a one-to-one mapping to the types of annotation element values.
API Note:
TAG_-prefixed constants in this class, such as TAG_INT, describe the possible return values of this method. The return type is int for consistency with union indicator items in other union structures in the class file format.
Returns:
the tag character for this value as per JVMS 4.7.16.1

ofEnum

static AnnotationValue.OfEnum ofEnum(Utf8Entry className, Utf8Entry constantName)
Returns an enum value for an element-value pair.
Parameters:
className - the descriptor string of the enum class
constantName - the name of the enum constant
Returns:
an enum value for an element-value pair

ofEnum

static AnnotationValue.OfEnum ofEnum(ClassDesc className, String constantName)
Returns an enum value for an element-value pair.
Parameters:
className - the descriptor of the enum class
constantName - the name of the enum constant
Returns:
an enum value for an element-value pair

ofClass

static AnnotationValue.OfClass ofClass(Utf8Entry className)
Returns a class value for an element-value pair.
Parameters:
className - the descriptor string of the class
Returns:
a class value for an element-value pair

ofClass

static AnnotationValue.OfClass ofClass(ClassDesc className)
Returns a class value for an element-value pair.
Parameters:
className - the descriptor of the class
Returns:
a class value for an element-value pair

ofString

static AnnotationValue.OfString ofString(Utf8Entry value)
Returns a string value for an element-value pair.
Parameters:
value - the string
Returns:
a string value for an element-value pair

ofString

static AnnotationValue.OfString ofString(String value)
Returns a string value for an element-value pair.
Parameters:
value - the string
Returns:
a string value for an element-value pair

ofDouble

static AnnotationValue.OfDouble ofDouble(DoubleEntry value)
Returns a double value for an element-value pair.
Parameters:
value - the double value
Returns:
a double value for an element-value pair

ofDouble

static AnnotationValue.OfDouble ofDouble(double value)
Returns a double value for an element-value pair.
Parameters:
value - the double value
Returns:
a double value for an element-value pair

ofFloat

static AnnotationValue.OfFloat ofFloat(FloatEntry value)
Returns a float value for an element-value pair.
Parameters:
value - the float value
Returns:
a float value for an element-value pair

ofFloat

static AnnotationValue.OfFloat ofFloat(float value)
Returns a float value for an element-value pair.
Parameters:
value - the float value
Returns:
a float value for an element-value pair

ofLong

static AnnotationValue.OfLong ofLong(LongEntry value)
Returns a long value for an element-value pair.
Parameters:
value - the long value
Returns:
a long value for an element-value pair

ofLong

static AnnotationValue.OfLong ofLong(long value)
Returns a long value for an element-value pair.
Parameters:
value - the long value
Returns:
a long value for an element-value pair

ofInt

static AnnotationValue.OfInt ofInt(IntegerEntry value)
Returns an int value for an element-value pair.
Parameters:
value - the int value
Returns:
an int value for an element-value pair

ofInt

static AnnotationValue.OfInt ofInt(int value)
Returns an int value for an element-value pair.
Parameters:
value - the int value
Returns:
an int value for an element-value pair

ofShort

static AnnotationValue.OfShort ofShort(IntegerEntry value)
Returns a short value for an element-value pair.
Parameters:
value - the short value
Returns:
a short value for an element-value pair

ofShort

static AnnotationValue.OfShort ofShort(short value)
Returns a short value for an element-value pair.
Parameters:
value - the short value
Returns:
a short value for an element-value pair

ofChar

static AnnotationValue.OfChar ofChar(IntegerEntry value)
Returns a char value for an element-value pair.
Parameters:
value - the char value
Returns:
a char value for an element-value pair

ofChar

static AnnotationValue.OfChar ofChar(char value)
Returns a char value for an element-value pair.
Parameters:
value - the char value
Returns:
a char value for an element-value pair

ofByte

static AnnotationValue.OfByte ofByte(IntegerEntry value)
Returns a byte value for an element-value pair.
Parameters:
value - the byte value
Returns:
a byte value for an element-value pair

ofByte

static AnnotationValue.OfByte ofByte(byte value)
Returns a byte value for an element-value pair.
Parameters:
value - the byte value
Returns:
a byte value for an element-value pair

ofBoolean

static AnnotationValue.OfBoolean ofBoolean(IntegerEntry value)
Returns a boolean value for an element-value pair.
Parameters:
value - the boolean value
Returns:
a boolean value for an element-value pair

ofBoolean

static AnnotationValue.OfBoolean ofBoolean(boolean value)
Returns a boolean value for an element-value pair.
Parameters:
value - the boolean value
Returns:
a boolean value for an element-value pair

ofAnnotation

static AnnotationValue.OfAnnotation ofAnnotation(Annotation value)
Returns an annotation value for an element-value pair.
Parameters:
value - the annotation
Returns:
an annotation value for an element-value pair

ofArray

static AnnotationValue.OfArray ofArray(List<AnnotationValue> values)
Returns an array value for an element-value pair.
API Note:
See values() for conventions on array values derived from Java source code.
Parameters:
values - the array elements
Returns:
an array value for an element-value pair

ofArray

static AnnotationValue.OfArray ofArray(AnnotationValue... values)
Returns an array value for an element-value pair.
API Note:
See values() for conventions on array values derived from Java source code.
Parameters:
values - the array elements
Returns:
an array value for an element-value pair

of

static AnnotationValue of(Object value)
Returns an annotation element. The value parameter must be a primitive, a wrapper of primitive, a String, a ClassDesc, an enum constant, or an array of one of these.
Parameters:
value - the annotation value
Returns:
an annotation element
Throws:
IllegalArgumentException - when the value parameter is not a primitive, a wrapper of primitive, a String, a ClassDesc, an enum constant, or an array of one of these.

© 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/AnnotationValue.html