On Wed, 16 Mar 2022 14:54:41 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:
> 
>   add since in javadoc

On the `toString` issue: there's no specification requirement for this nor is 
there need to change any specification, but it might be nice to provide a 
friendly implementation. I note that `SecureRandom` does override `toString` 
and delegates to the SPI. It seems reasonable for `RandomWrapper` to say that 
it's a wrapper around some `RandomGenerator` instance. It doesn't look like any 
of the generators currently override `toString`, but the default implementation 
would show the classname which is somewhat useful. If in the future a generator 
were to provide useful information in its string, that would be passed through 
the wrapper's string. The implementation could be as simple as

    return "RandomWrapper[" + generator + "]";

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

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

Reply via email to