src/share/classes/java/util/Hashtable.java
Print this page
@@ -24,10 +24,11 @@
*/
package java.util;
import java.io.*;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.BiFunction;
/**
@@ -217,11 +218,12 @@
* Return an initial value for the hashSeed, or 0 if the random seed is not
* enabled.
*/
final int initHashSeed() {
if (sun.misc.VM.isBooted() && Holder.USE_HASHSEED) {
- return sun.misc.Hashing.randomHashSeed(this);
+ int seed = ThreadLocalRandom.current().nextInt();
+ return (0 != seed) ? seed : 1;
}
return 0;
}
private int hash(Object k) {
@@ -1204,12 +1206,13 @@
// Read in the length, threshold, and loadfactor
s.defaultReadObject();
// set hashMask
if (Holder.USE_HASHSEED) {
+ int seed = ThreadLocalRandom.current().nextInt();
Holder.UNSAFE.putIntVolatile(this, Holder.HASHSEED_OFFSET,
- sun.misc.Hashing.randomHashSeed(this));
+ 0 != seed ? seed : 1);
}
// Read the original length of the array and number of elements
int origlength = s.readInt();
int elements = s.readInt();