java.lang.Object
java.lang.constant.DynamicConstantDesc<T>
- 类型参数:
T
- 动态常量的类型
- 所有已实现的接口:
ConstantDesc
- 已知子类:
Enum.EnumDesc
,VarHandle.VarHandleDesc
一个 名义描述符 用于动态常量(一个在常量池中用
Constant_Dynamic_info
描述的。)
DynamicConstantDesc 的具体子类型应该是不可变的,它们的行为不应该依赖于对象标识。
- 自从:
- 12
-
构造方法总结
构造方法修饰符构造方法描述protected
DynamicConstantDesc
(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs) 为动态常量创建标称描述符。 -
方法总结
修饰符和类型方法描述返回此常量的引导程序参数。将此常量的引导程序参数作为不可变的List
返回。返回一个MethodHandleDesc
描述这个常量的引导方法。返回将出现在该常量的LDC
的NameAndType
操作数中的名称。final boolean
比较指定对象与此描述符是否相等。final int
hashCode()
返回对象的哈希码值。static <T> DynamicConstantDesc<T>
of
(DirectMethodHandleDesc bootstrapMethod) 返回动态常量的标称描述符,其引导程序没有静态参数,名称参数为ConstantDescs.DEFAULT_NAME
,并且其类型参数始终与引导程序方法返回类型相同。static <T> DynamicConstantDesc<T>
of
(DirectMethodHandleDesc bootstrapMethod, ConstantDesc... bootstrapArgs) 返回名称参数为ConstantDescs.DEFAULT_NAME
且类型参数始终与引导方法返回类型相同的动态常量的标称描述符。static <T> ConstantDesc
ofCanonical
(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc[] bootstrapArgs) 返回动态常量的标称描述符,如果常量引导程序是众所周知的并且更具体的标称描述符类型(例如,ClassDesc)可用,则将其转换为更具体的类型。static <T> DynamicConstantDesc<T>
ofNamed
(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs) 返回动态常量的标称描述符。toString()
返回此常量描述的紧凑文本描述,包括引导方法、常量名称和类型以及静态引导参数。
-
构造方法详细信息
-
DynamicConstantDesc
protected DynamicConstantDesc(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc ... bootstrapArgs) 为动态常量创建标称描述符。- 参数:
bootstrapMethod
- 一个DirectMethodHandleDesc
描述常量的引导方法constantName
- 将出现在该常量的LDC
的NameAndType
操作数中的非限定名称constantType
- 一个ClassDesc
描述将出现在该常量的LDC
的NameAndType
操作数中的类型bootstrapArgs
-ConstantDesc
描述引导程序的静态参数,将出现在BootstrapMethods
属性中- 抛出:
NullPointerException
- 如果任何参数为空IllegalArgumentException
- 如果name
的格式不正确- 看Java 虚拟机规范:
-
4.2.2 非限定名称
-
-
方法详情
-
ofCanonical
public static <T> ConstantDesc ofCanonical(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc [] bootstrapArgs) 返回动态常量的标称描述符,如果常量引导程序是众所周知的并且更具体的标称描述符类型(例如,ClassDesc)可用,则将其转换为更具体的类型。Constable.describeConstable()
方法生成 DynamicConstantDesc 的类具有众所周知的引导程序,包括Class
(用于描述原始类型的实例)、Enum
和VarHandle
。处理常量池并希望将条目作为
ConstantDesc
公开给调用者的字节码读取 API 通常应该优先使用此方法而不是ofNamed(DirectMethodHandleDesc, String, ClassDesc, ConstantDesc...)
,因为这可能会导致可以提供给调用者的更具体的类型。- 类型参数:
T
- 动态常量的类型- 参数:
bootstrapMethod
- 一个DirectMethodHandleDesc
描述常量的引导方法constantName
- 将出现在该常量的LDC
的NameAndType
操作数中的非限定名称constantType
- 一个ClassDesc
描述将出现在该常量的LDC
的NameAndType
操作数中的类型bootstrapArgs
-ConstantDesc
描述引导程序的静态参数,将出现在BootstrapMethods
属性中- 返回:
- 名义描述符
- 抛出:
NullPointerException
- 如果任何参数为空IllegalArgumentException
- 如果name
的格式不正确- 看Java 虚拟机规范:
-
4.2.2 非限定名称
-
ofNamed
public static <T> DynamicConstantDesc <T> ofNamed(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc ... bootstrapArgs) 返回动态常量的标称描述符。- 类型参数:
T
- 动态常量的类型- 参数:
bootstrapMethod
- 一个DirectMethodHandleDesc
描述常量的引导方法constantName
- 将出现在该常量的LDC
的NameAndType
操作数中的非限定名称constantType
- 一个ClassDesc
描述将出现在该常量的LDC
的NameAndType
操作数中的类型bootstrapArgs
-ConstantDesc
描述引导程序的静态参数,将出现在BootstrapMethods
属性中- 返回:
- 名义描述符
- 抛出:
NullPointerException
- 如果任何参数为空IllegalArgumentException
- 如果name
的格式不正确- 看Java 虚拟机规范:
-
4.2.2 非限定名称
-
of
public static <T> DynamicConstantDesc <T> of(DirectMethodHandleDesc bootstrapMethod, ConstantDesc ... bootstrapArgs) 返回名称参数为ConstantDescs.DEFAULT_NAME
且类型参数始终与引导方法返回类型相同的动态常量的标称描述符。- 类型参数:
T
- 动态常量的类型- 参数:
bootstrapMethod
- 一个DirectMethodHandleDesc
描述常量的引导方法bootstrapArgs
-ConstantDesc
描述引导程序的静态参数,将出现在BootstrapMethods
属性中- 返回:
- 名义描述符
- 抛出:
NullPointerException
- 如果任何参数为空- 看Java 虚拟机规范:
-
4.2.2 非限定名称
-
of
返回动态常量的标称描述符,其引导程序没有静态参数,名称参数为ConstantDescs.DEFAULT_NAME
,并且其类型参数始终与引导程序方法返回类型相同。- 类型参数:
T
- 动态常量的类型- 参数:
bootstrapMethod
- 一个DirectMethodHandleDesc
描述常量的引导方法- 返回:
- 名义描述符
- 抛出:
NullPointerException
- 如果任何参数为空
-
constantName
返回将出现在该常量的LDC
的NameAndType
操作数中的名称。- 返回:
- 常量名称
-
constantType
- 返回:
- 常量类型
-
bootstrapMethod
返回一个MethodHandleDesc
描述这个常量的引导方法。- 返回:
- 自举法
-
bootstrapArgs
返回此常量的引导程序参数。- 返回:
- 引导参数
-
bootstrapArgsList
将此常量的引导程序参数作为不可变的List
返回。- 返回:
-
引导程序参数的
List
-
resolveConstantDesc
从接口ConstantDesc
复制的描述- 指定者:
resolveConstantDesc
在接口ConstantDesc
中- 参数:
lookup
-MethodHandles.Lookup
提供名称解析和访问控制上下文- 返回:
- 解析的常量值
- 抛出:
ReflectiveOperationException
- 如果类、方法或字段在解析过程中无法反射解析
-
equals
比较指定对象与此描述符是否相等。当且仅当指定对象也是 DynamicConstantDesc 并且两个描述符具有相同的引导方法、引导参数列表、常量名称和常量类型时返回true
。 -
hashCode
public final int hashCode()从类复制的描述:Object
返回对象的哈希码值。支持此方法是为了哈希表的好处,例如HashMap
提供的哈希表。hashCode
的总合同为: -
toString
返回此常量描述的紧凑文本描述,包括引导方法、常量名称和类型以及静态引导参数。
-