8020292: j.u.SplittableRandom

Paul Sandoz paul.sandoz at oracle.com
Tue Aug 27 08:19:37 UTC 2013

On Aug 27, 2013, at 8:54 AM, Peter Levart <peter.levart at gmail.com> wrote:

> Hi,
> The system property name "java.util.secureRandomSeed" suggests that it is not for SplittableRandom only. Now that ThreadLocalRandom is algorithmically aligned with SplittableRandom, should initial seed for TLR instances also use the same algorithm?

Well spotted, yes that was the intention. 

We did sync this with TLR but ran into an issue due to it's current use in WeakHashMap and Hashtable e.g. in WeakHashMap:

    final void initHashSeed() {
        if (sun.misc.VM.isBooted() && Holder.USE_HASHSEED) {
            // Do not set hashSeed more than once!
            // assert hashSeed == 0;
            int seed = ThreadLocalRandom.current().nextInt();
            hashSeed = (seed != 0) ? seed : 1;

The first call to TLR.current() will initialize the TLR class and uses InetAddress or SecureRandom, which in turn results in use of WeakHashMap and the second call to TLR.current() that throws a NPE that causes an java.lang.ExceptionInInitializerError.

My understanding is the hash seed functionality will be removed and when done we can add such functionality back to TLR.

It would be good to remove this functionality soonish so we can get this feature in.


More information about the core-libs-dev mailing list