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

Tagir F. Valeev tvaleev at openjdk.org
Sun Jan 15 07:52:53 UTC 2023


> 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 incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:

 - 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

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/10520/files
  - new: https://git.openjdk.org/jdk/pull/10520/files/127e44ca..7b4486f8

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=10520&range=03
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=10520&range=02-03

  Stats: 419299 lines in 6034 files changed: 213412 ins; 139135 del; 66752 mod
  Patch: https://git.openjdk.org/jdk/pull/10520.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/10520/head:pull/10520

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


More information about the core-libs-dev mailing list