8332547: Unloaded signature classes in DirectMethodHandles

Reviewed-by: jvernee, liach
This commit is contained in:
Vladimir Ivanov 2024-06-04 04:02:49 +00:00
parent c7d2a5c1c4
commit 29e10e4582
4 changed files with 83 additions and 15 deletions

View file

@ -632,7 +632,7 @@ class InvokerBytecodeGenerator {
else if (c == Object[].class) return OBJARY;
else if (c == Class.class) return CLS;
else if (c == MethodHandle.class) return MH;
assert(VerifyAccess.isTypeVisible(c, Object.class)) : c.getName();
assert(VerifyAccess.ensureTypeVisible(c, Object.class)) : c.getName();
if (c == lastClass) {
return lastInternalName;

View file

@ -800,7 +800,7 @@ final class MemberName implements Member, Cloneable {
assert(isResolved() == isResolved);
}
void checkForTypeAlias(Class<?> refc) {
void ensureTypeVisible(Class<?> refc) {
if (isInvocable()) {
MethodType type;
if (this.type instanceof MethodType mt)
@ -808,7 +808,7 @@ final class MemberName implements Member, Cloneable {
else
this.type = type = getMethodType();
if (type.erase() == type) return;
if (VerifyAccess.isTypeVisible(type, refc)) return;
if (VerifyAccess.ensureTypeVisible(type, refc)) return;
throw new LinkageError("bad method type alias: "+type+" not visible from "+refc);
} else {
Class<?> type;
@ -816,7 +816,7 @@ final class MemberName implements Member, Cloneable {
type = cl;
else
this.type = type = getFieldType();
if (VerifyAccess.isTypeVisible(type, refc)) return;
if (VerifyAccess.ensureTypeVisible(type, refc)) return;
throw new LinkageError("bad field type alias: "+type+" not visible from "+refc);
}
}
@ -958,7 +958,7 @@ final class MemberName implements Member, Cloneable {
if (m == null && speculativeResolve) {
return null;
}
m.checkForTypeAlias(m.getDeclaringClass());
m.ensureTypeVisible(m.getDeclaringClass());
m.resolution = null;
} catch (ClassNotFoundException | LinkageError ex) {
// JVM reports that the "bytecode behavior" would get an error