Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update java.security.manager behaviour #14329

Merged
merged 3 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions jcl/src/java.base/share/classes/java/lang/ClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,31 +286,7 @@ static final void initializeClassLoaders() {
}
/*[ENDIF] JAVA_SPEC_VERSION >= 10 */
jdk.internal.misc.VM.initLevel(2);
String javaSecurityManager = System.internalGetProperties().getProperty("java.security.manager"); //$NON-NLS-1$
if ((javaSecurityManager != null)
/*[IF JAVA_SPEC_VERSION >= 12]*/
/* See the SecurityManager javadoc for details about special tokens. */
&& !javaSecurityManager.equals("disallow") //$NON-NLS-1$ /* special token to disallow SecurityManager */
&& !javaSecurityManager.equals("allow") //$NON-NLS-1$ /* special token to allow SecurityManager */
/*[ENDIF] JAVA_SPEC_VERSION >= 12 */
) {
/*[IF JAVA_SPEC_VERSION >= 17]*/
System.initialErr.println("WARNING: A command line option has enabled the Security Manager"); //$NON-NLS-1$
System.initialErr.println("WARNING: The Security Manager is deprecated and will be removed in a future release"); //$NON-NLS-1$
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */
if (javaSecurityManager.isEmpty() || "default".equals(javaSecurityManager)) { //$NON-NLS-1$
System.setSecurityManager(new SecurityManager());
} else {
try {
Constructor<?> constructor = Class.forName(javaSecurityManager, true, applicationClassLoader).getConstructor();
constructor.setAccessible(true);
System.setSecurityManager((SecurityManager)constructor.newInstance());
} catch (Throwable e) {
/*[MSG "K0631", "JVM can't set custom SecurityManager due to {0}"]*/
throw new Error(com.ibm.oti.util.Msg.getString("K0631", e.toString()), e); //$NON-NLS-1$
}
}
}
System.initSecurityManager(applicationClassLoader);
jdk.internal.misc.VM.initLevel(3);
/*[ELSE]*/
applicationClassLoader = sun.misc.Launcher.getLauncher().getClassLoader();
Expand Down
53 changes: 50 additions & 3 deletions jcl/src/java.base/share/classes/java/lang/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.PropertyPermission;
import java.security.*;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;

/*[IF Sidecar19-SE]*/
import jdk.internal.misc.Unsafe;
Expand Down Expand Up @@ -91,6 +92,14 @@ public final class System {
private static Map<Class<?>, Object> setSMCallers;
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */

/*[IF JAVA_SPEC_VERSION > 11] */
/**
* setSecurityManager() should throw UnsupportedOperationException
* if throwUOEFromSetSM is set to true.
*/
private static boolean throwUOEFromSetSM;
/*[ENDIF] JAVA_SPEC_VERSION > 11 */

//Get a ref to the Runtime instance for faster lookup
private static final Runtime RUNTIME = Runtime.getRuntime();
/**
Expand Down Expand Up @@ -1051,6 +1060,39 @@ public static void setProperties(Properties p) {
}
}

static void initSecurityManager(ClassLoader applicationClassLoader) {
String javaSecurityManager = internalGetProperties().getProperty("java.security.manager"); //$NON-NLS-1$
/*[IF JAVA_SPEC_VERSION > 11]*/
if ("allow".equals(javaSecurityManager)) {
/* Do nothing. */
} else if ("disallow".equals(javaSecurityManager) //$NON-NLS-1$
/*[IF JAVA_SPEC_VERSION >= 18]*/
|| (null == javaSecurityManager)
/*[ENDIF] JAVA_SPEC_VERSION >= 18 */
) {
throwUOEFromSetSM = true;
} else
/*[ENDIF] JAVA_SPEC_VERSION > 11 */
if (null != javaSecurityManager) {
/*[IF JAVA_SPEC_VERSION >= 17]*/
initialErr.println("WARNING: A command line option has enabled the Security Manager"); //$NON-NLS-1$
initialErr.println("WARNING: The Security Manager is deprecated and will be removed in a future release"); //$NON-NLS-1$
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */
if (javaSecurityManager.isEmpty() || "default".equals(javaSecurityManager)) { //$NON-NLS-1$
setSecurityManager(new SecurityManager());
} else {
try {
Constructor<?> constructor = Class.forName(javaSecurityManager, true, applicationClassLoader).getConstructor();
constructor.setAccessible(true);
setSecurityManager((SecurityManager)constructor.newInstance());
} catch (Throwable e) {
/*[MSG "K0631", "JVM can't set custom SecurityManager due to {0}"]*/
throw new Error(com.ibm.oti.util.Msg.getString("K0631", e.toString()), e); //$NON-NLS-1$
}
}
}
}

