[jdk11u-dev] RFR: 8280550: SplittableRandom#nextDouble(double,double) can return result >= bound [v3]
Goetz Lindenmaier
goetz at openjdk.org
Wed Nov 2 07:58:15 UTC 2022
On Mon, 31 Oct 2022 17:26:47 GMT, Goetz Lindenmaier <goetz at openjdk.org> wrote:
>> 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.
>
> Goetz Lindenmaier has updated the pull request incrementally with one additional commit since the last revision:
>
> Remove stray comments
Good catch of this further appearance. I agree the fix is not needed there. But the methods there might not always deliver the previous double either.
-------------
PR: https://git.openjdk.org/jdk11u-dev/pull/1478
More information about the jdk-updates-dev
mailing list