T
- the type of the dynamic constantConstantDesc
Enum.EnumDesc
, VarHandle.VarHandleDesc
public abstract class DynamicConstantDesc<T> extends Object implements ConstantDesc
Constant_Dynamic_info
.)
Concrete subtypes of DynamicConstantDesc must be value-based.
Modifier | Constructor | Description |
---|---|---|
protected |
DynamicConstantDesc(DirectMethodHandleDesc bootstrapMethod,
String constantName,
ClassDesc constantType,
ConstantDesc... bootstrapArgs) |
Create a nominal descriptor for a dynamic constant.
|
Modifier and Type | Method | Description |
---|---|---|
ConstantDesc[] |
bootstrapArgs() |
Returns the bootstrap arguments for this constant
|
java.util.List<ConstantDesc> |
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. |
boolean |
equals(Object o) |
Compares the specified object with this descriptor for equality.
|
int |
hashCode() |
Returns a hash code value for the object.
|
static <T> DynamicConstantDesc<T> |
of(DirectMethodHandleDesc bootstrapMethod) |
Return 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<T> |
of(DirectMethodHandleDesc bootstrapMethod,
ConstantDesc... bootstrapArgs) |
Return 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(DirectMethodHandleDesc bootstrapMethod,
String constantName,
ClassDesc constantType,
ConstantDesc[] bootstrapArgs) |
Return 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<T> |
ofNamed(DirectMethodHandleDesc bootstrapMethod,
String constantName,
ClassDesc constantType,
ConstantDesc... bootstrapArgs) |
Return a nominal descriptor for a dynamic constant.
|
T |
resolveConstantDesc(MethodHandles.Lookup lookup) |
Resolve this descriptor reflectively, emulating the resolution behavior
of JVMS 5.4.3 and the access control behavior of JVMS 5.4.4.
|
String |
toString() |
Returns a string representation of the object.
|
protected DynamicConstantDesc(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs)
bootstrapMethod
- a DirectMethodHandleDescImpl
describing the
bootstrap method for the constantconstantName
- The unqualified name that would appear in the NameAndType
operand of the LDC
for this constantconstantType
- a DirectMethodHandleDescImpl
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 produces
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 DirectMethodHandleDescImpl
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 DirectMethodHandleDescImpl
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 DirectMethodHandleDescImpl
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 DirectMethodHandleDescImpl
describing the
bootstrap method for the constantNullPointerException
- if any argument is nullpublic String constantName()
NameAndType
operand
of the LDC
for this constantpublic 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 constantpublic ConstantDesc[] bootstrapArgs()
public java.util.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.equals
in class Object
o
- the DynamicConstantDesc
to compare to this
DynamicConstantDesc
true
if the specified DynamicConstantDesc
is
equals to this DynamicConstantDesc
.Object.hashCode()
,
HashMap
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(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
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.
As much as is reasonably practical, the hashCode method defined
by class Object
does return distinct integers for
distinct objects. (The hashCode may or may not be implemented
as some function of an object's memory address at some point
in time.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())