Top Description Inners Fields Constructors Methods
java.lang.constant

public abstract non-sealed Class DynamicConstantDesc<T>

extends Object
implements ConstantDesc
Class Inheritance
All Implemented Interfaces
java.lang.constant.ConstantDesc
Known Direct Subclasses
java.lang.constant.DynamicConstantDesc.AnonymousDynamicConstantDesc, jdk.internal.constant.PrimitiveClassDescImpl, java.lang.Enum.EnumDesc, java.lang.invoke.VarHandle.VarHandleDesc, java.lang.constant.AsTypeMethodHandleDesc
Type Parameters
<T>
the type of the dynamic constant
Imports
java.lang.Enum.EnumDesc, java.lang.invoke.MethodHandle, .MethodHandles, .VarHandle, .VarHandle.VarHandleDesc, java.util.Arrays, .List, .Map, .Objects, java.util.function.Function, java.util.stream.Stream

A nominal descriptor for a dynamic constant (one described in the constant pool with Constant_Dynamic_info.)

Concrete subtypes of DynamicConstantDesc should be immutable and their behavior should not rely on object identity.

Since
12

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final ConstantDesc[]
private final DirectMethodHandleDesc
private final String
private final ClassDesc

Constructor Summary

AccessConstructor and Description
protected
DynamicConstantDesc(DirectMethodHandleDesc
a DirectMethodHandleDesc describing the bootstrap method for the constant
bootstrapMethod
,
String
The unqualified name that would appear in the NameAndType operand of the LDC for this constant
constantName
,
ClassDesc
a ClassDesc describing the type that would appear in the NameAndType operand of the LDC for this constant
constantType
,
ConstantDesc...
ConstantDescs describing the static arguments to the bootstrap, that would appear in the BootstrapMethods attribute
bootstrapArgs
)

Creates a nominal descriptor for a dynamic constant.

Method Summary

Modifier and TypeMethod and Description
public ConstantDesc[]

Returns:

the bootstrap arguments
bootstrapArgs
()

Returns the bootstrap arguments for this constant.

public List<ConstantDesc>

Returns:

a List of the bootstrap arguments
bootstrapArgsList
()

Returns the bootstrap arguments for this constant as an immutable List.

public DirectMethodHandleDesc

Returns:

the bootstrap method
bootstrapMethod
()

Returns a MethodHandleDesc describing the bootstrap method for this constant.

private static ConstantDesc
private static ConstantDesc
private static ConstantDesc
private static ConstantDesc
private static ConstantDesc
private static ConstantDesc
public String

Returns:

the constant name
constantName
()

Returns the name that would appear in the NameAndType operand of the LDC for this constant.

public ClassDesc

Returns:

the constant type
constantType
()

Returns a ClassDesc describing the type that would appear in the NameAndType operand of the LDC for this constant.

public final boolean

Returns:

true if the specified DynamicConstantDesc is equal to this DynamicConstantDesc.
equals
(Object
the DynamicConstantDesc to compare to this DynamicConstantDesc
o
)

Overrides java.lang.Object.equals.

Compares the specified object with this descriptor for equality.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public static <
the type of the dynamic constant
T
>
DynamicConstantDesc<T>

Returns:

the nominal descriptor
of
(DirectMethodHandleDesc
a DirectMethodHandleDesc describing the bootstrap method for the constant
bootstrapMethod
,
ConstantDesc...
ConstantDescs describing the static arguments to the bootstrap, that would appear in the BootstrapMethods attribute
bootstrapArgs
)

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.

public static <
the type of the dynamic constant
T
>
DynamicConstantDesc<T>

Returns:

the nominal descriptor
of
(DirectMethodHandleDesc
a DirectMethodHandleDesc describing the bootstrap method for the constant
bootstrapMethod
)

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.

public static <
the type of the dynamic constant
T
>
ConstantDesc

Returns:

the nominal descriptor
ofCanonical
(DirectMethodHandleDesc
a DirectMethodHandleDesc describing the bootstrap method for the constant
bootstrapMethod
,
String
The unqualified name that would appear in the NameAndType operand of the LDC for this constant
constantName
,
ClassDesc
a ClassDesc describing the type that would appear in the NameAndType operand of the LDC for this constant
constantType
,
ConstantDesc[]
ConstantDescs describing the static arguments to the bootstrap, that would appear in the BootstrapMethods attribute
bootstrapArgs
)

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.

public static <
the type of the dynamic constant
T
>
DynamicConstantDesc<T>

Returns:

