8330467: NoClassDefFoundError when lambda is in a hidden class

Reviewed-by: psandoz, mchung
This commit is contained in:
Adam Sotona 2024-04-18 05:50:24 +00:00
parent fe0227e978
commit 706b421cca
3 changed files with 58 additions and 5 deletions

View file

@ -175,13 +175,15 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
lambdaClassName = lambdaClassName(targetClass);
// If the target class invokes a protected method inherited from a
// superclass in a different package, or does 'invokespecial', the
// lambda class has no access to the resolved method. Instead, we need
// to pass the live implementation method handle to the proxy class
// to invoke directly. (javac prefers to avoid this situation by
// generating bridges in the target class)
// lambda class has no access to the resolved method, or does
// 'invokestatic' on a hidden class which cannot be resolved by name.
// Instead, we need to pass the live implementation method handle to
// the proxy class to invoke directly. (javac prefers to avoid this
// situation by generating bridges in the target class)
useImplMethodHandle = (Modifier.isProtected(implInfo.getModifiers()) &&
!VerifyAccess.isSamePackage(targetClass, implInfo.getDeclaringClass())) ||
implKind == H_INVOKESPECIAL;
implKind == H_INVOKESPECIAL ||
implKind == H_INVOKESTATIC && implClass.isHidden();
cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
int parameterCount = factoryType.parameterCount();
if (parameterCount > 0) {