ConstantDescs (Java SE 22 & JDK 22)
Description: declaration: module: java.base, package: java.lang.constant, class: ConstantDescs
Keywords: java.lang.constant.ConstantDescs class

Module java.base
Package java.lang.constant

# Class ConstantDescs

java.lang.Object
java.lang.constant.ConstantDescs

public final class ConstantDescs extends Object
Predefined values of nominal descriptor for common constants, including descriptors for primitive class types and other common platform types, and descriptors for method handles for standard bootstrap methods.

Since:
  12
See Also:
  - `ConstantDesc`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final DirectMethodHandleDesc`
  `BSM_CLASS_DATA`
  `MethodHandleDesc` representing `MethodHandles.classData`
  `static final DirectMethodHandleDesc`
  `BSM_CLASS_DATA_AT`
  `MethodHandleDesc` representing `MethodHandles.classDataAt`
  `static final DirectMethodHandleDesc`
  `BSM_ENUM_CONSTANT`
  `MethodHandleDesc` representing `ConstantBootstraps.enumConstant`
  `static final DirectMethodHandleDesc`
  `BSM_EXPLICIT_CAST`
  `MethodHandleDesc` representing `ConstantBootstraps.explicitCast`
  `static final DirectMethodHandleDesc`
  `BSM_GET_STATIC_FINAL`
  `MethodHandleDesc` representing `ConstantBootstraps.getStaticFinal`
  `static final DirectMethodHandleDesc`
  `BSM_INVOKE`
  `MethodHandleDesc` representing `ConstantBootstraps.invoke`
  `static final DirectMethodHandleDesc`
  `BSM_NULL_CONSTANT`
  `MethodHandleDesc` representing `ConstantBootstraps.nullConstant`
  `static final DirectMethodHandleDesc`
  `BSM_PRIMITIVE_CLASS`
  `MethodHandleDesc` representing `ConstantBootstraps.primitiveClass`
  `static final DirectMethodHandleDesc`
  `BSM_VARHANDLE_ARRAY`
  `MethodHandleDesc` representing `ConstantBootstraps.arrayVarHandle`
  `static final DirectMethodHandleDesc`
  `BSM_VARHANDLE_FIELD`
  `MethodHandleDesc` representing `ConstantBootstraps.fieldVarHandle`
  `static final DirectMethodHandleDesc`
  `BSM_VARHANDLE_STATIC_FIELD`
  `MethodHandleDesc` representing `ConstantBootstraps.staticFieldVarHandle`
  `static final ClassDesc`
  `CD_boolean`
  `ClassDesc` representing the primitive type `boolean`
  `static final ClassDesc`
  `CD_Boolean`
  `ClassDesc` representing `Boolean`
  `static final ClassDesc`
  `CD_byte`
  `ClassDesc` representing the primitive type `byte`
  `static final ClassDesc`
  `CD_Byte`
  `ClassDesc` representing `Byte`
  `static final ClassDesc`
  `CD_CallSite`
  `ClassDesc` representing `CallSite`
  `static final ClassDesc`
  `CD_char`
  `ClassDesc` representing the primitive type `char`
  `static final ClassDesc`
  `CD_Character`
  `ClassDesc` representing `Character`
  `static final ClassDesc`
  `CD_Class`
  `ClassDesc` representing `Class`
  `static final ClassDesc`
  `CD_ClassDesc`
  `ClassDesc` representing `ClassDesc`
  `static final ClassDesc`
  `CD_Collection`
  `ClassDesc` representing `Collection`
  `static final ClassDesc`
  `CD_ConstantBootstraps`
  `ClassDesc` representing `ConstantBootstraps`
  `static final ClassDesc`
  `CD_ConstantDesc`
  `ClassDesc` representing `ConstantDesc`
  `static final ClassDesc`
  `CD_DirectMethodHandleDesc`
  `ClassDesc` representing `DirectMethodHandleDesc`
  `static final ClassDesc`
  `CD_double`
  `ClassDesc` representing the primitive type `double`
  `static final ClassDesc`
  `CD_Double`
  `ClassDesc` representing `Double`
  `static final ClassDesc`
  `CD_DynamicCallSiteDesc`
  `ClassDesc` representing `DynamicCallSiteDesc`
  `static final ClassDesc`
  `CD_DynamicConstantDesc`
  `ClassDesc` representing `DynamicConstantDesc`
  `static final ClassDesc`
  `CD_Enum`
  `ClassDesc` representing `Enum`
  `static final ClassDesc`
  `CD_EnumDesc`
  `ClassDesc` representing `Enum.EnumDesc`
  `static final ClassDesc`
  `CD_Exception`
  `ClassDesc` representing `Exception`
  `static final ClassDesc`
  `CD_float`
  `ClassDesc` representing the primitive type `float`
  `static final ClassDesc`
  `CD_Float`
  `ClassDesc` representing `Float`
  `static final ClassDesc`
  `CD_int`
  `ClassDesc` representing the primitive type `int`
  `static final ClassDesc`
  `CD_Integer`
  `ClassDesc` representing `Integer`
  `static final ClassDesc`
  `CD_List`
  `ClassDesc` representing `List`
  `static final ClassDesc`
  `CD_long`
  `ClassDesc` representing the primitive type `long`
  `static final ClassDesc`
  `CD_Long`
  `ClassDesc` representing `Long`
  `static final ClassDesc`
  `CD_Map`
  `ClassDesc` representing `Map`
  `static final ClassDesc`
  `CD_MethodHandle`
  `ClassDesc` representing `MethodHandle`
  `static final ClassDesc`
  `CD_MethodHandleDesc`
  `ClassDesc` representing `MethodHandleDesc`
  `static final ClassDesc`
  `CD_MethodHandleDesc_Kind`
  `ClassDesc` representing `DirectMethodHandleDesc.Kind`
  `static final ClassDesc`
  `CD_MethodHandles`
  `ClassDesc` representing `MethodHandles`
  `static final ClassDesc`
  `CD_MethodHandles_Lookup`
  `ClassDesc` representing `MethodHandles.Lookup`
  `static final ClassDesc`
  `CD_MethodType`
  `ClassDesc` representing `MethodType`
  `static final ClassDesc`
  `CD_MethodTypeDesc`
  `ClassDesc` representing `MethodTypeDesc`
  `static final ClassDesc`
  `CD_Number`
  `ClassDesc` representing `Number`
  `static final ClassDesc`
  `CD_Object`
  `ClassDesc` representing `Object`
  `static final ClassDesc`
  `CD_Set`
  `ClassDesc` representing `Set`
  `static final ClassDesc`
  `CD_short`
  `ClassDesc` representing the primitive type `short`
  `static final ClassDesc`
  `CD_Short`
  `ClassDesc` representing `Short`
  `static final ClassDesc`
  `CD_String`
  `ClassDesc` representing `String`
  `static final ClassDesc`
  `CD_Throwable`
  `ClassDesc` representing `Throwable`
  `static final ClassDesc`
  `CD_VarHandle`
  `ClassDesc` representing `VarHandle`
  `static final ClassDesc`
  `CD_VarHandleDesc`
  `ClassDesc` representing `VarHandle.VarHandleDesc`
  `static final ClassDesc`
  `CD_void`
  `ClassDesc` representing the primitive type `void`
  `static final ClassDesc`
  `CD_Void`
  `ClassDesc` representing `Void`
  `static final String`
  `CLASS_INIT_NAME`
  The special name of class initialization methods, "<clinit>".
  `static final String`
  `DEFAULT_NAME`
  Invocation name to use when no name is needed, such as the name of a constructor, or the invocation name of a dynamic constant or dynamic callsite when the bootstrap is known to ignore the invocation name.
  `static final DynamicConstantDesc<Boolean>`
  `FALSE`
  Nominal descriptor representing the constant Boolean.FALSE
  `static final String`
  `INIT_NAME`
  The special name of instance initialization methods, "<init>".
  `static final MethodTypeDesc`
  `MTD_void`
  Nominal descriptor representing the method descriptor `()V`, taking no argument and returning `void`.
  `static final ConstantDesc`
  `NULL`
  Nominal descriptor representing the constant `null`
  `static final DynamicConstantDesc<Boolean>`
  `TRUE`
  Nominal descriptor representing the constant Boolean.TRUE

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static DirectMethodHandleDesc`
  `ofCallsiteBootstrap(ClassDesc owner, String name, ClassDesc returnType, ClassDesc... paramTypes)`
  Returns a `MethodHandleDesc` corresponding to a bootstrap method for an `invokedynamic` callsite, which is a static method whose leading parameter types are `Lookup`, `String`, and `MethodType`.
  `static DirectMethodHandleDesc`
  `ofConstantBootstrap(ClassDesc owner, String name, ClassDesc returnType, ClassDesc... paramTypes)`
  Returns a `MethodHandleDesc` corresponding to a bootstrap method for a dynamic constant, which is a static method whose leading arguments are `Lookup`, `String`, and `Class`.

  ### Methods declared in class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_NAME

    public static final String DEFAULT_NAME
    Invocation name to use when no name is needed, such as the name of a constructor, or the invocation name of a dynamic constant or dynamic callsite when the bootstrap is known to ignore the invocation name.
    See Also:
      - Constant Field Values

  - ### CD_Object

    public static final ClassDesc CD_Object
    `ClassDesc` representing `Object`

  - ### CD_String

    public static final ClassDesc CD_String
    `ClassDesc` representing `String`

  - ### CD_Class

    public static final ClassDesc CD_Class
    `ClassDesc` representing `Class`

  - ### CD_Number

    public static final ClassDesc CD_Number
    `ClassDesc` representing `Number`

  - ### CD_Integer

    public static final ClassDesc CD_Integer
    `ClassDesc` representing `Integer`

  - ### CD_Long

    public static final ClassDesc CD_Long
    `ClassDesc` representing `Long`

  - ### CD_Float

    public static final ClassDesc CD_Float
    `ClassDesc` representing `Float`

  - ### CD_Double

    public static final ClassDesc CD_Double
    `ClassDesc` representing `Double`

  - ### CD_Short

    public static final ClassDesc CD_Short
    `ClassDesc` representing `Short`

  - ### CD_Byte

    public static final ClassDesc CD_Byte
    `ClassDesc` representing `Byte`

  - ### CD_Character

    public static final ClassDesc CD_Character
    `ClassDesc` representing `Character`

  - ### CD_Boolean

    public static final ClassDesc CD_Boolean
    `ClassDesc` representing `Boolean`

  - ### CD_Void

    public static final ClassDesc CD_Void
    `ClassDesc` representing `Void`

  - ### CD_Throwable

    public static final ClassDesc CD_Throwable
    `ClassDesc` representing `Throwable`

  - ### CD_Exception

    public static final ClassDesc CD_Exception
    `ClassDesc` representing `Exception`

  - ### CD_Enum

    public static final ClassDesc CD_Enum
    `ClassDesc` representing `Enum`

  - ### CD_VarHandle

    public static final ClassDesc CD_VarHandle
    `ClassDesc` representing `VarHandle`

  - ### CD_MethodHandles

    public static final ClassDesc CD_MethodHandles
    `ClassDesc` representing `MethodHandles`

  - ### CD_MethodHandles_Lookup

    public static final ClassDesc CD_MethodHandles_Lookup
    `ClassDesc` representing `MethodHandles.Lookup`

  - ### CD_MethodHandle

    public static final ClassDesc CD_MethodHandle
    `ClassDesc` representing `MethodHandle`

  - ### CD_MethodType

    public static final ClassDesc CD_MethodType
    `ClassDesc` representing `MethodType`

  - ### CD_CallSite

    public static final ClassDesc CD_CallSite
    `ClassDesc` representing `CallSite`

  - ### CD_Collection

    public static final ClassDesc CD_Collection
    `ClassDesc` representing `Collection`

  - ### CD_List

    public static final ClassDesc CD_List
    `ClassDesc` representing `List`

  - ### CD_Set

    public static final ClassDesc CD_Set
    `ClassDesc` representing `Set`

  - ### CD_Map

    public static final ClassDesc CD_Map
    `ClassDesc` representing `Map`

  - ### CD_ConstantDesc

    public static final ClassDesc CD_ConstantDesc
    `ClassDesc` representing `ConstantDesc`

  - ### CD_ClassDesc

    public static final ClassDesc CD_ClassDesc
    `ClassDesc` representing `ClassDesc`

  - ### CD_EnumDesc

    public static final ClassDesc CD_EnumDesc
    `ClassDesc` representing `Enum.EnumDesc`

  - ### CD_MethodTypeDesc

    public static final ClassDesc CD_MethodTypeDesc
    `ClassDesc` representing `MethodTypeDesc`

  - ### CD_MethodHandleDesc

    public static final ClassDesc CD_MethodHandleDesc
    `ClassDesc` representing `MethodHandleDesc`

  - ### CD_DirectMethodHandleDesc

    public static final ClassDesc CD_DirectMethodHandleDesc
    `ClassDesc` representing `DirectMethodHandleDesc`

  - ### CD_VarHandleDesc

    public static final ClassDesc CD_VarHandleDesc
    `ClassDesc` representing `VarHandle.VarHandleDesc`

  - ### CD_MethodHandleDesc_Kind

    public static final ClassDesc CD_MethodHandleDesc_Kind
    `ClassDesc` representing `DirectMethodHandleDesc.Kind`

  - ### CD_DynamicConstantDesc

    public static final ClassDesc CD_DynamicConstantDesc
    `ClassDesc` representing `DynamicConstantDesc`

  - ### CD_DynamicCallSiteDesc

    public static final ClassDesc CD_DynamicCallSiteDesc
    `ClassDesc` representing `DynamicCallSiteDesc`

  - ### CD_ConstantBootstraps

    public static final ClassDesc CD_ConstantBootstraps
    `ClassDesc` representing `ConstantBootstraps`

  - ### BSM_PRIMITIVE_CLASS

    public static final DirectMethodHandleDesc BSM_PRIMITIVE_CLASS
    `MethodHandleDesc` representing `ConstantBootstraps.primitiveClass`

  - ### BSM_ENUM_CONSTANT

    public static final DirectMethodHandleDesc BSM_ENUM_CONSTANT
    `MethodHandleDesc` representing `ConstantBootstraps.enumConstant`

  - ### BSM_GET_STATIC_FINAL

    public static final DirectMethodHandleDesc BSM_GET_STATIC_FINAL
    `MethodHandleDesc` representing `ConstantBootstraps.getStaticFinal`
    Since:
      15

  - ### BSM_NULL_CONSTANT

    public static final DirectMethodHandleDesc BSM_NULL_CONSTANT
    `MethodHandleDesc` representing `ConstantBootstraps.nullConstant`

  - ### BSM_VARHANDLE_FIELD

    public static final DirectMethodHandleDesc BSM_VARHANDLE_FIELD
    `MethodHandleDesc` representing `ConstantBootstraps.fieldVarHandle`

  - ### BSM_VARHANDLE_STATIC_FIELD

    public static final DirectMethodHandleDesc BSM_VARHANDLE_STATIC_FIELD
    `MethodHandleDesc` representing `ConstantBootstraps.staticFieldVarHandle`

  - ### BSM_VARHANDLE_ARRAY

    public static final DirectMethodHandleDesc BSM_VARHANDLE_ARRAY
    `MethodHandleDesc` representing `ConstantBootstraps.arrayVarHandle`

  - ### BSM_INVOKE

    public static final DirectMethodHandleDesc BSM_INVOKE
    `MethodHandleDesc` representing `ConstantBootstraps.invoke`

  - ### BSM_EXPLICIT_CAST

    public static final DirectMethodHandleDesc BSM_EXPLICIT_CAST
    `MethodHandleDesc` representing `ConstantBootstraps.explicitCast`
    Since:
      15

  - ### CD_int

    public static final ClassDesc CD_int
    `ClassDesc` representing the primitive type `int`

  - ### CD_long

    public static final ClassDesc CD_long
    `ClassDesc` representing the primitive type `long`

  - ### CD_float

    public static final ClassDesc CD_float
    `ClassDesc` representing the primitive type `float`

  - ### CD_double

    public static final ClassDesc CD_double
    `ClassDesc` representing the primitive type `double`

  - ### CD_short

    public static final ClassDesc CD_short
    `ClassDesc` representing the primitive type `short`

  - ### CD_byte

    public static final ClassDesc CD_byte
    `ClassDesc` representing the primitive type `byte`

  - ### CD_char

    public static final ClassDesc CD_char
    `ClassDesc` representing the primitive type `char`

  - ### CD_boolean

    public static final ClassDesc CD_boolean
    `ClassDesc` representing the primitive type `boolean`

  - ### CD_void

    public static final ClassDesc CD_void
    `ClassDesc` representing the primitive type `void`

  - ### BSM_CLASS_DATA

    public static final DirectMethodHandleDesc BSM_CLASS_DATA
    `MethodHandleDesc` representing `MethodHandles.classData`
    Since:
      21

  - ### BSM_CLASS_DATA_AT

    public static final DirectMethodHandleDesc BSM_CLASS_DATA_AT
    `MethodHandleDesc` representing `MethodHandles.classDataAt`
    Since:
      21

  - ### NULL

    public static final ConstantDesc NULL
    Nominal descriptor representing the constant `null`

  - ### TRUE

    public static final DynamicConstantDesc<Boolean> TRUE
    Nominal descriptor representing the constant Boolean.TRUE
    Since:
      15

  - ### FALSE

    public static final DynamicConstantDesc<Boolean> FALSE
    Nominal descriptor representing the constant Boolean.FALSE
    Since:
      15

  - ### INIT_NAME

    public static final String INIT_NAME
    The special name of instance initialization methods, "<init>". An instance initialization method has this special name and is `void`.
    See Java Virtual Machine Specification:
      2.9.1 Instance Initialization Methods
    Since:
      21
    See Also:
      - Constant Field Values

  - ### CLASS_INIT_NAME

    public static final String CLASS_INIT_NAME
    The special name of class initialization methods, "<clinit>". A class initialization method has this special name, `ACC_STATIC` flag set, is `void` and takes no arguments.
    See Java Virtual Machine Specification:
      2.9.2 Class Initialization Methods
    Since:
      21
    See Also:
      - Constant Field Values

  - ### MTD_void

    public static final MethodTypeDesc MTD_void
    Nominal descriptor representing the method descriptor `()V`, taking no argument and returning `void`.
    Since:
      21

