Java 17 introduces a revamped random number generation API via JEP 356, addressing longstanding issues with the fragmented and inconsistent pre-existing classes (Random, SecureRandom, ThreadLocalRandom, SplittableRandom). The new design centers on the RandomGenerator interface and a hierarchy of sub-interfaces (StreamableGenerator, JumpableGenerator, LeapableGenerator, ArbitrarilyJumpableGenerator, SplittableGenerator) that clearly express algorithm capabilities. All four existing classes were refactored to implement these interfaces while remaining backwards compatible. Algorithm selection can be done by name using static of() methods or, more robustly, by querying RandomGeneratorFactory.all() and filtering by properties like state bits, jumpability, or hardware usage. Third parties can also plug in custom implementations via the service provider mechanism and the @RandomGeneratorProperties annotation.
Table of contents
▚ The New Type Hierarchy Around RandomGenerator▚ Algorithm Selection▚ Adding Algorithms▚ ReflectionSort: