57 * THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60 package jdk.internal.org.objectweb.asm; 61 62 /** 63 * A reference to a type appearing in a class, field or method declaration, or 64 * on an instruction. Such a reference designates the part of the class where 65 * the referenced type is appearing (e.g. an 'extends', 'implements' or 'throws' 66 * clause, a 'new' instruction, a 'catch' clause, a type cast, a local variable 67 * declaration, etc). 68 * 69 * @author Eric Bruneton 70 */ 71 public class TypeReference { 72 73 /** 74 * The sort of type references that target a type parameter of a generic 75 * class. See {@link #getSort getSort}. 76 */ 77 public static final int CLASS_TYPE_PARAMETER = 0x00; 78 79 /** 80 * The sort of type references that target a type parameter of a generic 81 * method. See {@link #getSort getSort}. 82 */ 83 public static final int METHOD_TYPE_PARAMETER = 0x01; 84 85 /** 86 * The sort of type references that target the super class of a class or one 87 * of the interfaces it implements. See {@link #getSort getSort}. 88 */ 89 public static final int CLASS_EXTENDS = 0x10; 90 91 /** 92 * The sort of type references that target a bound of a type parameter of a 93 * generic class. See {@link #getSort getSort}. 94 */ 95 public static final int CLASS_TYPE_PARAMETER_BOUND = 0x11; 96 97 /** 98 * The sort of type references that target a bound of a type parameter of a 99 * generic method. See {@link #getSort getSort}. 100 */ 101 public static final int METHOD_TYPE_PARAMETER_BOUND = 0x12; 102 103 /** 104 * The sort of type references that target the type of a field. See 105 * {@link #getSort getSort}. 106 */ 107 public static final int FIELD = 0x13; 108 109 /** 110 * The sort of type references that target the return type of a method. See 111 * {@link #getSort getSort}. 112 */ 113 public static final int METHOD_RETURN = 0x14; 114 115 /** 116 * The sort of type references that target the receiver type of a method. 117 * See {@link #getSort getSort}. 118 */ 119 public static final int METHOD_RECEIVER = 0x15; 120 121 /** 122 * The sort of type references that target the type of a formal parameter of 123 * a method. See {@link #getSort getSort}. 124 */ 125 public static final int METHOD_FORMAL_PARAMETER = 0x16; 126 127 /** 128 * The sort of type references that target the type of an exception declared 129 * in the throws clause of a method. See {@link #getSort getSort}. 130 */ 131 public static final int THROWS = 0x17; 132 133 /** 134 * The sort of type references that target the type of a local variable in a 135 * method. See {@link #getSort getSort}. 136 */ 137 public static final int LOCAL_VARIABLE = 0x40; 138 139 /** 140 * The sort of type references that target the type of a resource variable 141 * in a method. See {@link #getSort getSort}. 142 */ 143 public static final int RESOURCE_VARIABLE = 0x41; 144 145 /** 146 * The sort of type references that target the type of the exception of a 147 * 'catch' clause in a method. See {@link #getSort getSort}. 148 */ 149 public static final int EXCEPTION_PARAMETER = 0x42; 150 151 /** 152 * The sort of type references that target the type declared in an 153 * 'instanceof' instruction. See {@link #getSort getSort}. 154 */ 155 public static final int INSTANCEOF = 0x43; 156 157 /** 158 * The sort of type references that target the type of the object created by 159 * a 'new' instruction. See {@link #getSort getSort}. 160 */ 161 public static final int NEW = 0x44; 162 163 /** 164 * The sort of type references that target the receiver type of a 165 * constructor reference. See {@link #getSort getSort}. 166 */ 167 public static final int CONSTRUCTOR_REFERENCE = 0x45; 168 169 /** 170 * The sort of type references that target the receiver type of a method 171 * reference. See {@link #getSort getSort}. 172 */ 173 public static final int METHOD_REFERENCE = 0x46; 174 175 /** 176 * The sort of type references that target the type declared in an explicit 177 * or implicit cast instruction. See {@link #getSort getSort}. 178 */ 179 public static final int CAST = 0x47; 180 181 /** 182 * The sort of type references that target a type parameter of a generic 183 * constructor in a constructor call. See {@link #getSort getSort}. 184 */ 185 public static final int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48; 186 187 /** 188 * The sort of type references that target a type parameter of a generic 189 * method in a method call. See {@link #getSort getSort}. 190 */ 191 public static final int METHOD_INVOCATION_TYPE_ARGUMENT = 0x49; 192 193 /** 194 * The sort of type references that target a type parameter of a generic 195 * constructor in a constructor reference. See {@link #getSort getSort}. 196 */ 197 public static final int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A; 198 199 /** 200 * The sort of type references that target a type parameter of a generic 201 * method in a method reference. See {@link #getSort getSort}. 202 */ 203 public static final int METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B; 204 205 /** 206 * The type reference value in Java class file format. 207 */ 208 private int value; 209 210 /** 211 * Creates a new TypeReference. 212 * 213 * @param typeRef 214 * the int encoded value of the type reference, as received in a 215 * visit method related to type annotations, like 216 * visitTypeAnnotation. 217 */ 218 public TypeReference(int typeRef) { 219 this.value = typeRef; 220 } 221 222 /** 223 * Returns a type reference of the given sort. | 57 * THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60 package jdk.internal.org.objectweb.asm; 61 62 /** 63 * A reference to a type appearing in a class, field or method declaration, or 64 * on an instruction. Such a reference designates the part of the class where 65 * the referenced type is appearing (e.g. an 'extends', 'implements' or 'throws' 66 * clause, a 'new' instruction, a 'catch' clause, a type cast, a local variable 67 * declaration, etc). 68 * 69 * @author Eric Bruneton 70 */ 71 public class TypeReference { 72 73 /** 74 * The sort of type references that target a type parameter of a generic 75 * class. See {@link #getSort getSort}. 76 */ 77 public final static int CLASS_TYPE_PARAMETER = 0x00; 78 79 /** 80 * The sort of type references that target a type parameter of a generic 81 * method. See {@link #getSort getSort}. 82 */ 83 public final static int METHOD_TYPE_PARAMETER = 0x01; 84 85 /** 86 * The sort of type references that target the super class of a class or one 87 * of the interfaces it implements. See {@link #getSort getSort}. 88 */ 89 public final static int CLASS_EXTENDS = 0x10; 90 91 /** 92 * The sort of type references that target a bound of a type parameter of a 93 * generic class. See {@link #getSort getSort}. 94 */ 95 public final static int CLASS_TYPE_PARAMETER_BOUND = 0x11; 96 97 /** 98 * The sort of type references that target a bound of a type parameter of a 99 * generic method. See {@link #getSort getSort}. 100 */ 101 public final static int METHOD_TYPE_PARAMETER_BOUND = 0x12; 102 103 /** 104 * The sort of type references that target the type of a field. See 105 * {@link #getSort getSort}. 106 */ 107 public final static int FIELD = 0x13; 108 109 /** 110 * The sort of type references that target the return type of a method. See 111 * {@link #getSort getSort}. 112 */ 113 public final static int METHOD_RETURN = 0x14; 114 115 /** 116 * The sort of type references that target the receiver type of a method. 117 * See {@link #getSort getSort}. 118 */ 119 public final static int METHOD_RECEIVER = 0x15; 120 121 /** 122 * The sort of type references that target the type of a formal parameter of 123 * a method. See {@link #getSort getSort}. 124 */ 125 public final static int METHOD_FORMAL_PARAMETER = 0x16; 126 127 /** 128 * The sort of type references that target the type of an exception declared 129 * in the throws clause of a method. See {@link #getSort getSort}. 130 */ 131 public final static int THROWS = 0x17; 132 133 /** 134 * The sort of type references that target the type of a local variable in a 135 * method. See {@link #getSort getSort}. 136 */ 137 public final static int LOCAL_VARIABLE = 0x40; 138 139 /** 140 * The sort of type references that target the type of a resource variable 141 * in a method. See {@link #getSort getSort}. 142 */ 143 public final static int RESOURCE_VARIABLE = 0x41; 144 145 /** 146 * The sort of type references that target the type of the exception of a 147 * 'catch' clause in a method. See {@link #getSort getSort}. 148 */ 149 public final static int EXCEPTION_PARAMETER = 0x42; 150 151 /** 152 * The sort of type references that target the type declared in an 153 * 'instanceof' instruction. See {@link #getSort getSort}. 154 */ 155 public final static int INSTANCEOF = 0x43; 156 157 /** 158 * The sort of type references that target the type of the object created by 159 * a 'new' instruction. See {@link #getSort getSort}. 160 */ 161 public final static int NEW = 0x44; 162 163 /** 164 * The sort of type references that target the receiver type of a 165 * constructor reference. See {@link #getSort getSort}. 166 */ 167 public final static int CONSTRUCTOR_REFERENCE = 0x45; 168 169 /** 170 * The sort of type references that target the receiver type of a method 171 * reference. See {@link #getSort getSort}. 172 */ 173 public final static int METHOD_REFERENCE = 0x46; 174 175 /** 176 * The sort of type references that target the type declared in an explicit 177 * or implicit cast instruction. See {@link #getSort getSort}. 178 */ 179 public final static int CAST = 0x47; 180 181 /** 182 * The sort of type references that target a type parameter of a generic 183 * constructor in a constructor call. See {@link #getSort getSort}. 184 */ 185 public final static int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48; 186 187 /** 188 * The sort of type references that target a type parameter of a generic 189 * method in a method call. See {@link #getSort getSort}. 190 */ 191 public final static int METHOD_INVOCATION_TYPE_ARGUMENT = 0x49; 192 193 /** 194 * The sort of type references that target a type parameter of a generic 195 * constructor in a constructor reference. See {@link #getSort getSort}. 196 */ 197 public final static int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A; 198 199 /** 200 * The sort of type references that target a type parameter of a generic 201 * method in a method reference. See {@link #getSort getSort}. 202 */ 203 public final static int METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B; 204 205 /** 206 * The type reference value in Java class file format. 207 */ 208 private int value; 209 210 /** 211 * Creates a new TypeReference. 212 * 213 * @param typeRef 214 * the int encoded value of the type reference, as received in a 215 * visit method related to type annotations, like 216 * visitTypeAnnotation. 217 */ 218 public TypeReference(int typeRef) { 219 this.value = typeRef; 220 } 221 222 /** 223 * Returns a type reference of the given sort. |