jdk/src/java.base/share/classes/java/util/SplittableRandom.java
changeset 36232 7a020ad42ac0
parent 36015 c263d0e3b073
child 42927 1d31e540bfcb
--- a/jdk/src/java.base/share/classes/java/util/SplittableRandom.java	Thu Mar 03 10:36:08 2016 -0800
+++ b/jdk/src/java.base/share/classes/java/util/SplittableRandom.java	Thu Mar 03 10:39:34 2016 -0800
@@ -219,12 +219,20 @@
         return seed += gamma;
     }
 
+    // IllegalArgumentException messages
+    static final String BAD_BOUND = "bound must be positive";
+    static final String BAD_RANGE = "bound must be greater than origin";
+    static final String BAD_SIZE  = "size must be non-negative";
+
     /**
      * The seed generator for default constructors.
      */
-    private static final AtomicLong defaultGen = new AtomicLong(initialSeed());
+    private static final AtomicLong defaultGen
+        = new AtomicLong(mix64(System.currentTimeMillis()) ^
+                         mix64(System.nanoTime()));
 
-    private static long initialSeed() {
+    // at end of <clinit> to survive static initialization circularity
+    static {
         if (java.security.AccessController.doPrivileged(
             new java.security.PrivilegedAction<Boolean>() {
                 public Boolean run() {
@@ -234,17 +242,10 @@
             long s = (long)seedBytes[0] & 0xffL;
             for (int i = 1; i < 8; ++i)
                 s = (s << 8) | ((long)seedBytes[i] & 0xffL);
-            return s;
+            defaultGen.set(s);
         }
-        return (mix64(System.currentTimeMillis()) ^
-                mix64(System.nanoTime()));
     }
 
-    // IllegalArgumentException messages
-    static final String BAD_BOUND = "bound must be positive";
-    static final String BAD_RANGE = "bound must be greater than origin";
-    static final String BAD_SIZE  = "size must be non-negative";
-
     /*
      * Internal versions of nextX methods used by streams, as well as
      * the public nextX(origin, bound) methods.  These exist mainly to