/** Return the declared type of this member, which must be a method or constructor. */ public MethodType getMethodType() { if (type == null) { expandFromVM(); if (type == null) return null; } if (!isInvocable()) throw newIllegalArgumentException("not invocable, no method type"); if (type instanceof MethodType) { return (MethodType) type; } if (type instanceof String) { String sig = (String) type; MethodType res = MethodType.fromMethodDescriptorString(sig, getClassLoader()); this.type = res; return res; } if (type instanceof Object[]) { Object[] typeInfo = (Object[]) type; Class<?>[] ptypes = (Class<?>[]) typeInfo[1]; Class<?> rtype = (Class<?>) typeInfo[0]; MethodType res = MethodType.methodType(rtype, ptypes); this.type = res; return res; } throw new InternalError("bad method type " + type); }
/** * Return the declared type of this member, which must be a field or type. If it is a type member, * that type itself is returned. */ public Class<?> getFieldType() { if (type == null) { expandFromVM(); if (type == null) return null; } if (isInvocable()) throw newIllegalArgumentException("not a field or nested class, no simple type"); if (type instanceof Class<?>) { return (Class<?>) type; } if (type instanceof String) { String sig = (String) type; MethodType mtype = MethodType.fromMethodDescriptorString("()" + sig, getClassLoader()); Class<?> res = mtype.returnType(); this.type = res; return res; } throw new InternalError("bad field type " + type); }