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

Tagir F. Valeev tvaleev at openjdk.org
Sat Oct 8 15:35:14 UTC 2022


On Mon, 3 Oct 2022 21:46:09 GMT, Stuart Marks <smarks 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).
>
> See my comments in [JDK-8218282](https://bugs.openjdk.org/browse/JDK-8218282). While updating the one-arg Collections::shuffle to use ThreadLocalRandom seems obvious, it's not clear to me that we actually want to do that.

@stuart-marks thank you for the information. As this part is controversial, and there's a separate issue for it, I'll remove it from my PR and edit the description, so it could be addressed separately.

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

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


More information about the core-libs-dev mailing list