Class TypePath

java.lang.Object
org.objectweb.asm.TypePath

public final class TypePath extends Object
The path to a type argument, wildcard bound, array element type, or static inner type within an enclosing type.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    A type path step that steps into the element type of an array type.
    static final int
    A type path step that steps into the nested type of a class type.
    static final int
    A type path step that steps into a type argument of a generic type.
    private final byte[]
    The byte array where the 'type_path' structure - as defined in the Java Virtual Machine Specification (JVMS) - corresponding to this TypePath is stored.
    private final int
    The offset of the first byte of the type_path JVMS structure in typePathContainer.
    static final int
    A type path step that steps into the bound of a wildcard type.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TypePath(byte[] typePathContainer, int typePathOffset)
    Constructs a new TypePath.
  • Method Summary

    Modifier and Type
    Method
    Description
    static TypePath
    fromString(String typePath)
    Converts a type path in string form, in the format used by toString(), into a TypePath object.
    int
    Returns the length of this path, i.e.
    int
    getStep(int index)
    Returns the value of the given step of this path.
    int
    getStepArgument(int index)
    Returns the index of the type argument that the given step is stepping into.
    (package private) static void
    put(TypePath typePath, ByteVector output)
    Puts the type_path JVMS structure corresponding to the given TypePath into the given ByteVector.
    Returns a string representation of this type path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ARRAY_ELEMENT

      public static final int ARRAY_ELEMENT
      A type path step that steps into the element type of an array type. See getStep(int).
      See Also:
    • INNER_TYPE

      public static final int INNER_TYPE
      A type path step that steps into the nested type of a class type. See getStep(int).
      See Also:
    • WILDCARD_BOUND

      public static final int WILDCARD_BOUND
      A type path step that steps into the bound of a wildcard type. See getStep(int).
      See Also:
    • TYPE_ARGUMENT

      public static final int TYPE_ARGUMENT
      A type path step that steps into a type argument of a generic type. See getStep(int).
      See Also:
    • typePathContainer

      private final byte[] typePathContainer
      The byte array where the 'type_path' structure - as defined in the Java Virtual Machine Specification (JVMS) - corresponding to this TypePath is stored. The first byte of the structure in this array is given by typePathOffset.
      See Also:
    • typePathOffset

      private final int typePathOffset
      The offset of the first byte of the type_path JVMS structure in typePathContainer.
  • Constructor Details

    • TypePath

      TypePath(byte[] typePathContainer, int typePathOffset)
      Constructs a new TypePath.
      Parameters:
      typePathContainer - a byte array containing a type_path JVMS structure.
      typePathOffset - the offset of the first byte of the type_path structure in typePathContainer.
  • Method Details

    • getLength

      public int getLength()
      Returns the length of this path, i.e. its number of steps.
      Returns:
      the length of this path.
    • getStep

      public int getStep(int index)
      Returns the value of the given step of this path.
      Parameters:
      index - an index between 0 and getLength(), exclusive.
      Returns:
      one of ARRAY_ELEMENT, INNER_TYPE, WILDCARD_BOUND, or TYPE_ARGUMENT.
    • getStepArgument

      public int getStepArgument(int index)
      Returns the index of the type argument that the given step is stepping into. This method should only be used for steps whose value is TYPE_ARGUMENT.
      Parameters:
      index - an index between 0 and getLength(), exclusive.
      Returns:
      the index of the type argument that the given step is stepping into.
    • fromString

      public static TypePath fromString(String typePath)
      Converts a type path in string form, in the format used by toString(), into a TypePath object.
      Parameters:
      typePath - a type path in string form, in the format used by toString(). May be null or empty.
      Returns:
      the corresponding TypePath object, or null if the path is empty.
    • toString

      public String toString()
      Returns a string representation of this type path. ARRAY_ELEMENT steps are represented with '[', INNER_TYPE steps with '.', WILDCARD_BOUND steps with '*' and TYPE_ARGUMENT steps with their type argument index in decimal form followed by ';'.
      Overrides:
      toString in class Object
    • put

      static void put(TypePath typePath, ByteVector output)
      Puts the type_path JVMS structure corresponding to the given TypePath into the given ByteVector.
      Parameters:
      typePath - a TypePath instance, or null for empty paths.
      output - where the type path must be put.