RFR: 8332086: Remove the usage of ServiceLoader in j.u.r.RandomGeneratorFactory
Jaikiran Pai
jpai at openjdk.org
Mon May 13 14:11:06 UTC 2024
On Mon, 13 May 2024 13:54:18 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
> Then I would even remove the double-checking idiom, the volatile on ctor and properties, and declare methods getProperties() and ensureConstructors() as synchronized.
> I'm not sure that the double-checking optimization brings much value on contemporary JVMs.
Making the methods synchronized would bring in a penalty that there will always be a monitor entry at every call site, even after the `properites` and `ctor`(s) are initialized. Ideally, we should just do all of this intialization in the constructor of the `RandomGeneratorFactory`, the one which takes the `Class<>` type of the `RandomGenerator`. We can then make the `properties` and the `ctor`(s) all `final` and not have to worry about any synchronization or volatile semantics. You would of course have to rework the ensureConstructors to not throw an exception at that time.
> But I feel that the followup PR discussed before wouldn't need synchronized at all.
Correct. The more I think about it, I think cleaning up all this in this PR itself might make both reviewing and the implementation a bit more simpler. What's your thoughts?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19212#discussion_r1598540564
More information about the core-libs-dev
mailing list