/**
* Sets the active security manager. Note that once
* the security manager has been set, it can not be
Expand All @@ -1076,12 +1118,17 @@ public static void setSecurityManager(final SecurityManager s) {
@SuppressWarnings("removal")
final SecurityManager currentSecurity = security;

/*[IF JAVA_SPEC_VERSION >= 12]*/
if ("disallow".equals(systemProperties.getProperty("java.security.manager"))) { //$NON-NLS-1$ //$NON-NLS-2$
if ((currentSecurity == null) && (s == null)) {
/* Return if the input argument is null and no security manager has been established. */
return;
}

/*[IF JAVA_SPEC_VERSION > 11]*/
if (throwUOEFromSetSM) {
/*[MSG "K0B00", "The Security Manager is deprecated and will be removed in a future release"]*/
throw new UnsupportedOperationException(com.ibm.oti.util.Msg.getString("K0B00")); //$NON-NLS-1$
}
/*[ENDIF] JAVA_SPEC_VERSION >= 12 */
/*[ENDIF] JAVA_SPEC_VERSION > 11 */

/*[IF JAVA_SPEC_VERSION >= 17] */
Class<?> callerClz = getCallerClass();
Expand Down
7 changes: 4 additions & 3 deletions test/functional/JLM_Tests/playlist.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Copyright (c) 2016, 2021 IBM Corp. and others
Copyright (c) 2016, 2022 IBM Corp. and others

This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -21,6 +21,7 @@
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
-->
<playlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../TKG/playlist.xsd">
<include>$(TEST_ROOT)$(D)functional$(D)variables.mk</include>
<test>
<testCaseName>JLM_Tests_interface_SE80</testCaseName>
<variations>
Expand Down Expand Up @@ -64,7 +65,7 @@
<variation>NoOptions</variation>
<variation>-XX:+HeapManagementMXBeanCompatibility</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
<command>$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) \
--add-exports=jdk.management/com.ibm.lang.management.internal=ALL-UNNAMED --add-exports=java.management/com.ibm.java.lang.management.internal=ALL-UNNAMED \
-XX:SharedCacheHardLimit=16m -Xscmx1m -Xshareclasses:name=testJLM,reset \
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)jlm_tests.jar$(Q) \
Expand Down Expand Up @@ -190,7 +191,7 @@
<variation>NoOptions</variation>
<variation>-XX:+HeapManagementMXBeanCompatibility</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
<command>$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) \
--add-exports=jdk.management/com.ibm.lang.management.internal=ALL-UNNAMED --add-exports=java.management/com.ibm.java.lang.management.internal=ALL-UNNAMED \
-XX:SharedCacheHardLimit=16m -Xscmx1m -Xshareclasses:name=testJLM,reset \
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)jlm_tests.jar$(Q) \
Expand Down
4 changes: 3 additions & 1 deletion test/functional/Java8andUp/java8andUpSettings.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##############################################################################
# Copyright (c) 2018, 2021 IBM Corp. and others
# Copyright (c) 2018, 2022 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -20,6 +20,8 @@
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
##############################################################################

include $(TEST_ROOT)$(D)functional$(D)variables.mk

