RFR: 8332086: Remove the usage of ServiceLoader in j.u.r.RandomGeneratorFactory

Raffaello Giulietti rgiulietti at openjdk.org
Mon May 13 09:07:11 UTC 2024


On Mon, 13 May 2024 08:47:50 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

> All random number generator algorithms are implemented in module `java.base`. The usage of `ServiceLoader` in `j.u.r.RandomGeneratorFactory` is no longer needed.

This is a followup of [18932](https://github.com/openjdk/jdk/pull/18932) in which all random number generator algorithms have been moved to module `java.base` and module `jdk.random` has been removed.

Reliance on `ServiceLoader` in `j.u.r.RandomGeneratorFactory` is no longer needed and has been replaced by a (lazily populated) map from algorithm names to classes.

Moreover, methods `RandomGeneratorFactory.create(long)` and `create(byte[])` now throw an `UnsupportedOperationException` rather than silently falling back to the no-arg `create()` in case the underlying algorithm does not support a `long` resp. `byte[]` seed.

Tests in tier1-tier3 pass after adaptations on the existing `RandomTestCoverage`.

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

PR Comment: https://git.openjdk.org/jdk/pull/19212#issuecomment-2107034744


More information about the core-libs-dev mailing list