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

Jaikiran Pai jpai at openjdk.org
Mon May 13 13:34:03 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.

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

> 185:      private RandomGeneratorProperties getProperties() {
> 186:         if (properties == null) {  // volatile load
> 187:             synchronized (rgClass) {

The synchronization on `rgClass` to intialize an instance field `properties` appears odd here. I think this should be synchronized on `this`.

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

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


More information about the core-libs-dev mailing list