JDK-8282551 : Properly initialize L32X64MixRandom state
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 17,18,19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-03-02
  • Updated: 2022-04-01
  • Resolved: 2022-03-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 18 JDK 19
17.0.4Fixed 18.0.2Fixed 19 b12Fixed
Related Reports
Relates :  
Description
issue created for https://github.com/openjdk/jdk/pull/7120;

L32X64MixRandom does not initialize x0 and x1 fields.
Comments
For the record. A simple reproducer is: $ cat RandomGeneratorBroken.java import java.util.*; import java.util.random.*; public class RandomGeneratorBroken { public static void main(String[] args) { var numbers = new HashSet<>(); for (int i = 0; i < 1_00; i++) { numbers.add(RandomGenerator.getDefault().nextInt()); } System.out.println(numbers.size()); } } Before: $ java -showversion RandomGeneratorBroken openjdk version "17.0.2" 2022-01-18 OpenJDK Runtime Environment 21.9 (build 17.0.2+8) OpenJDK 64-Bit Server VM 21.9 (build 17.0.2+8, mixed mode, sharing) 1 After: $ java -showversion RandomGeneratorBroken openjdk version "17.0.4-internal" 2022-07-19 OpenJDK Runtime Environment (build 17.0.4-internal+0-adhoc.sgehwolf.jdk17u-dev) OpenJDK 64-Bit Server VM (build 17.0.4-internal+0-adhoc.sgehwolf.jdk17u-dev, mixed mode, sharing) 100
28-03-2022

Fix Request (OpenJDK 18u & 17u): Please approve backporting this fix to JDK 18u and 17u. Both JDKs have this issue as well: Default RandomGenerator returning the same initial integer value. This was originally reported here: https://github.com/adoptium/adoptium-support/issues/480. The patch applies cleanly and is low risk. Testing: Fails reproducer in the adoptium issue before and passes after. Also via GHA.
28-03-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk17u-dev/pull/286 Date: 2022-03-28 09:29:00 +0000
28-03-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk18u/pull/55 Date: 2022-03-28 09:27:57 +0000
28-03-2022

Changeset: ce18ff85 Author: Devin Smith <devinrsmith@protonmail.com> Committer: Jim Laskey <jlaskey@openjdk.org> Date: 2022-03-02 16:41:13 +0000 URL: https://git.openjdk.java.net/jdk/commit/ce18ff8527cc51805bf11c50c050ea64c3f9dec0
02-03-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7120 Date: 2022-01-18 01:39:52 +0000
02-03-2022