RFR: 8330005: RandomGeneratorFactory.getDefault() throws exception when the runtime image only has java.base module [v4]

Hannes Greule hgreule at openjdk.org
Sat Apr 27 11:52:06 UTC 2024


On Fri, 26 Apr 2024 15:24:30 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> Move all random generators mandated in package `java.util.random` and currently implemented in module `jdk.random` to module `java.base`, and remove module `jdk.random`.
>
> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Added @uses javadoc tag for j.u.r.RandomGenerator in java.base.

Note that this also fixes a "bug" when calling `RandomGenerator.getDefault()` (or similar) from an unnamed module that does not have the application class loader as a(n indirect) parent. That previously resulted in the service loader only finding `Random`, `SecureRandom`, and `SplittableRandom`. As those are cached (https://github.com/openjdk/jdk/blob/fd84a28ba0aa82b2f48f247c3ec7e13acdcd6ff1/src/java.base/share/classes/java/util/random/RandomGeneratorFactory.java#L137), even calls from somewhere else afterwards wouldn't find the correct implementation anymore. So I'm welcoming this change.

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

PR Comment: https://git.openjdk.org/jdk/pull/18932#issuecomment-2080464407


More information about the core-libs-dev mailing list