On Fri, 25 Feb 2022 22:56:36 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: > > Use var instead of ArrayList raw > > Co-authored-by: liach <7806504+li...@users.noreply.github.com> src/java.base/share/classes/java/util/Random.java line 92: > 90: */ > 91: > 92: @SuppressWarnings("serial") Is this really fine, or should a `serialVersionUID` be defined? (And maybe `initialized` should be made transient then) src/java.base/share/classes/java/util/Random.java line 93: > 91: > 92: @SuppressWarnings("serial") > 93: private static class RandomWrapper extends Random implements > RandomGenerator { Isn't ` implements RandomGenerator` redundant because `Random` already implements `RandomGenerator`? src/java.base/share/classes/java/util/Random.java line 107: > 105: return rand; > 106: > 107: return (Random) new Random.RandomWrapper(random); Isn't the `(Random)` cast redundant? src/java.base/share/classes/java/util/Random.java line 290: > 288: /** > 289: * Returns an instance of {@link Random} based on this > 290: * {@code java.util.random.RandomGenerator}. If this generator is > already an instance of Would it make sense to use a `{@link ...}` here instead? (and maybe remove the `{@link ...}` from the `@param` and the `@return`; since that might be rather uncommon for OpenJDK javadoc?) ------------- PR: https://git.openjdk.java.net/jdk/pull/7001