ADD_MODULE_JAVA_SE_EE=
# java.se.ee should only used for jdk 9 and 10
# if JDK_VERSION is 9 10
Expand Down
10 changes: 5 additions & 5 deletions test/functional/Java8andUp/playlist.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Copyright (c) 2016, 2021 IBM Corp. and others
Copyright (c) 2016, 2022 IBM Corp. and others

This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -1013,7 +1013,7 @@
<variation>-XX:RecreateClassfileOnload</variation>
<variation>-XX:+CompactStrings</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) -verbose:stacktrace -Djava.security.policy=$(Q)$(TEST_RESROOT)$(D)java.policy$(Q) \
<command>$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) -verbose:stacktrace -Djava.security.policy=$(Q)$(TEST_RESROOT)$(D)java.policy$(Q) \
-Drowset.provider.classname=org.openj9.resources.classloader.CustomSyncProvider \
--add-modules openj9.sharedclasses $(ADD_MODULE_JAVA_SE_EE) \
--add-exports java.base/com.ibm.oti.vm=ALL-UNNAMED \
Expand Down Expand Up @@ -1113,7 +1113,7 @@
<variation>-Xshareclasses:none</variation>
<variation>-Xshareclasses:none -XX:RecreateClassfileOnload</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) -verbose:stacktrace -Djava.security.policy=$(Q)$(TEST_RESROOT)$(D)java.policy$(Q) \
<command>$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) -verbose:stacktrace -Djava.security.policy=$(Q)$(TEST_RESROOT)$(D)java.policy$(Q) \
-Drowset.provider.classname=org.openj9.resources.classloader.CustomSyncProvider \
--add-modules openj9.sharedclasses $(ADD_MODULE_JAVA_SE_EE) \
--add-exports java.base/com.ibm.oti.vm=ALL-UNNAMED \
Expand Down Expand Up @@ -1362,7 +1362,7 @@
</variations>
<command>$(MKDIR) -p $(REPORTDIR); \
cd $(REPORTDIR); \
$(JAVA_COMMAND) $(JVM_OPTIONS) -verbose:stacktrace \
$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) -verbose:stacktrace \
-Djava.security.policy=$(Q)$(TEST_RESROOT)$(D)java.policy$(Q) \
-Xbootclasspath/a:$(TEST_RESROOT)$(D)TestResources.jar \
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)GeneralTest.jar$(P)$(TEST_RESROOT)$(D)TestResources.jar$(P)$(LIB_DIR)$(D)asm-all.jar$(Q) \
Expand Down Expand Up @@ -1459,7 +1459,7 @@
<variations>
<variation>NoOptions</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) -verbose:stacktrace \
<command>$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) -verbose:stacktrace \
--add-modules openj9.sharedclasses $(ADD_MODULE_JAVA_SE_EE) \
--add-exports java.base/com.ibm.oti.vm=ALL-UNNAMED \
--add-exports java.base/com.ibm.oti.util=ALL-UNNAMED \
Expand Down
10 changes: 5 additions & 5 deletions test/functional/Jsr292/playlist.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Copyright (c) 2016, 2021 IBM Corp. and others
Copyright (c) 2016, 2022 IBM Corp. and others

