WeakHashMap: Remove some unnecessary lazy initialization.

If altHashing is true, we will almost always use the hashCode, so
there's no point lazily initializing it (and paying for an additional
field and synchronization).

Note that altHashing is turned off by default.

Change-Id: I08a4064846a549a186e397f63dee968ea7388a03
diff --git a/ojluni/src/main/java/java/util/WeakHashMap.java b/ojluni/src/main/java/java/util/WeakHashMap.java
index a8ca523..652b053 100755
--- a/ojluni/src/main/java/java/util/WeakHashMap.java
+++ b/ojluni/src/main/java/java/util/WeakHashMap.java
@@ -243,9 +243,10 @@
     /**
      * A randomizing value associated with this instance that is applied to
      * hash code of keys to make hash collisions harder to find.
+     *
+     * This hash seed is only used if {@code useAltHashing} is true.
      */
     transient int hashSeed;
-    volatile boolean seedSet = false;
 
     @SuppressWarnings("unchecked")
     private Entry<K,V>[] newTable(int n) {
@@ -279,6 +280,11 @@
         threshold = (int)(capacity * loadFactor);
         useAltHashing = sun.misc.VM.isBooted() &&
                 (capacity >= Holder.ALTERNATIVE_HASHING_THRESHOLD);
+        if (useAltHashing) {
+            hashSeed = sun.misc.Hashing.randomHashSeed(this);
+        } else {
+            hashSeed = 0;
+        }
     }
 
     /**
@@ -357,14 +363,6 @@
 
         int h;
         if (useAltHashing) {
-            if (!seedSet) {
-                synchronized(this) {
-                    if (!seedSet) {
-                        hashSeed = sun.misc.Hashing.randomHashSeed(this);
-                        seedSet = true;
-                    }
-                }
-            }
             h = hashSeed;
             if (k instanceof String) {
                 return sun.misc.Hashing.stringHash32((String) k);
@@ -572,6 +570,9 @@
         useAltHashing |= sun.misc.VM.isBooted() &&
                 (newCapacity >= Holder.ALTERNATIVE_HASHING_THRESHOLD);
         boolean rehash = oldAltHashing ^ useAltHashing;
+        if (rehash) {
+            hashSeed = sun.misc.Hashing.randomHashSeed(this);
+        }
         transfer(oldTable, newTable, rehash);
         table = newTable;