On Sun, 20 Feb 2022 03:15:22 GMT, Yasser Bazzi <d...@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 one additional > commit since the last revision: > > remove missed whitespace src/java.base/share/classes/java/util/Random.java line 95: > 93: private static class RandomWrapper extends Random implements > RandomGenerator { > 94: private final RandomGenerator generator; > 95: private final boolean initialized; Can we create a private or package-private constructor for `Random` for this subclass' constructor to call? The no-arg constructor has some unnecessary calculations, and the `long` constructor calls `setSeed`. A special `Random` constructor for this subclass allows removing this special logic (by not calling `setSeed` at all) and avoid redundant seed initialization. ------------- PR: https://git.openjdk.java.net/jdk/pull/7001