org.objectweb.asm

## Class TypeReference

- java.lang.Object
- - org.objectweb.asm.TypeReference

-     public class TypeReference
      extends Object

  A reference to a type appearing in a class, field or method declaration, or on an instruction. Such a reference designates the part of the class where the referenced type is appearing (e.g. an 'extends', 'implements' or 'throws' clause, a 'new' instruction, a 'catch' clause, a type cast, a local variable declaration, etc).
  Author:
    Eric Bruneton

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `CAST` The sort of type references that target the type declared in an explicit or implicit cast instruction.
    `static int` | `CLASS_EXTENDS` The sort of type references that target the super class of a class or one of the interfaces it implements.
    `static int` | `CLASS_TYPE_PARAMETER` The sort of type references that target a type parameter of a generic class.
    `static int` | `CLASS_TYPE_PARAMETER_BOUND` The sort of type references that target a bound of a type parameter of a generic class.
    `static int` | `CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT` The sort of type references that target a type parameter of a generic constructor in a constructor call.
    `static int` | `CONSTRUCTOR_REFERENCE` The sort of type references that target the receiver type of a constructor reference.
    `static int` | `CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT` The sort of type references that target a type parameter of a generic constructor in a constructor reference.
    `static int` | `EXCEPTION_PARAMETER` The sort of type references that target the type of the exception of a 'catch' clause in a method.
    `static int` | `FIELD` The sort of type references that target the type of a field.
    `static int` | `INSTANCEOF` The sort of type references that target the type declared in an 'instanceof' instruction.
    `static int` | `LOCAL_VARIABLE` The sort of type references that target the type of a local variable in a method.
    `static int` | `METHOD_FORMAL_PARAMETER` The sort of type references that target the type of a formal parameter of a method.
    `static int` | `METHOD_INVOCATION_TYPE_ARGUMENT` The sort of type references that target a type parameter of a generic method in a method call.
    `static int` | `METHOD_RECEIVER` The sort of type references that target the receiver type of a method.
    `static int` | `METHOD_REFERENCE` The sort of type references that target the receiver type of a method reference.
    `static int` | `METHOD_REFERENCE_TYPE_ARGUMENT` The sort of type references that target a type parameter of a generic method in a method reference.
    `static int` | `METHOD_RETURN` The sort of type references that target the return type of a method.
    `static int` | `METHOD_TYPE_PARAMETER` The sort of type references that target a type parameter of a generic method.
    `static int` | `METHOD_TYPE_PARAMETER_BOUND` The sort of type references that target a bound of a type parameter of a generic method.
    `static int` | `NEW` The sort of type references that target the type of the object created by a 'new' instruction.
    `static int` | `RESOURCE_VARIABLE` The sort of type references that target the type of a resource variable in a method.
    `static int` | `THROWS` The sort of type references that target the type of an exception declared in the throws clause of a method.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TypeReference(int typeRef)` Creates a new TypeReference.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getExceptionIndex()` Returns the index of the exception, in a 'throws' clause of a method, whose type is referenced by this type reference.
    `int` | `getFormalParameterIndex()` Returns the index of the formal parameter whose type is referenced by this type reference.
    `int` | `getSort()` Returns the sort of this type reference.
    `int` | `getSuperTypeIndex()` Returns the index of the "super type" of a class that is referenced by this type reference.
    `int` | `getTryCatchBlockIndex()` Returns the index of the try catch block (using the order in which they are visited with visitTryCatchBlock), whose 'catch' type is referenced by this type reference.
    `int` | `getTypeArgumentIndex()` Returns the index of the type argument referenced by this type reference.
    `int` | `getTypeParameterBoundIndex()` Returns the index of the type parameter bound, within the type parameter `getTypeParameterIndex()`, referenced by this type reference.
    `int` | `getTypeParameterIndex()` Returns the index of the type parameter referenced by this type reference.
    `int` | `getValue()` Returns the int encoded value of this type reference, suitable for use in visit methods related to type annotations, like visitTypeAnnotation.
    `static TypeReference` | `newExceptionReference(int exceptionIndex)` Returns a reference to the type of an exception, in a 'throws' clause of a method.
    `static TypeReference` | `newFormalParameterReference(int paramIndex)` Returns a reference to the type of a formal parameter of a method.
    `static TypeReference` | `newSuperTypeReference(int itfIndex)` Returns a reference to the super class or to an interface of the 'implements' clause of a class.
    `static TypeReference` | `newTryCatchReference(int tryCatchBlockIndex)` Returns a reference to the type of the exception declared in a 'catch' clause of a method.
    `static TypeReference` | `newTypeArgumentReference(int sort, int argIndex)` Returns a reference to the type of a type argument in a constructor or method call or reference.
    `static TypeReference` | `newTypeParameterBoundReference(int sort, int paramIndex, int boundIndex)` Returns a reference to a type parameter bound of a generic class or method.
    `static TypeReference` | `newTypeParameterReference(int sort, int paramIndex)` Returns a reference to a type parameter of a generic class or method.
    `static TypeReference` | `newTypeReference(int sort)` Returns a type reference of the given sort.

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### CLASS_TYPE_PARAMETER

          public static final int CLASS_TYPE_PARAMETER

      The sort of type references that target a type parameter of a generic class. See `getSort`.
      See Also:
        Constant Field Values

    - #### METHOD_TYPE_PARAMETER

          public static final int METHOD_TYPE_PARAMETER

      The sort of type references that target a type parameter of a generic method. See `getSort`.
      See Also:
        Constant Field Values

    - #### CLASS_EXTENDS

          public static final int CLASS_EXTENDS

      The sort of type references that target the super class of a class or one of the interfaces it implements. See `getSort`.
      See Also:
        Constant Field Values

    - #### CLASS_TYPE_PARAMETER_BOUND

          public static final int CLASS_TYPE_PARAMETER_BOUND

      The sort of type references that target a bound of a type parameter of a generic class. See `getSort`.
      See Also:
        Constant Field Values

    - #### METHOD_TYPE_PARAMETER_BOUND

          public static final int METHOD_TYPE_PARAMETER_BOUND

      The sort of type references that target a bound of a type parameter of a generic method. See `getSort`.
      See Also:
        Constant Field Values

    - #### FIELD

          public static final int FIELD

      The sort of type references that target the type of a field. See `getSort`.
      See Also:
        Constant Field Values

    - #### METHOD_RETURN

          public static final int METHOD_RETURN

      The sort of type references that target the return type of a method. See `getSort`.
      See Also:
        Constant Field Values

    - #### METHOD_RECEIVER

          public static final int METHOD_RECEIVER

      The sort of type references that target the receiver type of a method. See `getSort`.
      See Also:
        Constant Field Values

    - #### METHOD_FORMAL_PARAMETER

          public static final int METHOD_FORMAL_PARAMETER

      The sort of type references that target the type of a formal parameter of a method. See `getSort`.
      See Also:
        Constant Field Values

    - #### THROWS

          public static final int THROWS

      The sort of type references that target the type of an exception declared in the throws clause of a method. See `getSort`.
      See Also:
        Constant Field Values

    - #### LOCAL_VARIABLE

          public static final int LOCAL_VARIABLE

      The sort of type references that target the type of a local variable in a method. See `getSort`.
      See Also:
        Constant Field Values

    - #### RESOURCE_VARIABLE

          public static final int RESOURCE_VARIABLE

      The sort of type references that target the type of a resource variable in a method. See `getSort`.
      See Also:
        Constant Field Values

    - #### EXCEPTION_PARAMETER

          public static final int EXCEPTION_PARAMETER

      The sort of type references that target the type of the exception of a 'catch' clause in a method. See `getSort`.
      See Also:
        Constant Field Values

    - #### INSTANCEOF

          public static final int INSTANCEOF

      The sort of type references that target the type declared in an 'instanceof' instruction. See `getSort`.
      See Also:
        Constant Field Values

    - #### NEW

          public static final int NEW

      The sort of type references that target the type of the object created by a 'new' instruction. See `getSort`.
      See Also:
        Constant Field Values

    - #### CONSTRUCTOR_REFERENCE

          public static final int CONSTRUCTOR_REFERENCE

      The sort of type references that target the receiver type of a constructor reference. See `getSort`.
      See Also:
        Constant Field Values

    - #### METHOD_REFERENCE

          public static final int METHOD_REFERENCE

      The sort of type references that target the receiver type of a method reference. See `getSort`.
      See Also:
        Constant Field Values

    - #### CAST

          public static final int CAST

      The sort of type references that target the type declared in an explicit or implicit cast instruction. See `getSort`.
      See Also:
        Constant Field Values

    - #### CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT

          public static final int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT

      The sort of type references that target a type parameter of a generic constructor in a constructor call. See `getSort`.
      See Also:
        Constant Field Values

    - #### METHOD_INVOCATION_TYPE_ARGUMENT

          public static final int METHOD_INVOCATION_TYPE_ARGUMENT

      The sort of type references that target a type parameter of a generic method in a method call. See `getSort`.
      See Also:
        Constant Field Values

    - #### CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT

          public static final int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT

      The sort of type references that target a type parameter of a generic constructor in a constructor reference. See `getSort`.
      See Also:
        Constant Field Values

    - #### METHOD_REFERENCE_TYPE_ARGUMENT

          public static final int METHOD_REFERENCE_TYPE_ARGUMENT

      The sort of type references that target a type parameter of a generic method in a method reference. See `getSort`.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TypeReference

          public TypeReference(int typeRef)

      Creates a new TypeReference.
      Parameters:
        `typeRef` - the int encoded value of the type reference, as received in a visit method related to type annotations, like visitTypeAnnotation.

  - ### Method Detail

    - #### newTypeReference

          public static TypeReference newTypeReference(int sort)

      Returns a type reference of the given sort.
      Parameters:
        `sort` - `FIELD`, `METHOD_RETURN`, `METHOD_RECEIVER`, `LOCAL_VARIABLE`, `RESOURCE_VARIABLE`, `INSTANCEOF`, `NEW`, `CONSTRUCTOR_REFERENCE`, or `METHOD_REFERENCE`.
      Returns:
        a type reference of the given sort.

    - #### newTypeParameterReference

          public static TypeReference newTypeParameterReference(int sort,
                                                                int paramIndex)

      Returns a reference to a type parameter of a generic class or method.
      Parameters:
        `sort` - `CLASS_TYPE_PARAMETER` or `METHOD_TYPE_PARAMETER`.
        `paramIndex` - the type parameter index.
      Returns:
        a reference to the given generic class or method type parameter.

    - #### newTypeParameterBoundReference

          public static TypeReference newTypeParameterBoundReference(int sort,
                                                                     int paramIndex,
                                                                     int boundIndex)

      Returns a reference to a type parameter bound of a generic class or method.
      Parameters:
        `sort` - `CLASS_TYPE_PARAMETER` or `METHOD_TYPE_PARAMETER`.
        `paramIndex` - the type parameter index.
        `boundIndex` - the type bound index within the above type parameters.
      Returns:
        a reference to the given generic class or method type parameter bound.

    - #### newSuperTypeReference

          public static TypeReference newSuperTypeReference(int itfIndex)

      Returns a reference to the super class or to an interface of the 'implements' clause of a class.
      Parameters:
        `itfIndex` - the index of an interface in the 'implements' clause of a class, or -1 to reference the super class of the class.
      Returns:
        a reference to the given super type of a class.

    - #### newFormalParameterReference

          public static TypeReference newFormalParameterReference(int paramIndex)

      Returns a reference to the type of a formal parameter of a method.
      Parameters:
        `paramIndex` - the formal parameter index.
      Returns:
        a reference to the type of the given method formal parameter.

    - #### newExceptionReference

          public static TypeReference newExceptionReference(int exceptionIndex)

      Returns a reference to the type of an exception, in a 'throws' clause of a method.
      Parameters:
        `exceptionIndex` - the index of an exception in a 'throws' clause of a method.
      Returns:
        a reference to the type of the given exception.

    - #### newTryCatchReference

          public static TypeReference newTryCatchReference(int tryCatchBlockIndex)

      Returns a reference to the type of the exception declared in a 'catch' clause of a method.
      Parameters:
        `tryCatchBlockIndex` - the index of a try catch block (using the order in which they are visited with visitTryCatchBlock).
      Returns:
        a reference to the type of the given exception.

    - #### newTypeArgumentReference

          public static TypeReference newTypeArgumentReference(int sort,
                                                               int argIndex)

      Returns a reference to the type of a type argument in a constructor or method call or reference.
      Parameters:
        `sort` - `CAST`, `CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT`, `METHOD_INVOCATION_TYPE_ARGUMENT`, `CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT`, or `METHOD_REFERENCE_TYPE_ARGUMENT`.
        `argIndex` - the type argument index.
      Returns:
        a reference to the type of the given type argument.

    - #### getSort

          public int getSort()

      Returns the sort of this type reference.
      Returns:
        `CLASS_TYPE_PARAMETER`, `METHOD_TYPE_PARAMETER`, `CLASS_EXTENDS`, `CLASS_TYPE_PARAMETER_BOUND`, `METHOD_TYPE_PARAMETER_BOUND`, `FIELD`, `METHOD_RETURN`, `METHOD_RECEIVER`, `METHOD_FORMAL_PARAMETER`, `THROWS`, `LOCAL_VARIABLE`, `RESOURCE_VARIABLE`, `EXCEPTION_PARAMETER`, `INSTANCEOF`, `NEW`, `CONSTRUCTOR_REFERENCE`, `METHOD_REFERENCE`, `CAST`, `CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT`, `METHOD_INVOCATION_TYPE_ARGUMENT`, `CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT`, or `METHOD_REFERENCE_TYPE_ARGUMENT`.

    - #### getTypeParameterIndex

          public int getTypeParameterIndex()

      Returns the index of the type parameter referenced by this type reference. This method must only be used for type references whose sort is `CLASS_TYPE_PARAMETER`, `METHOD_TYPE_PARAMETER`, `CLASS_TYPE_PARAMETER_BOUND` or `METHOD_TYPE_PARAMETER_BOUND`.
      Returns:
        a type parameter index.

    - #### getTypeParameterBoundIndex

          public int getTypeParameterBoundIndex()

      Returns the index of the type parameter bound, within the type parameter `getTypeParameterIndex()`, referenced by this type reference. This method must only be used for type references whose sort is `CLASS_TYPE_PARAMETER_BOUND` or `METHOD_TYPE_PARAMETER_BOUND`.
      Returns:
        a type parameter bound index.

    - #### getSuperTypeIndex

          public int getSuperTypeIndex()

      Returns the index of the "super type" of a class that is referenced by this type reference. This method must only be used for type references whose sort is `CLASS_EXTENDS`.
      Returns:
        the index of an interface in the 'implements' clause of a class, or -1 if this type reference references the type of the super class.

    - #### getFormalParameterIndex

          public int getFormalParameterIndex()

      Returns the index of the formal parameter whose type is referenced by this type reference. This method must only be used for type references whose sort is `METHOD_FORMAL_PARAMETER`.
      Returns:
        a formal parameter index.

    - #### getExceptionIndex

          public int getExceptionIndex()

      Returns the index of the exception, in a 'throws' clause of a method, whose type is referenced by this type reference. This method must only be used for type references whose sort is `THROWS`.
      Returns:
        the index of an exception in the 'throws' clause of a method.

    - #### getTryCatchBlockIndex

          public int getTryCatchBlockIndex()

      Returns the index of the try catch block (using the order in which they are visited with visitTryCatchBlock), whose 'catch' type is referenced by this type reference. This method must only be used for type references whose sort is `EXCEPTION_PARAMETER` .
      Returns:
        the index of an exception in the 'throws' clause of a method.

    - #### getTypeArgumentIndex

          public int getTypeArgumentIndex()

      Returns the index of the type argument referenced by this type reference. This method must only be used for type references whose sort is `CAST`, `CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT`, `METHOD_INVOCATION_TYPE_ARGUMENT`, `CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT`, or `METHOD_REFERENCE_TYPE_ARGUMENT`.
      Returns:
        a type parameter index.

    - #### getValue

          public int getValue()

      Returns the int encoded value of this type reference, suitable for use in visit methods related to type annotations, like visitTypeAnnotation.
      Returns:
        the int encoded value of this type reference.