76 * {@link Opcodes#H_INVOKEINTERFACE}. 77 */ 78 final int tag; 79 80 /** 81 * The internal name of the class that owns the field or method designated 82 * by this handle. 83 */ 84 final String owner; 85 86 /** 87 * The name of the field or method designated by this handle. 88 */ 89 final String name; 90 91 /** 92 * The descriptor of the field or method designated by this handle. 93 */ 94 final String desc; 95 96 /** 97 * Constructs a new field or method handle. 98 * 99 * @param tag 100 * the kind of field or method designated by this Handle. Must be 101 * {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC}, 102 * {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, 103 * {@link Opcodes#H_INVOKEVIRTUAL}, 104 * {@link Opcodes#H_INVOKESTATIC}, 105 * {@link Opcodes#H_INVOKESPECIAL}, 106 * {@link Opcodes#H_NEWINVOKESPECIAL} or 107 * {@link Opcodes#H_INVOKEINTERFACE}. 108 * @param owner 109 * the internal name of the class that owns the field or method 110 * designated by this handle. 111 * @param name 112 * the name of the field or method designated by this handle. 113 * @param desc 114 * the descriptor of the field or method designated by this 115 * handle. 116 */ 117 public Handle(int tag, String owner, String name, String desc) { 118 this.tag = tag; 119 this.owner = owner; 120 this.name = name; 121 this.desc = desc; 122 } 123 124 /** 125 * Returns the kind of field or method designated by this handle. 126 * 127 * @return {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC}, 128 * {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, 129 * {@link Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, 130 * {@link Opcodes#H_INVOKESPECIAL}, 131 * {@link Opcodes#H_NEWINVOKESPECIAL} or 132 * {@link Opcodes#H_INVOKEINTERFACE}. 133 */ 134 public int getTag() { 135 return tag; 136 } 137 138 /** 139 * Returns the internal name of the class that owns the field or method 140 * designated by this handle. 141 * 147 } 148 149 /** 150 * Returns the name of the field or method designated by this handle. 151 * 152 * @return the name of the field or method designated by this handle. 153 */ 154 public String getName() { 155 return name; 156 } 157 158 /** 159 * Returns the descriptor of the field or method designated by this handle. 160 * 161 * @return the descriptor of the field or method designated by this handle. 162 */ 163 public String getDesc() { 164 return desc; 165 } 166 167 @Override 168 public boolean equals(Object obj) { 169 if (obj == this) { 170 return true; 171 } 172 if (!(obj instanceof Handle)) { 173 return false; 174 } 175 Handle h = (Handle) obj; 176 return tag == h.tag && owner.equals(h.owner) && name.equals(h.name) 177 && desc.equals(h.desc); 178 } 179 180 @Override 181 public int hashCode() { 182 return tag + owner.hashCode() * name.hashCode() * desc.hashCode(); 183 } 184 185 /** 186 * Returns the textual representation of this handle. The textual 187 * representation is: 188 * 189 * <pre> 190 * owner '.' name desc ' ' '(' tag ')' 191 * </pre> 192 * 193 * . As this format is unambiguous, it can be parsed if necessary. 194 */ 195 @Override 196 public String toString() { 197 return owner + '.' + name + desc + " (" + tag + ')'; 198 } 199 } | 76 * {@link Opcodes#H_INVOKEINTERFACE}. 77 */ 78 final int tag; 79 80 /** 81 * The internal name of the class that owns the field or method designated 82 * by this handle. 83 */ 84 final String owner; 85 86 /** 87 * The name of the field or method designated by this handle. 88 */ 89 final String name; 90 91 /** 92 * The descriptor of the field or method designated by this handle. 93 */ 94 final String desc; 95 96 97 /** 98 * Indicate if the owner is an interface or not. 99 */ 100 final boolean itf; 101 102 /** 103 * Constructs a new field or method handle. 104 * 105 * @param tag 106 * the kind of field or method designated by this Handle. Must be 107 * {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC}, 108 * {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, 109 * {@link Opcodes#H_INVOKEVIRTUAL}, 110 * {@link Opcodes#H_INVOKESTATIC}, 111 * {@link Opcodes#H_INVOKESPECIAL}, 112 * {@link Opcodes#H_NEWINVOKESPECIAL} or 113 * {@link Opcodes#H_INVOKEINTERFACE}. 114 * @param owner 115 * the internal name of the class that owns the field or method 116 * designated by this handle. 117 * @param name 118 * the name of the field or method designated by this handle. 119 * @param desc 120 * the descriptor of the field or method designated by this 121 * handle. 122 * 123 * @deprecated this constructor has been superseded 124 * by {@link #Handle(int, String, String, String, boolean)}. 125 */ 126 @Deprecated 127 public Handle(int tag, String owner, String name, String desc) { 128 this(tag, owner, name, desc, tag == Opcodes.H_INVOKEINTERFACE); 129 } 130 131 /** 132 * Constructs a new field or method handle. 133 * 134 * @param tag 135 * the kind of field or method designated by this Handle. Must be 136 * {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC}, 137 * {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, 138 * {@link Opcodes#H_INVOKEVIRTUAL}, 139 * {@link Opcodes#H_INVOKESTATIC}, 140 * {@link Opcodes#H_INVOKESPECIAL}, 141 * {@link Opcodes#H_NEWINVOKESPECIAL} or 142 * {@link Opcodes#H_INVOKEINTERFACE}. 143 * @param owner 144 * the internal name of the class that owns the field or method 145 * designated by this handle. 146 * @param name 147 * the name of the field or method designated by this handle. 148 * @param desc 149 * the descriptor of the field or method designated by this 150 * handle. 151 * @param itf 152 * true if the owner is an interface. 153 */ 154 public Handle(int tag, String owner, String name, String desc, boolean itf) { 155 this.tag = tag; 156 this.owner = owner; 157 this.name = name; 158 this.desc = desc; 159 this.itf = itf; 160 } 161 162 /** 163 * Returns the kind of field or method designated by this handle. 164 * 165 * @return {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC}, 166 * {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, 167 * {@link Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, 168 * {@link Opcodes#H_INVOKESPECIAL}, 169 * {@link Opcodes#H_NEWINVOKESPECIAL} or 170 * {@link Opcodes#H_INVOKEINTERFACE}. 171 */ 172 public int getTag() { 173 return tag; 174 } 175 176 /** 177 * Returns the internal name of the class that owns the field or method 178 * designated by this handle. 179 * 185 } 186 187 /** 188 * Returns the name of the field or method designated by this handle. 189 * 190 * @return the name of the field or method designated by this handle. 191 */ 192 public String getName() { 193 return name; 194 } 195 196 /** 197 * Returns the descriptor of the field or method designated by this handle. 198 * 199 * @return the descriptor of the field or method designated by this handle. 200 */ 201 public String getDesc() { 202 return desc; 203 } 204 205 /** 206 * Returns true if the owner of the field or method designated 207 * by this handle is an interface. 208 * 209 * @return true if the owner of the field or method designated 210 * by this handle is an interface. 211 */ 212 public boolean isInterface() { 213 return itf; 214 } 215 216 @Override 217 public boolean equals(Object obj) { 218 if (obj == this) { 219 return true; 220 } 221 if (!(obj instanceof Handle)) { 222 return false; 223 } 224 Handle h = (Handle) obj; 225 return tag == h.tag && itf == h.itf && owner.equals(h.owner) 226 && name.equals(h.name) && desc.equals(h.desc); 227 } 228 229 @Override 230 public int hashCode() { 231 return tag + (itf? 64: 0) + owner.hashCode() * name.hashCode() * desc.hashCode(); 232 } 233 234 /** 235 * Returns the textual representation of this handle. The textual 236 * representation is: 237 * 238 * <pre> 239 * for a reference to a class: 240 * owner '.' name desc ' ' '(' tag ')' 241 * for a reference to an interface: 242 * owner '.' name desc ' ' '(' tag ' ' itf ')' 243 * </pre> 244 * 245 * . As this format is unambiguous, it can be parsed if necessary. 246 */ 247 @Override 248 public String toString() { 249 return owner + '.' + name + desc + " (" + tag + (itf? " itf": "") + ')'; 250 } 251 } |