src/share/classes/sun/misc/Hashing.java

Print this page

        

*** 22,32 **** * or visit www.oracle.com if you need additional information or have any * questions. */ package sun.misc; ! import java.util.Random; /** * Hashing utilities. * * Little endian implementations of Murmur3 hashing. --- 22,32 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ package sun.misc; ! import java.util.concurrent.ThreadLocalRandom; /** * Hashing utilities. * * Little endian implementations of Murmur3 hashing.
*** 205,236 **** return h1; } /** ! * Holds references to things that can't be initialized until after VM ! * is fully booted. ! */ ! private static class Holder { ! ! /** ! * Used for generating per-instance hash seeds. * ! * We try to improve upon the default seeding. */ - static final Random SEED_MAKER = new Random( - Double.doubleToRawLongBits(Math.random()) - ^ System.identityHashCode(Hashing.class) - ^ System.currentTimeMillis() - ^ System.nanoTime() - ^ Runtime.getRuntime().freeMemory()); - } - public static int randomHashSeed(Object instance) { int seed; if (sun.misc.VM.isBooted()) { ! seed = Holder.SEED_MAKER.nextInt(); } else { // lower quality "random" seed value--still better than zero and not // not practically reversible. int hashing_seed[] = { System.identityHashCode(Hashing.class), --- 205,224 ---- return h1; } /** ! * Return a non-zero 32-bit pseudo random value. The {@code instance} object ! * may be used as part of the value. * ! * @param instance an object to use if desired in choosing value. ! * @return a non-zero 32-bit pseudo random value. */ public static int randomHashSeed(Object instance) { int seed; if (sun.misc.VM.isBooted()) { ! seed = ThreadLocalRandom.current().nextInt(); } else { // lower quality "random" seed value--still better than zero and not // not practically reversible. int hashing_seed[] = { System.identityHashCode(Hashing.class),