8179515: Class java.util.concurrent.ThreadLocalRandom fails to Initialize when using SecurityManager
authordl
Thu, 11 May 2017 19:34:59 -0400
changeset 45127 f8961f9da1d4
parent 45125 36fd126403f0
child 45128 629171363c31
8179515: Class java.util.concurrent.ThreadLocalRandom fails to Initialize when using SecurityManager Summary: Break connection to security framework by using VM.getSavedProperty to read the proeprty. Reviewed-by: dholmes, martin, redestad, psandoz, mchung
jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java	Thu May 11 18:10:40 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java	Thu May 11 19:34:59 2017 -0400
@@ -49,6 +49,7 @@
 import java.util.stream.LongStream;
 import java.util.stream.StreamSupport;
 import jdk.internal.misc.Unsafe;
+import jdk.internal.misc.VM;
 
 /**
  * A random number generator isolated to the current thread.  Like the
@@ -1093,11 +1094,8 @@
 
     // at end of <clinit> to survive static initialization circularity
     static {
-        if (java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<>() {
-                public Boolean run() {
-                    return Boolean.getBoolean("java.util.secureRandomSeed");
-                }})) {
+        String sec = VM.getSavedProperty("java.util.secureRandomSeed");
+        if (Boolean.parseBoolean(sec)) {
             byte[] seedBytes = java.security.SecureRandom.getSeed(8);
             long s = (long)seedBytes[0] & 0xffL;
             for (int i = 1; i < 8; ++i)