I have the following program:
public static void main(String[] args) throws Exception{
ForkJoinTask<?> read = ForkJoinPool.commonPool().submit(new Runnable() {
@Override
public void run() {
SecurityManager appsm = System.getSecurityManager();
if (appsm != null) {
appsm.checkPermission(new PropertyPermission("os.arch", "read"));
System.out.println("Permissions are OK!!!!");
} else {
System.out.println("No system mangerrr :(");
}
}
});
read.get();
System.out.println("End of the program!");
}
I also set this system property:
-Djava.security.manager
My question is the following - why sometimes I get "End of the program!" written to the standard output, but sometimes I get Exception in thread "main" java.util.concurrent.ExecutionException: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "os.arch" "read") ?
Shouldn't it always throw me this exception since the common pool's threads are created without any permissions? Shouldn't this behavior be always the same and do not vary throughout the different executions?
I am running this from my IntelliJ IDE using Zulu OPEN JDK 8.0.252.