-
public interface Constable
Represents a type which is constable. A constable type is one whose values are constants that can be represented in the constant pool of a Java classfile as described in JVMS 4.4, and whose instances can describe themselves nominally as aConstantDesc
.Some constable types have a native representation in the constant pool:
String
,Integer
,Long
,Float
,Double
,Class
,MethodType
, andMethodHandle
. The typesString
,Integer
,Long
,Float
, andDouble
serve as their own nominal descriptors;Class
,MethodType
, andMethodHandle
have corresponding nominal descriptorsClassDesc
,MethodTypeDesc
, andMethodHandleDesc
.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 asEnum
, and runtime support classes such asVarHandle
. These are typically described with aDynamicConstantDesc
, 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 aConstantDesc
; this method returns anOptional
that can be empty to indicate that a nominal descriptor could not be created for an instance. (For example,MethodHandle
will produce nominal descriptors for direct method handles, but not necessarily those produced by method handle combinators.)- Since:
- 12
- See The Java™ Virtual Machine Specification:
- 4.4 The Constant Pool, 4.4.10 The CONSTANT_InvokeDynamic_info Structure
-
-
Method Summary
Modifier and Type Method Description Optional<? extends ConstantDesc>
describeConstable()
-
-
-
Method Detail
-
describeConstable
Optional<? extends ConstantDesc> describeConstable()
-
-