This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -111,7 +111,7 @@
<variation>NoOptions</variation>
<variation>Mode195</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
<command>$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) \
--add-opens=java.base/java.lang=ALL-UNNAMED \
-Djava.security.policy=$(Q)$(TEST_RESROOT)$(D)java.policy$(Q) \
-cp $(Q)$(TEST_RESROOT)$(D)jsr292test.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(LIB_DIR)$(D)asm-all.jar$(Q) \
Expand Down Expand Up @@ -200,7 +200,7 @@
<variations>
<variation>-Xjit:count=0</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
<command>$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) \
--add-opens=java.base/java.lang=ALL-UNNAMED \
-Djava.security.policy=$(Q)$(TEST_RESROOT)$(D)java.policy$(Q) \
-cp $(Q)$(TEST_RESROOT)$(D)jsr292test.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(LIB_DIR)$(D)asm-all.jar$(Q) \
Expand Down Expand Up @@ -257,7 +257,7 @@
<variations>
<variation>NoOptions</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
<command>$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) \
--add-opens=java.base/java.lang=ALL-UNNAMED --add-exports java.base/jdk.internal.reflect=ALL-UNNAMED \
-Xbootclasspath/a:$(Q)$(TEST_RESROOT)$(D)jsr292bootstrap.jar$(Q) \
-cp $(Q)$(TEST_RESROOT)$(D)jsr292test.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(Q) \
Expand All @@ -281,7 +281,7 @@
<variations>
<variation>Mode195</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
<command>$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) \
--add-opens=java.base/java.lang=ALL-UNNAMED --add-exports java.base/jdk.internal.reflect=ALL-UNNAMED \
-Xbootclasspath/a:$(Q)$(TEST_RESROOT)$(D)jsr292bootstrap.jar$(Q) \
-cp $(Q)$(TEST_RESROOT)$(D)jsr292test.jar$(P)$(RESOURCES_DIR)$(P)$(TESTNG)$(Q) \
Expand Down
5 changes: 3 additions & 2 deletions test/functional/Jsr292/variables.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##############################################################################
# Copyright (c) 2018, 2018 IBM Corp. and others
# Copyright (c) 2018, 2022 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -20,8 +20,9 @@
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
##############################################################################

include $(TEST_ROOT)$(D)functional$(D)variables.mk

XMLSUFFIX=
ifeq ($(JDK_VERSION), 8)
XMLSUFFIX=_8
endif
endif
5 changes: 3 additions & 2 deletions test/functional/cmdLineTests/J9security/playlist.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Copyright (c) 2016, 2021 IBM Corp. and others
Copyright (c) 2016, 2022 IBM Corp. and others

This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -21,6 +21,7 @@
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
-->
<playlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../TKG/playlist.xsd">
<include>$(TEST_ROOT)$(D)functional$(D)variables.mk</include>
<test>
<testCaseName>cmdLineTester_J9securityTests_SE80</testCaseName>
<variations>
Expand Down Expand Up @@ -55,7 +56,7 @@
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) -Xdump \
-DMODULE_ADDEXPORTS_OPTION=$(Q)--add-exports$(Q) -DMODULE_ADDEXPORTS_VALUE=$(Q)java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED$(Q) \
-DTESTJ9SECURITYJARPATH=$(Q)$(TEST_RESROOT)$(D)$(Q) -DRESJAR=$(CMDLINETESTER_RESJAR) \
-DEXE=$(SQ)$(JAVA_COMMAND) $(JVM_OPTIONS) -Xdump$(SQ) -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)j9SecurityTest.xml$(Q) \
-DEXE=$(SQ)$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) -Xdump$(SQ) -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)j9SecurityTest.xml$(Q) \
-explainExcludes -nonZeroExitWhenError; \
$(TEST_STATUS)</command>
<levels>
Expand Down
20 changes: 15 additions & 5 deletions test/functional/cmdLineTests/proxyFieldAccess/playlist.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Copyright (c) 2016, 2021 IBM Corp. and others
Copyright (c) 2016, 2022 IBM Corp. and others

