Constable (Java SE 17 & JDK 17) JavaScript is disabled on your browser. Skip navigation links Java SE 17 & JDK 17 Overview Module Package Class Use Tree Preview New Deprecated Index Help Summary:  Nested |  Field |  Constr |  Method Detail:  Field |  Constr |  Method SEARCH: Module java.base Package java.lang.constant Interface Constable All Known Subinterfaces: MemoryLayout 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 a ConstantDesc. Some constable types have a native representation in the constant pool: String, Integer, Long, Float, Double, Class, MethodType, and MethodHandle. The types String, Integer, Long, Float, and Double serve as their own nominal descriptors; Class, MethodType, and MethodHandle have corresponding nominal descriptors ClassDesc, MethodTypeDesc, and MethodHandleDesc. 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 Enum, 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 a ConstantDesc; this method returns an Optional 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.) See Java Virtual Machine Specification: 4.4 The Constant Pool 4.4.10 The CONSTANT_Dynamic_info and CONSTANT_InvokeDynamic_info Structures Since: 12 Method Summary All MethodsInstance MethodsAbstract Methods Modifier and Type Method Description Optional<? extends ConstantDesc> describeConstable() Returns an Optional containing the nominal descriptor for this instance, if one can be constructed, or an empty Optional if one cannot be constructed. Method Details describeConstable Optional<? extends ConstantDesc> describeConstable() Returns an Optional containing the nominal descriptor for this instance, if one can be constructed, or an empty Optional if one cannot be constructed. Returns: An Optional containing the resulting nominal descriptor, or an empty Optional if one cannot be constructed. Report a bug or suggest an enhancement For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions. Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries. Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA. All rights reserved. Use is subject to license terms and the documentation redistribution policy. Scripting on this page tracks web page traffic, but does not change the content in any way.