< prev index next >

src/java.base/share/classes/java/lang/invoke/InfoFromMemberName.java

Print this page

        

*** 25,37 **** package java.lang.invoke; import java.security.*; import java.lang.reflect.*; - import java.lang.invoke.MethodHandleNatives.Constants; import java.lang.invoke.MethodHandles.Lookup; - import static java.lang.invoke.MethodHandleStatics.*; /* * Auxiliary to MethodHandleInfo, wants to nest in MethodHandleInfo but must be non-public. */ /*non-public*/ --- 25,35 ----
*** 109,128 **** private Member reflectUnchecked() throws ReflectiveOperationException { byte refKind = (byte) getReferenceKind(); Class<?> defc = getDeclaringClass(); boolean isPublic = Modifier.isPublic(getModifiers()); ! if (MethodHandleNatives.refKindIsMethod(refKind)) { if (isPublic) return defc.getMethod(getName(), getMethodType().parameterArray()); else return defc.getDeclaredMethod(getName(), getMethodType().parameterArray()); - } else if (MethodHandleNatives.refKindIsConstructor(refKind)) { - if (isPublic) - return defc.getConstructor(getMethodType().parameterArray()); - else - return defc.getDeclaredConstructor(getMethodType().parameterArray()); } else if (MethodHandleNatives.refKindIsField(refKind)) { if (isPublic) return defc.getField(getName()); else return defc.getDeclaredField(getName()); --- 107,135 ---- private Member reflectUnchecked() throws ReflectiveOperationException { byte refKind = (byte) getReferenceKind(); Class<?> defc = getDeclaringClass(); boolean isPublic = Modifier.isPublic(getModifiers()); ! if (member.isObjectConstructorOrStaticInitMethod()) { ! MethodType methodType = getMethodType(); ! if (MethodHandleNatives.refKindIsObjectConstructor(refKind) && ! methodType.returnType() != void.class) { ! // object constructor ! throw new IllegalArgumentException("object constructor must be of void return type"); ! } else if (MethodHandleNatives.refKindIsMethod(refKind) && ! methodType.returnType() != defc.asPrimaryType()) { ! // static init factory ! throw new IllegalArgumentException("static constructor must be of " + getDeclaringClass().getName()); ! } ! ! return isPublic ? defc.getConstructor(methodType.parameterArray()) ! : defc.getDeclaredConstructor(methodType.parameterArray()); ! } else if (MethodHandleNatives.refKindIsMethod(refKind)) { if (isPublic) return defc.getMethod(getName(), getMethodType().parameterArray()); else return defc.getDeclaredMethod(getName(), getMethodType().parameterArray()); } else if (MethodHandleNatives.refKindIsField(refKind)) { if (isPublic) return defc.getField(getName()); else return defc.getDeclaredField(getName());
< prev index next >