Skip to content

Commit

Permalink
Remove AccessController.doPrivileged uses from closed/src
Browse files Browse the repository at this point in the history
Signed-off-by: Theresa Mammarella <[email protected]>
  • Loading branch information
theresa-m committed Feb 4, 2025
1 parent 5d34738 commit 7b85f87
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 32 deletions.
24 changes: 4 additions & 20 deletions closed/src/java.base/share/classes/java/io/ClassByNameCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/* ClassByNameCache is Primarily responsible for Caching the results of the className lookups and hence to avoid
Expand Down Expand Up @@ -63,8 +61,10 @@ public ClassByNameCache() {
loader = loader.getParent();
}
setCanonicalSystemLoaderRef(null);
AccessController.doPrivileged(
new CreateReaperAction(this, staleLoaderRefs)).start();

Reaper reaper = new Reaper(this, staleLoaderRefs);
Thread t = com.ibm.oti.vm.VM.getVMLangAccess().createThread(reaper, "ClassByNameCache Reaper", true, false, true, null);
t.start();
}
/*
* sets Canonical Loader reference for the loader
Expand Down Expand Up @@ -197,22 +197,6 @@ Class<?> get() throws ClassNotFoundException {
}
}

private static final class CreateReaperAction
implements PrivilegedAction<Thread> {
private final ClassByNameCache cache;
private final ReferenceQueue<Object> queue;

CreateReaperAction(ClassByNameCache cache, ReferenceQueue<Object> queue) {
this.cache = cache;
this.queue = queue;
}

public Thread run() {
Reaper reaper = new Reaper(cache, queue);
return com.ibm.oti.vm.VM.getVMLangAccess().createThread(reaper, "ClassByNameCache Reaper", true, false, true, null);
}
}

private static final class Reaper implements Runnable {
private final WeakReference<ClassByNameCache> cacheRef;
private final ReferenceQueue<Object> queue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ private static long loadCryptoLibraries() {
return osslVersion;
}

@SuppressWarnings("removal")
private NativeCrypto() {
ossl_ver = AccessController.doPrivileged((PrivilegedAction<Long>) () -> loadCryptoLibraries()).longValue();
ossl_ver = loadCryptoLibraries();
if (ossl_ver != -1) {
isOpenSSLFIPS = isOpenSSLFIPS();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
package openj9.internal.security;

import java.nio.charset.StandardCharsets;
import java.security.AccessController;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PrivilegedAction;
import java.security.Provider;
import java.security.Provider.Service;
import java.time.LocalDate;
Expand Down Expand Up @@ -93,18 +91,11 @@ public final class RestrictedSecurity {
supportedPlatformsOpenJCEPlus.put("Arch", List.of("amd64", "ppc64", "s390x"));
supportedPlatformsOpenJCEPlus.put("OS", List.of("Linux", "AIX", "Windows"));

@SuppressWarnings("removal")
String[] props = AccessController.doPrivileged(
new PrivilegedAction<>() {
@Override
public String[] run() {
return new String[] { System.getProperty("semeru.fips"),
String[] props = new String[] { System.getProperty("semeru.fips"),
System.getProperty("semeru.customprofile"),
System.getProperty("os.name"),
System.getProperty("os.arch"),
System.getProperty("semeru.fips.allowsetproperties") };
}
});

boolean isOsSupported, isArchSupported;
// Check whether the NSS FIPS solution is supported.
Expand Down

0 comments on commit 7b85f87

Please sign in to comment.