Class CstMethodHandle

All Implemented Interfaces:
TypeBearer, ToHuman, Comparable<Constant>

public final class CstMethodHandle extends TypedConstant
Constants of type MethodHandle.
  • Field Details

    • METHOD_HANDLE_TYPE_STATIC_PUT

      public static final int METHOD_HANDLE_TYPE_STATIC_PUT
      See Also:
    • METHOD_HANDLE_TYPE_STATIC_GET

      public static final int METHOD_HANDLE_TYPE_STATIC_GET
      See Also:
    • METHOD_HANDLE_TYPE_INSTANCE_PUT

      public static final int METHOD_HANDLE_TYPE_INSTANCE_PUT
      See Also:
    • METHOD_HANDLE_TYPE_INSTANCE_GET

      public static final int METHOD_HANDLE_TYPE_INSTANCE_GET
      See Also:
    • METHOD_HANDLE_TYPE_INVOKE_STATIC

      public static final int METHOD_HANDLE_TYPE_INVOKE_STATIC
      See Also:
    • METHOD_HANDLE_TYPE_INVOKE_INSTANCE

      public static final int METHOD_HANDLE_TYPE_INVOKE_INSTANCE
      See Also:
    • METHOD_HANDLE_TYPE_INVOKE_CONSTRUCTOR

      public static final int METHOD_HANDLE_TYPE_INVOKE_CONSTRUCTOR
      See Also:
    • METHOD_HANDLE_TYPE_INVOKE_DIRECT

      public static final int METHOD_HANDLE_TYPE_INVOKE_DIRECT
      See Also:
    • METHOD_HANDLE_TYPE_INVOKE_INTERFACE

      public static final int METHOD_HANDLE_TYPE_INVOKE_INTERFACE
      See Also:
  • Method Details

    • make

      public static CstMethodHandle make(int type, Constant ref)
      Makes an instance for the given value. This may (but does not necessarily) return an already-allocated instance.
      Parameters:
      type - the type of this handle
      ref - non-null; the referenced field or method constant
      Returns:
      non-null; the appropriate instance
    • getRef

      public Constant getRef()
      Gets the actual constant.
      Returns:
      the value
    • getMethodHandleType

      public int getMethodHandleType()
      Gets the type of this method handle.
      Returns:
      the type
    • isAccessor

      public static boolean isAccessor(int type)
      Reports whether the method handle type is a field accessor.
      Parameters:
      type - the method handle type
      Returns:
      true if the method handle type is a field accessor, false otherwise
    • isAccessor

      public boolean isAccessor()
      Reports whether the method handle is a field accessor.
      Returns:
      true if the method handle is a field accessor, false otherwise
    • isInvocation

      public static boolean isInvocation(int type)
      Reports whether the method handle type is a method invocation.
      Parameters:
      type - the method handle type
      Returns:
      true if the method handle type is a method invocation, false otherwise
    • isInvocation

      public boolean isInvocation()
      Reports whether the method handle is a method invocation.
      Returns:
      true if the method handle is a method invocation, false otherwise
    • getMethodHandleTypeName

      public static String getMethodHandleTypeName(int type)
      Gets a human readable name for a method handle type.
      Parameters:
      type - the method handle type
      Returns:
      the string representation of the type
    • isCategory2

      public boolean isCategory2()
      Returns true if this instance is a category-2 constant, meaning it takes up two slots in the constant pool, or false if this instance is category-1.
      Specified by:
      isCategory2 in class Constant
      Returns:
      true iff this instance is category-2
    • compareTo0

      protected int compareTo0(Constant other)
      Compare the values of this and another instance, which are guaranteed to be of the same class. Subclasses must implement this.
      Specified by:
      compareTo0 in class Constant
      Parameters:
      other - non-null; the instance to compare to
      Returns:
      -1, 0, or 1, as usual for a comparison
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • typeName

      public String typeName()
      Returns the human name for the particular type of constant this instance is.
      Specified by:
      typeName in class Constant
      Returns:
      non-null; the name
    • toHuman

      public String toHuman()
      Return the "human" string form of this instance. This is generally less "debuggy" than toString().
      Returns:
      non-null; the human string form
    • getType

      public Type getType()
      Description copied from interface: TypeBearer
      Gets the type associated with this instance.
      Returns:
      non-null; the type