VarHandle.VarHandleDesc (Java SE 26 & JDK 26)
Description: declaration: module: java.base, package: java.lang.invoke, class: VarHandle, class: VarHandleDesc
Keywords: java.lang.invoke.VarHandle.VarHandleDesc class

# Class VarHandle.VarHandleDesc

java.lang.Object
java.lang.constant.DynamicConstantDesc<VarHandle>
java.lang.invoke.VarHandle.VarHandleDesc

All Implemented Interfaces:
  `ConstantDesc`

Enclosing class:
  `VarHandle`

public static final class VarHandle.VarHandleDesc extends DynamicConstantDesc<VarHandle>
A nominal descriptor for a `VarHandle` constant.

Since:
  12

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static VarHandle.VarHandleDesc`
  `ofArray(ClassDesc arrayClass)`
  Returns a VarHandle.VarHandleDesc corresponding to a `VarHandle` for an array type.
  `static VarHandle.VarHandleDesc`
  `ofField(ClassDesc declaringClass, String name, ClassDesc fieldType)`
  Returns a VarHandle.VarHandleDesc corresponding to a `VarHandle` for an instance field.
  `static VarHandle.VarHandleDesc`
  `ofStaticField(ClassDesc declaringClass, String name, ClassDesc fieldType)`
  Returns a VarHandle.VarHandleDesc corresponding to a `VarHandle` for a static field.
  `String`
  `toString()`
  Returns a compact textual description of this constant description.
  `ClassDesc`
  `varType()`
  Returns a `ClassDesc` describing the type of the variable described by this descriptor.

  ### Methods declared in class DynamicConstantDesc

  `bootstrapArgs, bootstrapArgsList, bootstrapMethod, constantName, constantType, equals, hashCode, of, of, ofCanonical, ofNamed, resolveConstantDesc`
  Modifier and Type
  Method
  Description
  `ConstantDesc[]`
  `bootstrapArgs()`
  Returns the bootstrap arguments for this constant.
  `List<ConstantDesc>`
  `bootstrapArgsList()`
  Returns the bootstrap arguments for this constant as an immutable `List`.
  `DirectMethodHandleDesc`
  `bootstrapMethod()`
  Returns a `MethodHandleDesc` describing the bootstrap method for this constant.
  `String`
  `constantName()`
  Returns the name that would appear in the `NameAndType` operand of the `LDC` for this constant.
  `ClassDesc`
  `constantType()`
  Returns a `ClassDesc` describing the type that would appear in the `NameAndType` operand of the `LDC` for this constant.
  `final boolean`
  `equals(Object o)`
  Compares the specified object with this descriptor for equality.
  `final int`
  `hashCode()`
  Returns a hash code value for this object.
  `static <T> DynamicConstantDesc<T>`
  `of(DirectMethodHandleDesc bootstrapMethod)`
  Returns a nominal descriptor for a dynamic constant whose bootstrap has no static arguments, whose name parameter is `ConstantDescs.DEFAULT_NAME`, and whose type parameter is always the same as the bootstrap method return type.
  `static <T> DynamicConstantDesc<T>`
  `of(DirectMethodHandleDesc bootstrapMethod, ConstantDesc... bootstrapArgs)`
  Returns a nominal descriptor for a dynamic constant whose name parameter is `ConstantDescs.DEFAULT_NAME`, and whose type parameter is always the same as the bootstrap method return type.
  `static <T> ConstantDesc`
  `ofCanonical(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc[] bootstrapArgs)`
  Returns a nominal descriptor for a dynamic constant, transforming it into a more specific type if the constant bootstrap is a well-known one and a more specific nominal descriptor type (e.g., ClassDesc) is available.
  `static <T> DynamicConstantDesc<T>`
  `ofNamed(DirectMethodHandleDesc bootstrapMethod, String constantName, ClassDesc constantType, ConstantDesc... bootstrapArgs)`
  Returns a nominal descriptor for a dynamic constant.
  `VarHandle`
  `resolveConstantDesc(MethodHandles.Lookup lookup)`
  Resolves this descriptor reflectively, emulating the resolution behavior of JVMS 5.4.3 and the access control behavior of JVMS 5.4.4.

  ### Methods declared in class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Method Details

  - ### ofField

    public static VarHandle.VarHandleDesc ofField(ClassDesc declaringClass, String name, ClassDesc fieldType)
    Returns a VarHandle.VarHandleDesc corresponding to a `VarHandle` for an instance field.
    Parameters:
      `declaringClass` - a `ClassDesc` describing the declaring class, for field var handles
      `name` - the unqualified name of the field
      `fieldType` - a `ClassDesc` describing the type of the field
    Returns:
      the VarHandle.VarHandleDesc
    Throws:
      `NullPointerException` - if any of the arguments are null
    See Java Virtual Machine Specification:
      4.2.2 Unqualified Names

  - ### ofStaticField

    public static VarHandle.VarHandleDesc ofStaticField(ClassDesc declaringClass, String name, ClassDesc fieldType)
    Returns a VarHandle.VarHandleDesc corresponding to a `VarHandle` for a static field.
    Parameters:
      `declaringClass` - a `ClassDesc` describing the declaring class, for field var handles
      `name` - the unqualified name of the field
      `fieldType` - a `ClassDesc` describing the type of the field
    Returns:
      the VarHandle.VarHandleDesc
    Throws:
      `NullPointerException` - if any of the arguments are null
    See Java Virtual Machine Specification:
      4.2.2 Unqualified Names

  - ### ofArray

    public static VarHandle.VarHandleDesc ofArray(ClassDesc arrayClass)
    Returns a VarHandle.VarHandleDesc corresponding to a `VarHandle` for an array type.
    Parameters:
      `arrayClass` - a `ClassDesc` describing the type of the array
    Returns:
      the VarHandle.VarHandleDesc
    Throws:
      `NullPointerException` - if any of the arguments are null

  - ### varType

    public ClassDesc varType()
    Returns a `ClassDesc` describing the type of the variable described by this descriptor.
    Returns:
      the variable type

  - ### toString

    public String toString()
    Returns a compact textual description of this constant description. For a field VarHandle, includes the owner, name, and type of the field, and whether it is static; for an array VarHandle, the name of the component type.
    Overrides:
      `toString` in class `DynamicConstantDesc<VarHandle>`
    Returns:
      A compact textual description of this descriptor