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 (
ConstantDesc, and serve as nominal descriptors for themselves.
Native linkable constants (
MethodHandle) have counterpart ConstantDesc types:
Other constants are represented by subtypes of
APIs that perform generation or parsing of bytecode are encouraged to use
ConstantDesc to describe the operand of an
(including dynamic constants), the static bootstrap arguments of
dynamic constants and
invokedynamic instructions, and other
bytecodes or classfile structures that make use of the constant pool.
Implementations of ConstantDesc should be immutable and their behavior should not rely on object identity.
Nominal descriptors should be compared using the
Object.equals(Object) method. There is no guarantee that any
particular entity will always be represented by the same descriptor instance.
resolveConstantDescResolves 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.Lookupparameter. No caching of the resulting value is performed.
- API Note:
- MethodTypeDesc can represent method type descriptors that are not representable by MethodType, such as methods with more than 255 parameter slots, so attempts to resolve these may result in errors.
MethodHandles.Lookupto provide name resolution and access control context
- the resolved constant value
ReflectiveOperationException- if a class, method, or field could not be reflectively resolved in the course of resolution
LinkageError- if a linkage error occurs
- See Java Virtual Machine Specification:
5.4.4 Access Control