- ## Method Details

  - ### ofCallsiteBootstrap

    public static DirectMethodHandleDesc ofCallsiteBootstrap(ClassDesc owner, String name, ClassDesc returnType, ClassDesc... paramTypes)
    Returns a `MethodHandleDesc` corresponding to a bootstrap method for an `invokedynamic` callsite, which is a static method whose leading parameter types are `Lookup`, `String`, and `MethodType`.
    Parameters:
      `owner` - the class declaring the method
      `name` - the unqualified name of the method
      `returnType` - the return type of the method
      `paramTypes` - the types of the static bootstrap arguments, if any
    Returns:
      the `MethodHandleDesc`
    Throws:
      `NullPointerException` - if any of the arguments are null
    See Java Virtual Machine Specification:
      4.2.2 Unqualified Names

  - ### ofConstantBootstrap

    public static DirectMethodHandleDesc ofConstantBootstrap(ClassDesc owner, String name, ClassDesc returnType, ClassDesc... paramTypes)
    Returns a `MethodHandleDesc` corresponding to a bootstrap method for a dynamic constant, which is a static method whose leading arguments are `Lookup`, `String`, and `Class`.
    Parameters:
      `owner` - the class declaring the method
      `name` - the unqualified name of the method
      `returnType` - the return type of the method
      `paramTypes` - the types of the static bootstrap arguments, if any
    Returns:
      the `MethodHandleDesc`
    Throws:
      `NullPointerException` - if any of the arguments are null
    See Java Virtual Machine Specification:
      4.2.2 Unqualified Names