174 } 175 if (!isInvocable()) { 176 throw newIllegalArgumentException("not invocable, no method type"); 177 } 178 179 // Get a snapshot of type which doesn't get changed by racing threads. 180 final Object type = this.type; 181 if (type instanceof String) { 182 return (String) type; 183 } else { 184 return getMethodType().toMethodDescriptorString(); 185 } 186 } 187 188 /** Return the actual type under which this method or constructor must be invoked. 189 * For non-static methods or constructors, this is the type with a leading parameter, 190 * a reference to declaring class. For static methods, it is the same as the declared type. 191 */ 192 public MethodType getInvocationType() { 193 MethodType itype = getMethodOrFieldType(); 194 if (isConstructor() && getReferenceKind() == REF_newInvokeSpecial) 195 return itype.changeReturnType(clazz); 196 if (!isStatic()) 197 return itype.insertParameterTypes(0, clazz); 198 return itype; 199 } 200 201 /** Utility method producing the parameter types of the method type. */ 202 public Class<?>[] getParameterTypes() { 203 return getMethodType().parameterArray(); 204 } 205 206 /** Utility method producing the return type of the method type. */ 207 public Class<?> getReturnType() { 208 return getMethodType().returnType(); 209 } 210 211 /** Return the declared type of this member, which 212 * must be a field or type. 213 * If it is a type member, that type itself is returned. 214 */ 215 public Class<?> getFieldType() { 216 if (type == null) { 217 expandFromVM(); | 174 } 175 if (!isInvocable()) { 176 throw newIllegalArgumentException("not invocable, no method type"); 177 } 178 179 // Get a snapshot of type which doesn't get changed by racing threads. 180 final Object type = this.type; 181 if (type instanceof String) { 182 return (String) type; 183 } else { 184 return getMethodType().toMethodDescriptorString(); 185 } 186 } 187 188 /** Return the actual type under which this method or constructor must be invoked. 189 * For non-static methods or constructors, this is the type with a leading parameter, 190 * a reference to declaring class. For static methods, it is the same as the declared type. 191 */ 192 public MethodType getInvocationType() { 193 MethodType itype = getMethodOrFieldType(); 194 Class<?> c = clazz.isValue() ? clazz.asValueType() : clazz; 195 if (isConstructor() && getReferenceKind() == REF_newInvokeSpecial) 196 return itype.changeReturnType(c); 197 if (!isStatic()) 198 return itype.insertParameterTypes(0, c); 199 return itype; 200 } 201 202 /** Utility method producing the parameter types of the method type. */ 203 public Class<?>[] getParameterTypes() { 204 return getMethodType().parameterArray(); 205 } 206 207 /** Utility method producing the return type of the method type. */ 208 public Class<?> getReturnType() { 209 return getMethodType().returnType(); 210 } 211 212 /** Return the declared type of this member, which 213 * must be a field or type. 214 * If it is a type member, that type itself is returned. 215 */ 216 public Class<?> getFieldType() { 217 if (type == null) { 218 expandFromVM(); |