This commit is contained in:
Chen Liang 2025-12-08 13:06:12 -06:00
parent 59aca0dfb5
commit d734e8a61b
6 changed files with 18 additions and 6 deletions

View File

@ -142,7 +142,7 @@ public final class VarHandleGuardMethodGenerator {
} else if (direct && handle.vform.getMethodType_V(ad.type) == ad.symbolicMethodTypeErased) {
MethodHandle.linkToStatic(<LINK_TO_STATIC_ARGS>);
} else {
<RETURN>ad.adaptedMethodHandle(handle).invokeBasic(<LINK_TO_INVOKER_ARGS>);
ad.adaptedMethodHandle(handle).invokeBasic(<LINK_TO_INVOKER_ARGS>);
}
}""";

View File

@ -980,7 +980,7 @@ public abstract sealed class MethodHandle implements Constable
return false; // no direct relation between loaders is found
}
static boolean isBuiltinLoader(ClassLoader loader) {
private static boolean isBuiltinLoader(ClassLoader loader) {
return loader == null ||
loader == ClassLoaders.platformClassLoader() ||
loader == ClassLoaders.appClassLoader();

View File

@ -64,6 +64,11 @@ final class SegmentVarHandle extends VarHandle {
: accessType.accessModeType(MemorySegment.class, getType.returnType(), long.class, long.class);
}
@Override
boolean isReachableFrom(ClassLoader cl) {
return true;
}
@Override
public SegmentVarHandle withInvokeExactBehavior() {
return hasInvokeExactBehavior() ?

View File

@ -2012,10 +2012,7 @@ public abstract sealed class VarHandle implements Constable
// Exists for the adaption mechanism of AccessDescriptor
// Each VH should report its explicitly (receiver, coordinates) and
// implicitly (static declaring class) used class to MethodHandle.isReachableFrom
boolean isReachableFrom(ClassLoader cl) {
// Call MethodHandle.isReachableFrom for the used classes
return true;
}
abstract boolean isReachableFrom(ClassLoader cl);
static final class AccessDescriptor {
final MethodType symbolicMethodTypeExact;

View File

@ -789,6 +789,11 @@ final class VarHandle$Type$s {
return at.accessModeType({#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class);
}
@Override
boolean isReachableFrom(ClassLoader cl) {
return {#if[Object]?MethodHandle.isReachableFrom(arrayType, cl):true};
}
#if[Object]
@ForceInline
static Object runtimeTypeCheck(Array handle, Object[] oarray, Object value) {

View File

@ -79,6 +79,11 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
super(form, exact);
this.be = be;
}
@Override
boolean isReachableFrom(ClassLoader cl) {
return true;
}
}
static final class ArrayHandle extends ByteArrayViewVarHandle {