Skip to content

Commit 3fdf168

Browse files
committed
svm: more "JDK-8338411: Implement JEP 486: Permanently Disable the Security Manager" adoption
1 parent b8fa1d4 commit 3fdf168

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/AccessControllerUtil.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
import java.util.ArrayDeque;
3030
import java.util.Objects;
3131

32-
import com.oracle.svm.core.util.VMError;
3332
import com.oracle.svm.util.ReflectionUtil;
3433

34+
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
35+
3536
/**
3637
* Stack for storing AccessControlContexts. Used in conjunction with
3738
* {@code StackAccessControlContextVisitor}.
@@ -104,10 +105,7 @@ public class AccessControllerUtil {
104105
public static final AccessControlContext DISALLOWED_CONTEXT_MARKER;
105106

106107
static {
107-
try {
108-
DISALLOWED_CONTEXT_MARKER = ReflectionUtil.lookupConstructor(AccessControlContext.class, ProtectionDomain[].class, boolean.class).newInstance(new ProtectionDomain[0], true);
109-
} catch (ReflectiveOperationException ex) {
110-
throw VMError.shouldNotReachHere(ex);
111-
}
108+
DISALLOWED_CONTEXT_MARKER = JavaVersionUtil.JAVA_SPEC > 21 ? null
109+
: ReflectionUtil.newInstance(ReflectionUtil.lookupConstructor(AccessControlContext.class, ProtectionDomain[].class, boolean.class), new ProtectionDomain[0], true);
112110
}
113111
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,12 @@ public static class Options {
166166
CertPathBuilder.class, CertPathValidator.class, CertStore.class, CertificateFactory.class,
167167
Cipher.class, Configuration.class, KeyAgreement.class, KeyFactory.class,
168168
KeyGenerator.class, KeyManagerFactory.class, KeyPairGenerator.class,
169-
KeyStore.class, Mac.class, MessageDigest.class, Policy.class, SSLContext.class,
169+
KeyStore.class, Mac.class, MessageDigest.class, SSLContext.class,
170170
SecretKeyFactory.class, SecureRandom.class, Signature.class, TrustManagerFactory.class));
171+
if (JavaVersionUtil.JAVA_SPEC <= 21) {
172+
// JDK-8338411: Implement JEP 486: Permanently Disable the Security Manager
173+
classList.add(Policy.class);
174+
}
171175

172176
if (ModuleLayer.boot().findModule("java.security.sasl").isPresent()) {
173177
classList.add(ReflectionUtil.lookupClass(false, "javax.security.sasl.SaslClientFactory"));
@@ -634,6 +638,7 @@ private void registerServices(DuringAnalysisAccess access, Object trigger, Strin
634638
private void doRegisterServices(DuringAnalysisAccess access, Object trigger, String serviceType) {
635639
try (TracingAutoCloseable ignored = trace(access, trigger, serviceType)) {
636640
Set<Service> services = availableServices.get(serviceType);
641+
VMError.guarantee(services != null);
637642
for (Service service : services) {
638643
registerService(access, service);
639644
}

0 commit comments

Comments
 (0)