stefanbirkner / system-rules

A collection of JUnit rules for testing code which uses java.lang.System.
http://stefanbirkner.github.io/system-rules
Other
546 stars 71 forks source link

UnsupportedOperationException with jdk-18 #85

Open siom79 opened 2 years ago

siom79 commented 2 years ago

Under jdk-18 I get a UnsupportedOperationException:

java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release

    at java.base/java.lang.System.setSecurityManager(System.java:416)
    at org.junit.contrib.java.lang.system.ProvideSecurityManager.before(ProvideSecurityManager.java:39)
    at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:50)
    at org.junit.contrib.java.lang.system.internal.PrintStreamRule$1$1.evaluate(PrintStreamRule.java:39)
    at org.junit.contrib.java.lang.system.internal.PrintStreamHandler$3.evaluate(PrintStreamHandler.java:44)
    at org.junit.contrib.java.lang.system.internal.PrintStreamRule$1.evaluate(PrintStreamRule.java:35)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
ottlinger commented 2 years ago

Same issue while trying to upgrade to JDK18 - is there a simple workaround available or a plan to get this wonderful library to work with JDK18? Thanks

judovana commented 2 years ago

For now you can use -Djava.security.manager=allow but on longer run it would need majore rework - https://openjdk.java.net/jeps/411

dkfellows commented 1 year ago

See also: https://bugs.openjdk.org/browse/JDK-8199704 (and maybe others)

zanzanYL commented 8 months ago

Bumped into same error when upgrading to jdk 21

zanzanYL commented 8 months ago

I am only using ExpectedSystemExit from system-rules. If there is alternative to this, please let me know!