the nominal descriptor
ofNamed
(DirectMethodHandleDesc
a DirectMethodHandleDesc describing the bootstrap method for the constant
bootstrapMethod
,
String
The unqualified name that would appear in the NameAndType operand of the LDC for this constant
constantName
,
ClassDesc
a ClassDesc describing the type that would appear in the NameAndType operand of the LDC for this constant
constantType
,
ConstantDesc...
ConstantDescs describing the static arguments to the bootstrap, that would appear in the BootstrapMethods attribute
bootstrapArgs
)

Returns a nominal descriptor for a dynamic constant.

public T
resolveConstantDesc(MethodHandles.Lookup
The MethodHandles.Lookup to provide name resolution and access control context
lookup
)

Implements java.lang.constant.ConstantDesc.resolveConstantDesc.

Resolves this descriptor reflectively, emulating the resolution behavior of JVMS 5.4.3 and the access control behavior of JVMS 5.4.4.

public String

Returns:

A compact textual description of this call site descriptor
toString
()

Overrides java.lang.Object.toString.

Returns a compact textual description of this constant description, including the bootstrap method, the constant name and type, and the static bootstrap arguments.

private ConstantDesc
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

bootstrapArgsback to summary
private final ConstantDesc[] bootstrapArgs
bootstrapMethodback to summary
private final DirectMethodHandleDesc bootstrapMethod
constantNameback to summary
private final String constantName
constantTypeback to summary
private final ClassDesc constantType

Constructor Detail

DynamicConstantDescback to summary
protected DynamicConstantDesc(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs)

Creates a nominal descriptor for a dynamic constant.

Parameters
bootstrapMethod:DirectMethodHandleDesc

a DirectMethodHandleDesc describing the bootstrap method for the constant

constantName:String

The unqualified name that would appear in the NameAndType operand of the LDC for this constant

constantType:ClassDesc

a ClassDesc describing the type that would appear in the NameAndType operand of the LDC for this constant

bootstrapArgs:ConstantDesc[]

ConstantDescs describing the static arguments to the bootstrap, that would appear in the BootstrapMethods attribute

Exceptions
NullPointerException:
if any argument is null
IllegalArgumentException:
if the name has the incorrect format
Java Virtual Machine Specification
4.2.2 Unqualified Names

Method Detail

bootstrapArgsback to summary
public ConstantDesc[] bootstrapArgs()

Returns the bootstrap arguments for this constant.

Returns:ConstantDesc[]

the bootstrap arguments

bootstrapArgsListback to summary
public List<ConstantDesc> bootstrapArgsList()

Returns the bootstrap arguments for this constant as an immutable List.

Returns:List<ConstantDesc>

a List of the bootstrap arguments

bootstrapMethodback to summary
public DirectMethodHandleDesc bootstrapMethod()

Returns a MethodHandleDesc describing the bootstrap method for this constant.

Returns:DirectMethodHandleDesc

the bootstrap method

canonicalizeArrayVarHandleback to summary
private static ConstantDesc canonicalizeArrayVarHandle(DynamicConstantDesc<?> desc)
canonicalizeEnumback to summary
private static ConstantDesc canonicalizeEnum(DynamicConstantDesc<?> desc)
canonicalizeFieldVarHandleback to summary
private static ConstantDesc canonicalizeFieldVarHandle(DynamicConstantDesc<?> desc)
canonicalizeNullback to summary
private static ConstantDesc canonicalizeNull(DynamicConstantDesc<?> desc)
canonicalizePrimitiveClassback to summary
private static ConstantDesc canonicalizePrimitiveClass(DynamicConstantDesc<?> desc)
canonicalizeStaticFieldVarHandleback to summary
private static ConstantDesc canonicalizeStaticFieldVarHandle(DynamicConstantDesc<?> desc)
constantNameback to summary
public String constantName()

Returns the name that would appear in the NameAndType operand of the LDC for this constant.

Returns:String

the constant name

constantTypeback to summary
public ClassDesc constantType()

Returns a ClassDesc describing the type that would appear in the NameAndType operand of the LDC for this constant.

Returns:ClassDesc

the constant type

equalsback to summary
public final boolean equals(Object o)

Overrides java.lang.Object.equals.

Compares the specified object with this descriptor for equality. Returns 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.

Parameters
o:Object

the DynamicConstantDesc to compare to this DynamicConstantDesc

Returns:boolean

true if the specified DynamicConstantDesc is equal to this DynamicConstantDesc.

Annotations
@Override
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the 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.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the 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.
Returns:int

a hash code value for this object

Annotations
@Override
ofback to summary
public static <T> DynamicConstantDesc<T> of(DirectMethodHandleDesc bootstrapMethod, ConstantDesc... bootstrapArgs)

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.

Parameters
<T>
the type of the dynamic constant
bootstrapMethod:DirectMethodHandleDesc

