T
- the type of the dynamic constantConstantDesc
Enum.EnumDesc
, VarHandle.VarHandleDesc
public abstract non-sealed class DynamicConstantDesc<T> extends Object implements ConstantDesc
Constant_Dynamic_info
.) Concrete subtypes of DynamicConstantDesc should be immutable and their behavior should not rely on object identity.
Modifier | Constructor | Description |
---|---|---|
protected |
Creates a nominal descriptor for a dynamic constant. |
Modifier and Type | Method | Description |
---|---|---|
ConstantDesc[] |
bootstrapArgs() |
Returns the bootstrap arguments for this constant. |
List |
bootstrapArgsList() |
Returns the bootstrap arguments for this constant as an immutable List . |
DirectMethodHandleDesc |
bootstrapMethod() |
Returns a MethodHandleDesc describing the bootstrap method for this constant. |
String |
constantName() |
Returns the name that would appear in the NameAndType operand of the LDC for this constant. |
ClassDesc |
constantType() |
Returns a ClassDesc describing the type that would appear in the NameAndType operand of the LDC for this constant. |
final boolean |
equals |
Compares the specified object with this descriptor for equality. |
final int |
hashCode() |
Returns a hash code value for the object. |
static <T> DynamicConstantDesc |
of |
Returns a nominal descriptor for a dynamic constant whose bootstrap has no static arguments, whose name parameter is ConstantDescs.DEFAULT_NAME , and whose type parameter is always the same as the bootstrap method return type. |
static <T> DynamicConstantDesc |
of |
Returns a nominal descriptor for a dynamic constant whose name parameter is ConstantDescs.DEFAULT_NAME , and whose type parameter is always the same as the bootstrap method return type. |
static <T> ConstantDesc |
ofCanonical |
Returns a nominal descriptor for a dynamic constant, transforming it into a more specific type if the constant bootstrap is a well-known one and a more specific nominal descriptor type (e.g., ClassDesc) is available. |
static <T> DynamicConstantDesc |
ofNamed |
Returns a nominal descriptor for a dynamic constant. |
T |
resolveConstantDesc |
|
String |
toString() |
Returns a compact textual description of this constant description, including the bootstrap method, the constant name and type, and the static bootstrap arguments. |
protected DynamicConstantDesc(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs)
bootstrapMethod
- a DirectMethodHandleDesc
describing the bootstrap method for the constantconstantName
- The unqualified name that would appear in the NameAndType
operand of the LDC
for this constantconstantType
- a ClassDesc
describing the type that would appear in the NameAndType
operand of the LDC
for this constantbootstrapArgs
- ConstantDesc
s describing the static arguments to the bootstrap, that would appear in the BootstrapMethods
attributeNullPointerException
- if any argument is nullIllegalArgumentException
- if the name
has the incorrect formatpublic static <T> ConstantDesc ofCanonical(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc[] bootstrapArgs)
Classes whose Constable.describeConstable()
method produce a DynamicConstantDesc with a well-known bootstrap including Class
(for instances describing primitive types), Enum
, and VarHandle
.
Bytecode-reading APIs that process the constant pool and wish to expose entries as ConstantDesc
to their callers should generally use this method in preference to ofNamed(DirectMethodHandleDesc, String, ClassDesc, ConstantDesc...)
because this may result in a more specific type that can be provided to callers.
T
- the type of the dynamic constantbootstrapMethod
- a DirectMethodHandleDesc
describing the bootstrap method for the constantconstantName
- The unqualified name that would appear in the NameAndType
operand of the LDC
for this constantconstantType
- a ClassDesc
describing the type that would appear in the NameAndType
operand of the LDC
for this constantbootstrapArgs
- ConstantDesc
s describing the static arguments to the bootstrap, that would appear in the BootstrapMethods
attributeNullPointerException
- if any argument is nullIllegalArgumentException
- if the name
has the incorrect formatpublic static <T> DynamicConstantDesc<T> ofNamed(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs)
T
- the type of the dynamic constantbootstrapMethod
- a DirectMethodHandleDesc
describing the bootstrap method for the constantconstantName
- The unqualified name that would appear in the NameAndType
operand of the LDC
for this constantconstantType
- a ClassDesc
describing the type that would appear in the NameAndType
operand of the LDC
for this constantbootstrapArgs
- ConstantDesc
s describing the static arguments to the bootstrap, that would appear in the BootstrapMethods
attributeNullPointerException
- if any argument is nullIllegalArgumentException
- if the name
has the incorrect formatpublic static <T> DynamicConstantDesc<T> of(DirectMethodHandleDesc bootstrapMethod, ConstantDesc... bootstrapArgs)
ConstantDescs.DEFAULT_NAME
, and whose type parameter is always the same as the bootstrap method return type.T
- the type of the dynamic constantbootstrapMethod
- a DirectMethodHandleDesc
describing the bootstrap method for the constantbootstrapArgs
- ConstantDesc
s describing the static arguments to the bootstrap, that would appear in the BootstrapMethods
attributeNullPointerException
- if any argument is nullpublic static <T> DynamicConstantDesc<T> of(DirectMethodHandleDesc bootstrapMethod)
ConstantDescs.DEFAULT_NAME
, and whose type parameter is always the same as the bootstrap method return type.T
- the type of the dynamic constantbootstrapMethod
- a DirectMethodHandleDesc
describing the bootstrap method for the constantNullPointerException
- if any argument is nullpublic String constantName()
NameAndType
operand of the LDC
for this constant.public ClassDesc constantType()
ClassDesc
describing the type that would appear in the NameAndType
operand of the LDC
for this constant.public DirectMethodHandleDesc bootstrapMethod()
MethodHandleDesc
describing the bootstrap method for this constant.public ConstantDesc[] bootstrapArgs()
public List<ConstantDesc> bootstrapArgsList()
List
.List
of the bootstrap argumentspublic T resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException
ConstantDesc
MethodHandles.Lookup
parameter. No caching of the resulting value is performed.resolveConstantDesc
in interface ConstantDesc
lookup
- The MethodHandles.Lookup
to provide name resolution and access control contextReflectiveOperationException
- if a class, method, or field could not be reflectively resolved in the course of resolutionpublic final boolean equals(Object o)
true
if and only if the specified object is also a DynamicConstantDesc, and both descriptors have equal bootstrap methods, bootstrap argument lists, constant name, and constant type.public final int hashCode()
Object
HashMap
. The general contract of hashCode
is:
hashCode
method must consistently return the same integer, provided no information used in equals
comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. equals
method, then calling the
hashCode
method on each of the two objects must produce the same integer result. equals
method, then calling the hashCode
method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables. public String toString()
© 1993, 2023, 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/21/docs/api/java.base/java/lang/constant/DynamicConstantDesc.html