Repository navigation
Description
This issue applies to tests that utilize System.setSecurityManager.
JDK18
In JDK18, the security manager is disallowed by default when the java.security.manager system property is not specified. Currently, the security manager tests in OpenJ9 cannot be selectively disabled. To keep the security manager tests correctly functioning, -Djava.security.manager=allow needs to be specified while running these tests with OpenJ9 and other implementations.
As per adoptium/TKG#263 (comment), only the OpenJ9 repo has tests which use System.setSecurityManager. The second commit in #14329 sets the java.security.manager property for the impacted tests in OpenJ9.
Related:
- Account for java.security.manager behaviour changes in JDK18 adoptium/TKG#263
- Update java.security.manager behaviour #14329
Future JDK
In a future JDK, the security manager will be removed. So, the security manager tests in OpenJ9 will need to be disabled.
If the compilation of the tests need to be disabled, then they would need to be separated from their current environment and run standalone. This may be challenging and will require substantially more time.
Disabling the tests during runtime may be easier. This can be achieved without separating the tests. org.junit.Assume.assumeTrue allows a test to be ignored based upon a condition. In this case, the condition would return FALSE if a security manager is not allowed based upon the JDK version and java.security.manager system property.
Impacted Tests
In OpenJ9, the impacted security manager tests are:
Impacted Java8andUp tests:
- JCL_TEST_Java-Security
- JCL_TEST_Java-Lang
- JCL_TEST_Java-Lang-Invoke
- JCL_TEST_Java-Lang_ClassLoader
- JCL_TEST_Java-Internals
- JCL_TEST_IBM-VM
- JCL_TEST_Java-Lang-Ref
Impacted JLM_Tests:
- JLM_Tests_IBMinternal
- TestMemoryMXBean
Impacted Jsr292 tests:
- jsr292Test
- jsr292BootstrapTest
Impacted cmdLineTests:
- J9security
- proxyFieldAccess
For system tests, only the framework which launches system tests is impacted: stf.load/src/stf.load/net/adoptopenjdk/loadTest/LoadTest.java. SecurityManager.checkExit is used to prevent tests from exiting the process. Currently, there is no replacement for SecurityManager.checkExit. This issue is being tracked in https://bugs.openjdk.java.net/browse/JDK-8199704. The goal is to add an ability to intercept or disable System::exit.
How to identify classes and methods dependent on the Security Manager?
This is a useful resource: https://openjdk.java.net/jeps/411. There is a section titled: Deprecate APIs for removal. It lists the classes and methods, which will be terminally deprecated and retained. This information can be used in segregation of tests, specifically to identify classes and methods which are strongly dependent on the security manager.
Activity
babsingh commentedon Feb 1, 2022
fyi @pshipton @tajila @smlambert @llxia @renfeiw
babsingh commentedon Feb 1, 2022
@pshipton when the security manager is removed, do we need to disable compilation of those tests? or disabling the tests during runtime should be sufficient?
pshipton commentedon Feb 1, 2022
I expect the tests won't compile on the new jdk since there won't be any java.lang.SecurityManager class available.
babsingh commentedon Feb 1, 2022
The above statement is wrong. The system tests do use the Security Manager. Initially, I only looked at https://github.com/adoptium/aqa-systemtest. The system tests use code from https://github.com/adoptium/STF which utilizes the Security Manager.
Personal build: https://hyc-runtimes-jenkins.swg-devops.com/view/OpenJ9%20-%20Personal/job/Pipeline-Build-Test-Personal/11686/
With JDK18's
java.security.managerbehaviour, the following exception is thrown:Requested help from @Mesbah-Alam to figure the best approach to handle the below failures. Current options: either add
-Djava.security.manager=allowor remove the use of theSecurityManagerclass.56 failing sanity.system test targets
29 failing extended.system test targets
Mesbah-Alam commentedon Feb 1, 2022
Yes, all load tests in STF based system tests will invoke LoadTests.java and thus invoke overrideSecurityManager(). From the comment in the code, it was added there to "block System.exit attempts" - that'd probably be made by the third party Mauve tests that system tests run. We need to find a replacement solution to do the same; we may add
-Djava.security.manager=allowfor JDK18 as a temporary solution.pshipton commentedon Feb 2, 2022
For jdk18 using
-Djava.security.manager=allowis the permanent solution. I'm guessing sometime between jdk19 and jdk21 (and I'm leaning towards jdk19) the java.lang.SecurityManager will be removed.-Djava.security.manager=allowwon't work and code that uses SecurityManager won't compile. We should consider how we are going to handle that when it happens.The other one to think about is https://openjdk.java.net/jeps/421, finalization will be removed as some point as well. Not sure if any system tests are using it. I'm guessing finalization may be disabled by default in jdk19 and removed in jdk20.
JasonFengJ9 commentedon Feb 2, 2022
If that's a correct prediction, disabling Security Manager tests (build & run) can start from JDK18 instead of setting
-Djava.security.manager=allowfor non-LTS versions before its actual removal. The tests for JDK17 and earlier LTS levels should be retained.JEP 421 (Finalization removal) will have similar requirements as well, but I think it is in much smaller scale comparing to how much security manager tests present.
[JDK18+] Set java.security.manager property for tests
[JDK18+] Set java.security.manager property for system tests
babsingh commentedon Feb 2, 2022
There are OpenJDK and other non-openj9 tests related to the security manager for JDK18. Disabling security manager tests in OpenJ9 instead of setting
-Djava.security.manager=allowmay prevent us to pass those non-openj9 tests which are not frequently run.+1 to begin segregating/isolating security manager tests so they can be disabled once the security manager is removed in a future JDK. Segregating security manager tests will be challenging since it is widely used in functional and system tests. Also, isolating some tests may be difficult because they are deeply dependent on their current test environment. I don't think it is feasible to achieve this for the JDK18 release.
[JDK18+] Set java.security.manager property for system tests
14 remaining items
cjjdespres commentedon Feb 28, 2022
@babsingh Out of curiosity, did the failures in your comment all look like
as you mentioned? There were a lot of recent JITServer test failures with substantial overlap with that list, and I wanted to confirm whether or not that was coincidence. (None of the JITServer test failures looked like that, of course).
babsingh commentedon Feb 28, 2022
@cjjdespres Yes, all failures had
UnsupportedOperationExceptionwhenSystem.setSecurityManagerwas invoked with the security manager disabled. None of the failures in #14538 are related to the security manager.Separate tests that rely on SecurityManager (Java8andUp)
Separate tests that rely on SecurityManager (Java8andUp)
Separate tests that rely on SecurityManager (JLM_Tests)
Separate tests that rely on SecurityManager (Jsr292)
Separate tests that rely on SecurityManager (JLM_Tests)
Separate tests that rely on SecurityManager (Jsr292)
theresa-m commentedon Feb 4, 2025
The system test frameworks reliance on the security manager has been resolved.
@babsingh do you want this issue to remain open?
babsingh commentedon Feb 4, 2025
Yes, we can close it. #20563 tracks the removal of the security manager and the disablement of all security manager tests.