Skip to content

Commit

Permalink
[GR-47001] Truffle TCKs PermissionsFeature relies on out-dated jdk.in…
Browse files Browse the repository at this point in the history
…ternal.reflect.UnsafeFieldAccessorFactory.

PullRequest: graal/15559
  • Loading branch information
tzezula committed Sep 14, 2023
2 parents ed89e10 + 982991c commit 9cf893f
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import com.oracle.svm.core.option.HostedOptionKey;
import com.oracle.svm.core.option.LocatableMultiOptionValue;
import com.oracle.svm.core.util.UserError;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.hosted.FeatureImpl;
import com.oracle.svm.hosted.ImageClassLoader;
import com.oracle.svm.hosted.SVMHost;
Expand Down Expand Up @@ -166,7 +165,6 @@ public boolean getAsBoolean() {
/**
* Classes for reflective accesses which are opaque for permission analysis.
*/
private AnalysisType reflectionFieldAccessorFactory;

private InlinedUnsafeMethodNode inlinedUnsafeCall;

Expand Down Expand Up @@ -218,8 +216,6 @@ public void afterAnalysis(AfterAnalysisAccess access) {
Options.TruffleTCKPermissionsExcludeFiles,
new ResourceAsOptionDecorator(getClass().getPackage().getName().replace('.', '/') + "/resources/jre.json"),
CONFIG);
reflectionFieldAccessorFactory = bb.getMetaAccess().lookupJavaType(loadClassOrFail("jdk.internal.reflect.UnsafeFieldAccessorFactory"));
VMError.guarantee(reflectionFieldAccessorFactory != null, "Cannot load one or several reflection types");
whiteList = parser.getLoadedWhiteList();
Set<BaseMethodNode> deniedMethods = new HashSet<>();
deniedMethods.addAll(findMethods(bb, SecurityManager.class, (m) -> m.getName().startsWith("check")));
Expand Down Expand Up @@ -459,7 +455,7 @@ private int collectViolations(
} else {
nextCaller: for (BaseMethodNode caller : callers) {
for (CallGraphFilter filter : contextFilters) {
if (isReflectionFieldAccessorFactory(caller) || filter.test(mNode, caller, visited)) {
if (filter.test(mNode, caller, visited)) {
continue nextCaller;
}
}
Expand All @@ -473,14 +469,6 @@ private int collectViolations(
return useNoReports;
}

/**
* Tests if the given {@link BaseMethodNode} is part of the factory of field accessors.
*/
private boolean isReflectionFieldAccessorFactory(BaseMethodNode methodNode) {
AnalysisMethod method = methodNode.getMethod();
return method != null && reflectionFieldAccessorFactory.isAssignableFrom(method.getDeclaringClass());
}

/**
* Tests if method represented by given {@link BaseMethodNode} is loaded by a system
* {@link ClassLoader}.
Expand Down Expand Up @@ -648,7 +636,7 @@ public boolean test(BaseMethodNode methodNode, BaseMethodNode callerNode, Linked
/**
* Filters out {@code AccessController#doPrivileged} done by JRE.
*/
private final class SafePrivilegedRecognizer implements CallGraphFilter {
private static final class SafePrivilegedRecognizer implements CallGraphFilter {

private final SVMHost hostVM;
private final Set<? extends BaseMethodNode> doPrivileged;
Expand Down

0 comments on commit 9cf893f

Please sign in to comment.