This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -21,13 +21,18 @@
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
-->
<playlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../TKG/playlist.xsd">
<include>$(TEST_ROOT)$(D)functional$(D)variables.mk</include>
<test>
<testCaseName>cmdLineTester_ProxyFieldAccess_SE80</testCaseName>
<variations>
<variation>NoOptions</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) -Xdump -DTESTPROXYFIELDACCESSJAR=$(Q)$(TEST_RESROOT)$(D)testproxyfieldaccess.jar$(Q) -DTESTDIR=$(Q)$(TEST_RESROOT)$(Q) -DRESJAR=$(CMDLINETESTER_RESJAR) -DEXE=$(SQ)$(JAVA_COMMAND) $(JVM_OPTIONS) -Xdump$(SQ) -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)testproxyfieldaccess.xml$(Q) -explainExcludes -nonZeroExitWhenError -xids all,$(PLATFORM),$(VARIATION) $(CMDLINETESTER_XLIST); \
${TEST_STATUS}</command>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) -Xdump \
-DTESTPROXYFIELDACCESSJAR=$(Q)$(TEST_RESROOT)$(D)testproxyfieldaccess.jar$(Q) \
-DTESTDIR=$(Q)$(TEST_RESROOT)$(Q) -DRESJAR=$(CMDLINETESTER_RESJAR) \
-DEXE=$(SQ)$(JAVA_COMMAND) $(JVM_OPTIONS) -Xdump$(SQ) -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)testproxyfieldaccess.xml$(Q) \
-explainExcludes -nonZeroExitWhenError -xids all,$(PLATFORM),$(VARIATION) $(CMDLINETESTER_XLIST); \
${TEST_STATUS}</command>
<levels>
<level>sanity</level>
</levels>
Expand All @@ -42,13 +47,18 @@
<version>8</version>
</versions>
</test>

<test>
<testCaseName>cmdLineTester_ProxyFieldAccess</testCaseName>
<variations>
<variation>NoOptions</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) -Xdump -DTESTPROXYFIELDACCESSJAR=$(Q)$(TEST_RESROOT)$(D)testproxyfieldaccess.jar$(Q) -DTESTDIR=$(Q)$(TEST_RESROOT)$(Q) -DRESJAR=$(CMDLINETESTER_RESJAR) -DEXE=$(SQ)$(JAVA_COMMAND) $(JVM_OPTIONS) --add-opens=java.base/java.lang=ALL-UNNAMED --add-reads java.base=jdk.unsupported --add-opens=java.base/java.lang=ALL-UNNAMED -Xdump$(SQ) -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)testproxyfieldaccess.xml$(Q) -explainExcludes -nonZeroExitWhenError -xids all,$(PLATFORM),$(VARIATION) $(CMDLINETESTER_XLIST); \
${TEST_STATUS}</command>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) -Xdump \
-DTESTPROXYFIELDACCESSJAR=$(Q)$(TEST_RESROOT)$(D)testproxyfieldaccess.jar$(Q) \
-DTESTDIR=$(Q)$(TEST_RESROOT)$(Q) -DRESJAR=$(CMDLINETESTER_RESJAR) \
-DEXE=$(SQ)$(JAVA_COMMAND) $(JAVA_SECURITY_MANAGER) $(JVM_OPTIONS) --add-opens=java.base/java.lang=ALL-UNNAMED --add-reads java.base=jdk.unsupported --add-opens=java.base/java.lang=ALL-UNNAMED -Xdump$(SQ) -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)testproxyfieldaccess.xml$(Q) \
-explainExcludes -nonZeroExitWhenError -xids all,$(PLATFORM),$(VARIATION) $(CMDLINETESTER_XLIST); \
${TEST_STATUS}</command>
<levels>
<level>sanity</level>
</levels>
Expand Down
30 changes: 30 additions & 0 deletions test/functional/variables.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
##############################################################################
# Copyright (c) 2022, 2022 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
# or the Apache License, Version 2.0 which accompanies this distribution and
# is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following
# Secondary Licenses when the conditions for such availability set
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
# General Public License, version 2 with the GNU Classpath
# Exception [1] and GNU General Public License, version 2 with the
# OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] http://openjdk.java.net/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
##############################################################################

# In JDK18+, java.security.manager == null behaves as -Djava.security.manager=disallow.
# In JDK17-, java.security.manager == null behaves as -Djava.security.manager=allow.
# For OpenJ9 tests to work as expected, -Djava.security.manager=allow behaviour is
# needed in JDK18+.
JAVA_SECURITY_MANAGER=
ifeq ($(filter 8 9 10 11 12 13 14 15 16 17, $(JDK_VERSION)),)
JAVA_SECURITY_MANAGER=-Djava.security.manager=allow
endif