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

Stuart Marks smarks at openjdk.org
Wed Jan 18 18:17:16 UTC 2023


On Sun, 15 Jan 2023 07:52:53 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 with a new target base due to a merge or a rebase. The pull request now contains four commits:
> 
>  - Copyright year and @since tag updated
>  - 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.
>  - Remove Random -> ThreadLocalRandom change
>  - 8294693: Add Collections.shuffle overload that accepts RandomGenerator interface

Marked as reviewed by smarks (Reviewer).

Thanks for updates. I've tweaked the CSR a bit and I've marked it reviewed; please go ahead and move it to Finalized.

(On rebase vs. merge, merge is definitely preferable. Merges preserve PR history more faithfully. Merge commits as well as intermediate commits all get squashed when the PR is integrated, so the result is a single commit in the mainline repo. Rebasing isn't a big deal with a small change like this, but rebasing would probably confuse things if this PR were more complicated or if it had a lot of comments on different versions.)

Marking this Approved so it can be integrated after the CSR completes.

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

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


More information about the core-libs-dev mailing list