RFR: 8294693: Add Collections.shuffle overload that accepts RandomGenerator interface [v3]

Stuart Marks smarks at openjdk.org
Wed Jan 4 21:06:50 UTC 2023


On Wed, 12 Oct 2022 13:26:29 GMT, Tagir F. Valeev <tvaleev at 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:
> 
>   Fixes according to review
>   
>   1. Reduce duplication in tests
>   2. Use JumpableGenerator#copy() instead of create(1) in tests, as according to the spec, seed can be ignored
>   3. Simplify documentation for shuffle(List, Random) to avoid duplication.

Sorry, this got derailed by the discussion of `SequencedCollection::replaceAll`. I think we should just set that issue aside. I don't think `SequencedCollection::replaceAll` makes sense, thus this PR shouldn't be held up on its account.

The change is fine in concept. A couple adjustments needs to be made: javadoc since-tags need to be updated to 21, and copyrights updated to 2023. (Well, maybe an argument could be made that they should stay at 2022. I don't particularly care.) Also, the CSR should be updated to reflect the changes to the specifications. Other than those items, this should be fine to move forward.

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

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


More information about the core-libs-dev mailing list