- All Implemented Interfaces:
ConstantDesc
- Enclosing class:
VarHandle
A nominal descriptor for a
VarHandle
constant.- Since:
- 12
-
Method Summary
Modifier and TypeMethodDescriptionstatic VarHandle.VarHandleDesc
Returns a VarHandle.VarHandleDesc corresponding to aVarHandle
for an array type.static VarHandle.VarHandleDesc
Returns a VarHandle.VarHandleDesc corresponding to aVarHandle
for an instance field.static VarHandle.VarHandleDesc
ofStaticField
(ClassDesc declaringClass, String name, ClassDesc fieldType) Returns a VarHandle.VarHandleDesc corresponding to aVarHandle
for a static field.toString()
Returns a compact textual description of this constant description.varType()
Returns aClassDesc
describing the type of the variable described by this descriptor.Methods inherited from class java.lang.constant.DynamicConstantDesc
bootstrapArgs, bootstrapArgsList, bootstrapMethod, constantName, constantType, equals, hashCode, of, of, ofCanonical, ofNamed
-
Method Details
-
ofField
public static VarHandle.VarHandleDesc ofField(ClassDesc declaringClass, String name, ClassDesc fieldType) Returns a VarHandle.VarHandleDesc corresponding to aVarHandle
for an instance field.- Parameters:
declaringClass
- aClassDesc
describing the declaring class, for field var handlesname
- the unqualified name of the fieldfieldType
- aClassDesc
describing the type of the field- Returns:
- the VarHandle.VarHandleDesc
- Throws:
NullPointerException
- if any of the arguments are null- See Java Virtual Machine Specification:
-
4.2.2 Unqualified Names
-
ofStaticField
public static VarHandle.VarHandleDesc ofStaticField(ClassDesc declaringClass, String name, ClassDesc fieldType) Returns a VarHandle.VarHandleDesc corresponding to aVarHandle
for a static field.- Parameters:
declaringClass
- aClassDesc
describing the declaring class, for field var handlesname
- the unqualified name of the fieldfieldType
- aClassDesc
describing the type of the field- Returns:
- the VarHandle.VarHandleDesc
- Throws:
NullPointerException
- if any of the arguments are null- See Java Virtual Machine Specification:
-
4.2.2 Unqualified Names
-
ofArray
Returns a VarHandle.VarHandleDesc corresponding to aVarHandle
for an array type.- Parameters:
arrayClass
- aClassDesc
describing the type of the array- Returns:
- the VarHandle.VarHandleDesc
- Throws:
NullPointerException
- if any of the arguments are null
-
varType
Returns aClassDesc
describing the type of the variable described by this descriptor.- Returns:
- the variable type
-
resolveConstantDesc
public VarHandle resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException Description copied from interface:ConstantDesc
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 theMethodHandles.Lookup
parameter. No caching of the resulting value is performed.- Specified by:
resolveConstantDesc
in interfaceConstantDesc
- Overrides:
resolveConstantDesc
in classDynamicConstantDesc<VarHandle>
- Parameters:
lookup
- TheMethodHandles.Lookup
to provide name resolution and access control context- Returns:
- the resolved constant value
- Throws:
ReflectiveOperationException
- if a class, method, or field could not be reflectively resolved in the course of resolution
-
toString
Returns a compact textual description of this constant description. For a field VarHandle, includes the owner, name, and type of the field, and whether it is static; for an array VarHandle, the name of the component type.- Overrides:
toString
in classDynamicConstantDesc<VarHandle>
- Returns:
- A compact textual description of this descriptor
-