--- old/src/java.base/share/classes/java/util/ImmutableCollections.java 2020-04-26 22:07:13.624304664 -0700 +++ new/src/java.base/share/classes/java/util/ImmutableCollections.java 2020-04-26 22:07:13.496299845 -0700 @@ -64,14 +64,22 @@ private static final boolean REVERSE; static { // to generate a reasonably random and well-mixed SALT, use an arbitrary - // value (a slice of pi), multiply with the System.nanoTime, then pick + // value (a slice of pi), multiply with a random seed, then pick // the mid 32-bits from the product. By picking a SALT value in the // [0 ... 0xFFFF_FFFFL == 2^32-1] range, we ensure that for any positive // int N, (SALT32L * N) >> 32 is a number in the [0 ... N-1] range. This // property will be used to avoid more expensive modulo-based // calculations. long color = 0x243F_6A88_85A3_08D3L; // slice of pi - long seed = System.nanoTime(); + + // When running with -Xshare:dump, the VM will supply a "random" seed that's + // derived from the JVM build/version, so can we generate the exact same + // CDS archive for the same JDK build. This makes it possible to verify the + // consistency of the JDK build. + long seed = VM.getRandomSeedForCDSDump(); + if (seed == 0) { + seed = System.nanoTime(); + } SALT32L = (int)((color * seed) >> 16) & 0xFFFF_FFFFL; // use the lowest bit to determine if we should reverse iteration REVERSE = (SALT32L & 1) == 0;