public interface Constable
Some constable types have a native representation in the constant pool:
Double serve as their own nominal descriptors;
MethodHandle have corresponding nominal
Other reference types can be constable if their instances can describe
themselves in nominal form as a
ConstantDesc. Examples in the Java SE
Platform API are types that support Java language features such as
and runtime support classes such as
VarHandle. These are typically
described with a
DynamicConstantDesc, which describes dynamically
generated constants (JVMS 4.4.10).
The nominal form of an instance of a constable type is obtained via
describeConstable(). A Constable need
not be able to (or may choose not to) describe all its instances in the form of
ConstantDesc; this method returns an
Optional that can be
empty to indicate that a nominal descriptor could not be created for an instance.
MethodHandle will produce nominal descriptors for direct
method handles, but not necessarily those produced by method handle
java.util.Optional<? extends ConstantDesc> describeConstable()
Optionalif one cannot be.
Optionalcontaining the resulting nominal descriptor, or an empty
Optionalif one cannot be constructed.