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

ExE Boss duke at openjdk.org
Tue May 14 15:44:04 UTC 2024


On Tue, 14 May 2024 13:47:33 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.
>
> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Move mathematical logic to record RandomGeneratorProperties.

src/java.base/share/classes/java/util/random/RandomGeneratorFactory.java line 202:

> 200:                 int i, int j, int k, int equidistribution,
> 201:                 int flags) {
> 202:             return new SimpleImmutableEntry<>(name,

This should use [`Map​.Entry​<…>`] as the return type, which in turn allows using [`Map​::entry​(K, V)`] as the implementation, as neither the `name` key, nor the value is ever `null`:
Suggestion:

        private static Map.Entry<String, RandomGeneratorProperties>
        entry(Class<? extends RandomGenerator> rgClass, String name, String group,
                int i, int j, int k, int equidistribution,
                int flags) {
            return Map.entry(name,


[`Map​.Entry​<…>`]: https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/Map.Entry.html
[`Map​::entry​(K, V)`]: https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/Map.html#entry(K,V)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19212#discussion_r1600264879


More information about the core-libs-dev mailing list