[jdk11u-dev] RFR: 8280550: SplittableRandom#nextDouble(double, double) can return result >= bound

Goetz Lindenmaier goetz at openjdk.org
Wed Oct 26 13:54:55 UTC 2022


The original fix patches jdk/internal/util/random/RandomSupport.java.
This class is not in 11.

The Random code was completely reworked by
"8248862: Implement Enhanced Pseudo-Random Number Generators"
In the old 11 code there are several methods 'nextDouble' or
'internalNextDouble' all using the same pattern.  They were
replaced by the implementation in the new class
RandomSupport in 17.

I adapted the following methods:
in java/util/Random.java:
  final double internalNextDouble(double origin, double bound)

in java/util/SplittableRandom.java
  final double internalNextDouble(double origin, double bound)
  public double nextDouble(double bound)

in java/util/concurrent/ThreadLocalRandom.java
  final double internalNextDouble(double origin, double bound)
  public double nextDouble(double bound)

I think this are all affected methods, but please double-check.

The change requires follow-up 8280950 which needs to be
adapted to touch the three internalNextDouble()
methods.

-------------

Commit messages:
 - Backport 0c42e43f77b91a50fedc3fddb74e17f910d8df2a

Changes: https://git.openjdk.org/jdk11u-dev/pull/1478/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk11u-dev&pr=1478&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8280550
  Stats: 8 lines in 3 files changed: 3 ins; 0 del; 5 mod
  Patch: https://git.openjdk.org/jdk11u-dev/pull/1478.diff
  Fetch: git fetch https://git.openjdk.org/jdk11u-dev pull/1478/head:pull/1478

PR: https://git.openjdk.org/jdk11u-dev/pull/1478


More information about the jdk-updates-dev mailing list