mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8270056: Generated lambda class can not access protected static method of target class
Co-authored-by: NekoCaffeine <nekocaffeine@qq.com> Reviewed-by: mchung
This commit is contained in:
parent
afe957cd97
commit
07e9052457
2 changed files with 45 additions and 5 deletions
|
@ -187,7 +187,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
|||
// to invoke directly. (javac prefers to avoid this situation by
|
||||
// generating bridges in the target class)
|
||||
useImplMethodHandle = (Modifier.isProtected(implInfo.getModifiers()) &&
|
||||
!VerifyAccess.isSamePackage(implClass, implInfo.getDeclaringClass())) ||
|
||||
!VerifyAccess.isSamePackage(targetClass, implInfo.getDeclaringClass())) ||
|
||||
implKind == H_INVOKESPECIAL;
|
||||
cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
int parameterCount = factoryType.parameterCount();
|
||||
|
@ -564,7 +564,10 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
|||
convertArgumentTypes(methodType);
|
||||
|
||||
if (useImplMethodHandle) {
|
||||
MethodType mtype = implInfo.getMethodType().insertParameterTypes(0, implClass);
|
||||
MethodType mtype = implInfo.getMethodType();
|
||||
if (implKind != MethodHandleInfo.REF_invokeStatic) {
|
||||
mtype = mtype.insertParameterTypes(0, implClass);
|
||||
}
|
||||
visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle",
|
||||
"invokeExact", mtype.descriptorString(), false);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue