- All Known Subinterfaces:
ClassDesc,DirectMethodHandleDesc,MethodHandleDesc,MethodTypeDesc
resolveConstantDesc(MethodHandles.Lookup) to yield the constant value itself.Class names in a nominal descriptor, like class names in the constant pool of a classfile, must be interpreted with respect to a particular class loader, which is not part of the nominal descriptor.
Static constants that are expressible natively in the constant pool (String,Integer,Long,Float, andDouble) implementConstantDesc, and serve as nominal descriptors for themselves. Native linkable constants (Class,MethodType, andMethodHandle) have counterpartConstantDesc types:ClassDesc,MethodTypeDesc, andMethodHandleDesc. Other constants are represented by subtypes ofDynamicConstantDesc.
APIs that perform generation or parsing of bytecode are encouraged to useConstantDesc to describe the operand of anldc instruction (including dynamic constants), the static bootstrap arguments of dynamic constants andinvokedynamic instructions, and other bytecodes or classfile structures that make use of the constant pool.
Constants describing various common constants (such asClassDesc instances for platform types) can be found inConstantDescs.
Implementations ofConstantDesc should be immutable and their behavior should not rely on object identity.
Non-platform classes should not implementConstantDesc directly. Instead, they should extendDynamicConstantDesc (asEnum.EnumDesc andVarHandle.VarHandleDesc do.)
Nominal descriptors should be compared using theObject.equals(Object) method. There is no guarantee that any particular entity will always be represented by the same descriptor instance.
- SeeJava Virtual Machine Specification:
- 4.4 The Constant Pool
- Since:
- 12
- See Also:
Method Summary
Modifier and TypeMethodDescriptionResolves this descriptor reflectively, emulating the resolution behavior of JVMS 5.4.3 and the access control behavior of JVMS 5.4.4.
Method Details
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 theMethodHandles.Lookupparameter. No caching of the resulting value is performed.- API Note:
- MethodTypeDesc can represent method type descriptors that are not representable byMethodType, such as methods with more than 255 parameter slots, so attempts to resolve these may result in errors.
- Parameters:
lookup- TheMethodHandles.Lookupto 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 resolutionLinkageError- if a linkage error occurs- SeeJava Virtual Machine Specification:
- 5.4.3 Resolution
5.4.4 Access Control