a DirectMethodHandleDesc describing the bootstrap method for the constant

bootstrapArgs:ConstantDesc[]

ConstantDescs describing the static arguments to the bootstrap, that would appear in the BootstrapMethods attribute

Returns:DynamicConstantDesc<T>

the nominal descriptor

Exceptions
NullPointerException:
if any argument is null
Java Virtual Machine Specification
4.2.2 Unqualified Names
ofback to summary
public static <T> DynamicConstantDesc<T> of(DirectMethodHandleDesc bootstrapMethod)

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.

Parameters
<T>
the type of the dynamic constant
bootstrapMethod:DirectMethodHandleDesc

a DirectMethodHandleDesc describing the bootstrap method for the constant

Returns:DynamicConstantDesc<T>

the nominal descriptor

Exceptions
NullPointerException:
if any argument is null
ofCanonicalback to summary
public static <T> ConstantDesc ofCanonical(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc[] bootstrapArgs)

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.

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.

Parameters
<T>
the type of the dynamic constant
bootstrapMethod:DirectMethodHandleDesc

a DirectMethodHandleDesc describing the bootstrap method for the constant

constantName:String

The unqualified name that would appear in the NameAndType operand of the LDC for this constant

constantType:ClassDesc

a ClassDesc describing the type that would appear in the NameAndType operand of the LDC for this constant

bootstrapArgs:ConstantDesc[]

ConstantDescs describing the static arguments to the bootstrap, that would appear in the BootstrapMethods attribute

Returns:ConstantDesc

the nominal descriptor

Exceptions
NullPointerException:
if any argument is null
IllegalArgumentException:
if the name has the incorrect format
Java Virtual Machine Specification
4.2.2 Unqualified Names
ofNamedback to summary
public static <T> DynamicConstantDesc<T> ofNamed(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs)

Returns a nominal descriptor for a dynamic constant.

Parameters
<T>
the type of the dynamic constant
bootstrapMethod:DirectMethodHandleDesc

a DirectMethodHandleDesc describing the bootstrap method for the constant

constantName:String

The unqualified name that would appear in the NameAndType operand of the LDC for this constant

constantType:ClassDesc

a ClassDesc describing the type that would appear in the NameAndType operand of the LDC for this constant

bootstrapArgs:ConstantDesc[]

ConstantDescs describing the static arguments to the bootstrap, that would appear in the BootstrapMethods attribute

Returns:DynamicConstantDesc<T>

the nominal descriptor

Exceptions
NullPointerException:
if any argument is null
IllegalArgumentException:
if the name has the incorrect format
Java Virtual Machine Specification
4.2.2 Unqualified Names
resolveConstantDescback to summary
public T resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException

Implements java.lang.constant.ConstantDesc.resolveConstantDesc.

Doc from java.lang.constant.ConstantDesc.resolveConstantDesc.

Resolves this descriptor reflectively, emulating the resolution behavior of JVMS 5.4.3 and the access control behavior of JVMS 5.4.4. The resolution and access control context is provided by the MethodHandles.Lookup parameter. No caching of the resulting value is performed.

Parameters
lookup:MethodHandles.Lookup

The MethodHandles.Lookup to provide name resolution and access control context

Returns:T

the resolved constant value

Annotations
@SuppressWarnings:unchecked
Exceptions
ReflectiveOperationException:
if a class, method, or field could not be reflectively resolved in the course of resolution
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a compact textual description of this constant description, including the bootstrap method, the constant name and type, and the static bootstrap arguments.

Returns:String

A compact textual description of this call site descriptor

Annotations
@Override
tryCanonicalizeback to summary
private ConstantDesc tryCanonicalize()
java.lang.constant back to summary

private Class DynamicConstantDesc.AnonymousDynamicConstantDesc<T>

extends DynamicConstantDesc<T>
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv
AnonymousDynamicConstantDesc(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs)

Method Summary

Inherited from java.lang.constant.DynamicConstantDesc:
bootstrapArgsbootstrapArgsListbootstrapMethodconstantNameconstantTypeequalshashCodeofofofCanonicalofNamedresolveConstantDesctoString

Constructor Detail

AnonymousDynamicConstantDescback to summary
pack-priv AnonymousDynamicConstantDesc(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs)
java.lang.constant back to summary

private final Class DynamicConstantDesc.CanonicalMapHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final Map<MethodHandleDesc, Function<DynamicConstantDesc<?>, ConstantDesc>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CANONICAL_MAPback to summary
pack-priv static final Map<MethodHandleDesc, Function<DynamicConstantDesc<?>, ConstantDesc>> CANONICAL_MAP

Constructor Detail

CanonicalMapHolderback to summary
private CanonicalMapHolder()