RFR: 8279598: Provide adapter from RandomGenerator to Random [v20]

Stuart Marks smarks at openjdk.java.net
Wed Apr 27 19:29:55 UTC 2022


On Thu, 21 Apr 2022 03:48:21 GMT, Yasser Bazzi <duke at openjdk.java.net> wrote:

>> Hi, could i get a review on this implementation proposed by Stuart Marks, i decided to use the https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/random/RandomGenerator.html interface to create the default method `asRandom()` that wraps around the newer algorithms to be used on classes that do not accept the new interface.
>> 
>> Some things to note as proposed by the bug report, the protected method next(int bits) is not overrided and setSeed() method if left blank up to discussion on what to do with it.
>> 
>> Small test done on https://gist.github.com/YShow/da678561419cda8e32fccf3a27a649d4
>
> Yasser Bazzi has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Update setSeed docs on Random class
>  - Add nicer toString method to random wrapper

Hi, thanks for the updates.

I've made some modifications to the specs of `setSeed` and `next(bits)` for good measure, since the latter also needed to be updated to accommodate overrides made by subclasses. If these changes are satisfactory, please pull them into this PR, and I'll update the CSR correspondingly. Changes are in this branch:

https://github.com/stuart-marks/jdk/tree/JDK-8279598-RandomGenerator-adapter

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

PR: https://git.openjdk.java.net/jdk/pull/7001


More information about the core-libs-dev mailing list