On Sat, 8 Oct 2022 15:35:14 GMT, Tagir F. Valeev <tval...@openjdk.org> wrote:

>> Java 17 added RandomGenerator interface. However, existing method 
>> Collections.shuffle accepts old java.util.Random class. While since Java 19, 
>> it's possible to use Random.from(RandomGenerator) wrapper, it would be more 
>> convenient to provide direct overload shuffle(List<?> list, RandomGenerator 
>> rnd).
>
> Tagir F. Valeev has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Remove Random -> ThreadLocalRandom change

src/java.base/share/classes/java/util/Collections.java line 485:

> 483:      *         list-iterator does not support the {@code set} operation.
> 484:      * @since 20
> 485:      */

It looks like this comment was copied from `shuffle(List, Random)` and 
`shuffle(List)` which is fine. But since this method is now preferred over the 
others, maybe we can reduce the duplication and have those other methods simply 
be defined in terms of this one. We'd have to come up with the right "weasel 
words" to describe the source of randomness used by `shuffle(List)`. In 
addition, if you don't want to deprecate the other methods, perhaps some 
wording can be found that clearly indicates this new method is now the 
preferred one.

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

PR: https://git.openjdk.org/jdk/pull/10520

Reply via email to