- 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
, and Double
) implement ConstantDesc
, and serve as nominal descriptors for themselves. Native linkable constants (Class
, MethodType
, and MethodHandle
) have counterpart ConstantDesc types: ClassDesc
, MethodTypeDesc
, and MethodHandleDesc
. Other constants are represented by subtypes of DynamicConstantDesc
.
APIs that perform generation or parsing of bytecode are encouraged to use ConstantDesc to describe the operand of an ldc
instruction (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.
Constants describing various common constants (such as ClassDesc
instances for platform types) can be found in ConstantDescs
.
Implementations of ConstantDesc should be immutable and their behavior should not rely on object identity.
Non-platform classes should not implement ConstantDesc directly. Instead, they should extend DynamicConstantDesc
(as Enum.EnumDesc
and VarHandle.VarHandleDesc
do.)
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.
- See Java Virtual Machine Specification:
- Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.4.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html#jvms-4.4. Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.4.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html#jvms-4.4.4.4 The Constant Pool
- Sealed Class Hierarchy Graph:
- Since:
- 12
- See Also:
Methods
- ✗public abstract java.lang.Object resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup arg0) throws java.lang.ReflectiveOperationExceptionComparing jdk-20-ga and jdk-21+35
resolveConstantDesc
Resolves this descriptor reflectively, emulating the resolution behavior of JVMS Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-5.html#jvms-5.4.3.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-5.html#jvms-5.4.3.5.4.3Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-5.html#jvms-5.4.3.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-5.html#jvms-5.4.3. and the access control behavior of JVMS Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-5.html#jvms-5.4.4.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-5.html#jvms-5.4.4.5.4.4. The resolution and access control context is provided by theMethodHandles.Lookupparameter. No caching of the resulting value is performed.- API Note:
- Some constant descriptors, such as MethodTypeDesc, can represent method type descriptors that are not representable by MethodType, such as methods with more than 255 parameter slots, so attempts a value that is not representable by run-time entities. 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- See Java Virtual Machine Specification:
- Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-5.html#jvms-5.4.3.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-5.html#jvms-5.4.3. Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-5.html#jvms-5.4.3.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-5.html#jvms-5.4.3.5.4.3 Resolution
Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-5.html#jvms-5.4.4.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-5.html#jvms-5.4.4.5.4.4 Access Control
Summary
| Elements | Comments | Descriptions | Total | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed | ||
| ConstantDesc | 2 | 2 | ||||||||
| resolveConstantDesc(MethodHandles.Lookup) | 2 | 6 | 1 | 9 | ||||||
| Total | 2 | 8 | 1 | 11 | ||||||