APIdia Launch Partner
Top Description Methods
java.lang.classfile.constantpool

public sealed Interface ClassEntry

extends LoadableConstantEntry
permits ClassEntryImpl
Known Direct Implementers
jdk.internal.classfile.impl.AbstractPoolEntry.ClassEntryImpl
Imports
java.lang.constant.ClassDesc, .ConstantDesc, jdk.internal.classfile.impl.AbstractPoolEntry

Models a CONSTANT_Class_info structure, representing a reference type, in the constant pool of a class file.

The use of a ClassEntry is modeled by a ClassDesc that is not primitive. Conversions are through ConstantPoolBuilder#classEntry( ClassDesc) and asSymbol().

A ClassEntry is composite:

ClassEntry(Utf8Entry name)
ClassEntry(Utf8Entry name)
where name represents: A field descriptor string for an array type can be distinguished by its leading '[' character.

API Note

The internal form of a binary name, where all occurrences of . in the name are replaced by /, is informally known as an internal name. This concept also applies to package names in addition to class and interface names.

Since
24
Java Virtual Machine Specification
4.4.1 The CONSTANT_Class_info Structure
See Also
ConstantPoolBuilder::classEntry, ClassDesc

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the represented reference type, as the internal form of a binary name or an array descriptor string
asInternalName
()

Returns the represented reference type, as the internal form of a binary name or an array descriptor string.

public ClassDesc

Returns:

the represented reference type, as a symbolic descriptor
asSymbol
()

Returns the represented reference type, as a symbolic descriptor.

public default ConstantDesc
constantValue()

Implements java.lang.classfile.constantpool.LoadableConstantEntry.constantValue.

Returns a symbolic descriptor of this constant.

public boolean

Returns:

whether this entry describes the given reference type
matches
(ClassDesc
the reference type
desc
)

Returns whether this entry describes the given reference type.

public Utf8Entry

Returns:

the Utf8Entry referred by this structure
name
()

Returns the Utf8Entry referred by this structure.

Inherited from java.lang.classfile.constantpool.LoadableConstantEntry:
typeKind

Method Detail

asInternalNameback to summary
public String asInternalName()

Returns the represented reference type, as the internal form of a binary name or an array descriptor string. This is a shortcut for name().stringValue().

Returns:String

the represented reference type, as the internal form of a binary name or an array descriptor string

asSymbolback to summary
public ClassDesc asSymbol()

Returns the represented reference type, as a symbolic descriptor. The returned descriptor is never primitive.

API Note

If only symbol equivalence is desired, matches should be used. It requires reduced parsing and can improve class file reading performance.

Returns:ClassDesc

the represented reference type, as a symbolic descriptor

See Also
ConstantPoolBuilder::classEntry(ClassDesc)
constantValueback to summary
public default ConstantDesc constantValue()

Implements java.lang.classfile.constantpool.LoadableConstantEntry.constantValue.

Doc from java.lang.classfile.constantpool.LoadableConstantEntry.constantValue.

Returns a symbolic descriptor of this constant.

This is equivalent to asSymbol().

Annotations
@Override
matchesback to summary
public boolean matches(ClassDesc desc)

Returns whether this entry describes the given reference type. Returns false if desc is primitive.

Parameters
desc:ClassDesc

the reference type

Returns:boolean

whether this entry describes the given reference type

Since
25
nameback to summary
public Utf8Entry name()

Returns the Utf8Entry referred by this structure. If the value of the UTF8 starts with a [, this represents an array type and the value is a descriptor string; otherwise, this represents a class or interface and the value is the internal form of a binary name.

Returns:Utf8Entry

the Utf8Entry referred by this structure

See Also
ConstantPoolBuilder::classEntry(Utf8Entry)