Causes :
|
|
Duplicate :
|
|
Relates :
|
Test java/lang/System/SecurityManagerWarnings.java fails with --enable-preview enabled. The problem is that this test makes jar from SecurityManagerWarnings.java classes. Then it executes it with java -cp a.jar SecurityManagerWarnings run and expects to have java.lang.UnsupportedOperationException: Setting a Security Manager is not supported at java.base/java.lang.System.setSecurityManager(System.java:286) at A.run(SecurityManagerWarnings.java:113) at SecurityManagerWarnings.main(SecurityManagerWarnings.java:66) However, running with --enable preview generates other error java --enable-preview -cp a.jar SecurityManagerWarnings run Error: Unable to initialize main class SecurityManagerWarnings Caused by: java.lang.NoClassDefFoundError: jdk/test/lib/process/OutputAnalyzer The problem is that SecurityManagerWarnings class depends on the OutputAnalyzer. The class is not used in the executed path and VM don't try to resolve i. But VM with --enable-preview tries to verify the main() method and resolve all dependencies. Not sure what spec says, but from my point of view test seems wrong. It is not a good to try to run classes with unresolved dependencies.
|