From 7cb76fd85c005b357824341802ca15ec94ae15d2 Mon Sep 17 00:00:00 2001 From: Peter Shipton Date: Wed, 4 Dec 2024 10:44:35 -0500 Subject: [PATCH] Add java.lang.Access.allowSecurityManager to jdk21 Issue https://github.com/eclipse-openj9/openj9/issues/20748 Signed-off-by: Peter Shipton --- .../java.base/share/classes/java/lang/Access.java | 12 +++++++----- .../java.base/share/classes/java/lang/System.java | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/jcl/src/java.base/share/classes/java/lang/Access.java b/jcl/src/java.base/share/classes/java/lang/Access.java index 661d814a737..f5f71d4b9b8 100644 --- a/jcl/src/java.base/share/classes/java/lang/Access.java +++ b/jcl/src/java.base/share/classes/java/lang/Access.java @@ -537,6 +537,13 @@ public Module addEnableNativeAccess(Module mod) { return mod.implAddEnableNativeAccess(); } +/*[IF (21 <= JAVA_SPEC_VERSION) & (JAVA_SPEC_VERSION < 24)]*/ + @Override + public boolean allowSecurityManager() { + return System.allowSecurityManager(); + } +/*[ENDIF] (21 <= JAVA_SPEC_VERSION) & (JAVA_SPEC_VERSION < 24) */ + /*[IF JAVA_SPEC_VERSION >= 23]*/ @Override public boolean addEnableNativeAccess(ModuleLayer moduleLayer, String moduleName) { @@ -559,11 +566,6 @@ public void putCharUTF16(byte[] val, int index, int c) { } /*[IF JAVA_SPEC_VERSION < 24]*/ - @Override - public boolean allowSecurityManager() { - return System.allowSecurityManager(); - } - @Override public long stringConcatHelperPrepend(long indexCoder, byte[] buf, String value) { return StringConcatHelper.prepend(indexCoder, buf, value); diff --git a/jcl/src/java.base/share/classes/java/lang/System.java b/jcl/src/java.base/share/classes/java/lang/System.java index 411b7efa2f8..cd0574c1aea 100644 --- a/jcl/src/java.base/share/classes/java/lang/System.java +++ b/jcl/src/java.base/share/classes/java/lang/System.java @@ -1301,11 +1301,11 @@ static void initSecurityManager(ClassLoader applicationClassLoader) { } /*[ENDIF] JAVA_SPEC_VERSION >= 9 */ -/*[IF JAVA_SPEC_VERSION == 23]*/ +/*[IF (21 <= JAVA_SPEC_VERSION) & (JAVA_SPEC_VERSION < 24)]*/ static boolean allowSecurityManager() { return !throwUOEFromSetSM; } -/*[ENDIF] JAVA_SPEC_VERSION == 23 */ +/*[ENDIF] (21 <= JAVA_SPEC_VERSION) & (JAVA_SPEC_VERSION < 24) */ /** * Sets the active security manager. Note that once