/** * Returns a reference to the type of the exception declared in a 'catch' clause of a method. * * @param tryCatchBlockIndex the index of a try catch block (using the order in which they are * visited with visitTryCatchBlock). * @return a reference to the type of the given exception. */ public static TypeReference newTryCatchReference(final int tryCatchBlockIndex) { return new TypeReference((EXCEPTION_PARAMETER << 24) | (tryCatchBlockIndex << 8)); }
/** * Returns a reference to the type of an exception, in a 'throws' clause of a method. * * @param exceptionIndex the index of an exception in a 'throws' clause of a method. * @return a reference to the type of the given exception. */ public static TypeReference newExceptionReference(final int exceptionIndex) { return new TypeReference((THROWS << 24) | (exceptionIndex << 8)); }
/** * Returns a reference to a type parameter of a generic class or method. * * @param sort one of {@link #CLASS_TYPE_PARAMETER} or {@link #METHOD_TYPE_PARAMETER}. * @param paramIndex the type parameter index. * @return a reference to the given generic class or method type parameter. */ public static TypeReference newTypeParameterReference(final int sort, final int paramIndex) { return new TypeReference((sort << 24) | (paramIndex << 16)); }
/** * Returns a reference to a type parameter bound of a generic class or method. * * @param sort one of {@link #CLASS_TYPE_PARAMETER} or {@link #METHOD_TYPE_PARAMETER}. * @param paramIndex the type parameter index. * @param boundIndex the type bound index within the above type parameters. * @return a reference to the given generic class or method type parameter bound. */ public static TypeReference newTypeParameterBoundReference( final int sort, final int paramIndex, final int boundIndex) { return new TypeReference((sort << 24) | (paramIndex << 16) | (boundIndex << 8)); }
/** * Returns a type reference of the given sort. * * @param sort one of {@link #FIELD}, {@link #METHOD_RETURN}, {@link #METHOD_RECEIVER}, {@link * #LOCAL_VARIABLE}, {@link #RESOURCE_VARIABLE}, {@link #INSTANCEOF}, {@link #NEW}, {@link * #CONSTRUCTOR_REFERENCE}, or {@link #METHOD_REFERENCE}. * @return a type reference of the given sort. */ public static TypeReference newTypeReference(final int sort) { return new TypeReference(sort << 24); }
/** * Returns a reference to the super class or to an interface of the 'implements' clause of a * class. * * @param itfIndex the index of an interface in the 'implements' clause of a class, or -1 to * reference the super class of the class. * @return a reference to the given super type of a class. */ public static TypeReference newSuperTypeReference(final int itfIndex) { return new TypeReference((CLASS_EXTENDS << 24) | ((itfIndex & 0xFFFF) << 8)); }
/** * Returns a reference to the type of a formal parameter of a method. * * @param paramIndex the formal parameter index. * @return a reference to the type of the given method formal parameter. */ public static TypeReference newFormalParameterReference(final int paramIndex) { return new TypeReference((METHOD_FORMAL_PARAMETER << 24) | (paramIndex << 16)); }
/** * Returns a reference to the type of a type argument in a constructor or method call or * reference. * * @param sort one of {@link #CAST}, {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, {@link * #METHOD_INVOCATION_TYPE_ARGUMENT}, {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or {@link * #METHOD_REFERENCE_TYPE_ARGUMENT}. * @param argIndex the type argument index. * @return a reference to the type of the given type argument. */ public static TypeReference newTypeArgumentReference(final int sort, final int argIndex) { return new TypeReference((sort << 24) | argIndex); }