public class S3ButcketTest
{
public static void main(String args[])
{
System.setSecurityManager(new RMISecurityManager());
ForkJoinPool pool = new ForkJoinPool(1);
System.out.println("main: "+Policy.getPolicy());
pool.execute(new Runnable()
{
@Override
public void run()
{
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println("pool: "+Policy.getPolicy());
}
});
pool.shutdown();
try
{
pool.awaitTermination(1000, TimeUnit.SECONDS);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
Работа в двух разных версиях JDK (8 и 11) с аргументом виртуальной машины: -Djava.security.policy = C: \ test_system.policy
test_system.policy Содержимое:
grant {
permission java.security.AllPermission;
};
Вывод при работе с JDK11:
main: sun.security.provider.PolicyFile@4cb2c100
Exception in thread "ForkJoinPool-1-worker-3" java.security.AccessControlException: access denied ("java.security.SecurityPermission" "getPolicy")
at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.base/java.security.AccessController.checkPermission(AccessController.java:895)
at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:322)
at java.base/java.security.Policy.getPolicy(Policy.java:159)
at S3ButcketTest$1.run(S3ButcketTest.java:30)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Вывод при работе с JDK8:
main: sun.security.provider.PolicyFile@1b84c92
pool: sun.security.provider.PolicyFile@1b84c92
Мы обновили наш JDK с 8 до 11 и внезапномы сталкиваемся с этой проблемой.Есть ли объяснение, почему это происходит?Любое решение?