Interface Utf8Entry
- All Superinterfaces:
AnnotationConstantValueEntry, CharSequence, PoolEntry
public sealed interface Utf8Entry extends CharSequence, AnnotationConstantValueEntry
CONSTANT_UTF8_info constant, representing strings, in the constant pool of a class file. This describes strings in the Modified UTF-8 format. The use of a Utf8Entry is represented by a String. Conversions are through ConstantPoolBuilder.utf8Entry(String) and stringValue().
Some uses of Utf8Entry represent field or method descriptor strings, symbolically represented as ClassDesc or MethodTypeDesc, depending on where a Utf8Entry appear. Entries representing such uses are created with ConstantPoolBuilder.utf8Entry(ClassDesc) and ConstantPoolBuilder.utf8Entry(MethodTypeDesc), and they can be converted to symbolic descriptors on a per-use-site basis, such as in AnnotationValue.OfClass.classSymbol() and MethodModel.methodTypeSymbol().
Unlike most constant pool entries, a UTF-8 entry is of flexible length: it is represented as an array structure, with an u2 for the data length in bytes, followed by that number of bytes of Modified UTF-8 data. It can represent at most 65535 bytes of data due to the physical restrictions of u2.
- See Java Virtual Machine Specification:
- 4.4.7 The
CONSTANT_Utf8_infoStructure
- Since:
- 24
- See Also:
Field Summary
Fields declared in interface PoolEntry
TAG_CLASS, TAG_DOUBLE, TAG_DYNAMIC, TAG_FIELDREF, TAG_FLOAT, TAG_INTEGER, TAG_INTERFACE_METHODREF, TAG_INVOKE_DYNAMIC, TAG_LONG, TAG_METHOD_HANDLE, TAG_METHOD_TYPE, TAG_METHODREF, TAG_MODULE, TAG_NAME_AND_TYPE, TAG_PACKAGE, TAG_STRING, TAG_UTF8 | Modifier and Type | Field | Description |
|---|---|---|
static final int |
TAG_CLASS |
The tag for CONSTANT_Class constant kind. |
static final int |
TAG_DOUBLE |
The tag for CONSTANT_Double constant kind. |
static final int |
TAG_DYNAMIC |
The tag for CONSTANT_Dynamic constant kind. |
static final int |
TAG_FIELDREF |
The tag for CONSTANT_Fieldref constant kind. |
static final int |
TAG_FLOAT |
The tag for CONSTANT_Float constant kind. |
static final int |
TAG_INTEGER |
The tag for CONSTANT_Integer constant kind. |
static final int |
TAG_INTERFACE_METHODREF |
The tag for CONSTANT_InterfaceMethodref constant kind. |
static final int |
TAG_INVOKE_DYNAMIC |
The tag for CONSTANT_InvokeDynamic constant kind. |
static final int |
TAG_LONG |
The tag for CONSTANT_Long constant kind. |
static final int |
TAG_METHOD_HANDLE |
The tag for CONSTANT_MethodHandle constant kind. |
static final int |
TAG_METHOD_TYPE |
The tag for CONSTANT_MethodType constant kind. |
static final int |
TAG_METHODREF |
The tag for CONSTANT_Methodref constant kind. |
static final int |
TAG_MODULE |
The tag for CONSTANT_Module constant kind. |
static final int |
TAG_NAME_AND_TYPE |
The tag for CONSTANT_NameAndType constant kind. |
static final int |
TAG_PACKAGE |
The tag for CONSTANT_Package constant kind. |
static final int |
TAG_STRING |
The tag for CONSTANT_String constant kind. |
static final int |
TAG_UTF8 |
The tag for CONSTANT_Utf8 constant kind. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
equalsString |
Returns whether this entry describes the same string as the provided string. |
boolean |
isFieldType |
Returns whether this entry describes the descriptor string of this field type. |
boolean |
isMethodType |
Returns whether this entry describes the descriptor string of this method type. |
String |
stringValue() |
Returns the string value for this entry. |
Methods declared in interface AnnotationConstantValueEntry
constantValue | Modifier and Type | Method | Description |
|---|---|---|
ConstantDesc |
constantValue() |
Returns the constant value. |
Methods declared in interface CharSequence
charAt, chars, codePoints, getChars, isEmpty, length, subSequence, toString | Modifier and Type | Method | Description |
|---|---|---|
char |
charAt |
Returns the char value at the specified index. |
default IntStream |
chars() |
Returns a stream of int zero-extending the char values from this sequence. |
default IntStream |
codePoints() |
Returns a stream of code point values from this sequence. |
default void |
getChars |
Copies characters from this sequence into the given destination array. |
default boolean |
isEmpty() |
Returns true if this character sequence is empty. |
int |
length() |
Returns the length of this character sequence. |
CharSequence |
subSequence |
Returns a CharSequence that is a subsequence of this sequence. |
String |
toString() |
Returns a string containing the characters in this sequence in the same order as this sequence. |
Methods declared in interface PoolEntry
constantPool, index, tag, width | Modifier and Type | Method | Description |
|---|---|---|
ConstantPool |
constantPool() |
Returns the constant pool this entry is from. |
int |
index() |
Returns the index within the constant pool corresponding to this entry. |
int |
tag() |
Returns the constant pool tag that describes the type of this entry. |
int |
width() |
Returns the number of constant pool slots this entry consumes. |
Method Details
stringValue
String stringValue()
- API Note:
- A
Utf8Entrycan be used directly as aCharSequenceifStringfunctionalities are not strictly desired. If only string equivalence is desired,equalsStringshould be used. Reduction of string processing can significantly improveclassfile reading performance. - Returns:
- the string value for this entry
- See Also:
equalsString
boolean equalsString(String s)
- Parameters:
-
s- the string to compare to - Returns:
- whether this entry describes the same string as the provided string
isFieldType
boolean isFieldType(ClassDesc desc)
- Parameters:
-
desc- the field type - Returns:
- whether this entry describes the descriptor string of this field type
- Since:
- 25
isMethodType
boolean isMethodType(MethodTypeDesc desc)
- Parameters:
-
desc- the method type - Returns:
- whether this entry describes the descriptor string of this method type
- Since:
- 25
© 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.