All classes in jdk.internal.random are not serializable
Remi Forax
forax at univ-mlv.fr
Thu Jan 30 23:17:08 UTC 2025
> From: "Glavo" <zjx001202 at gmail.com>
> To: "core-libs-dev" <core-libs-dev at openjdk.org>
> Sent: Thursday, January 30, 2025 4:22:00 PM
> Subject: All classes in jdk.internal.random are not serializable
> Hi,
> My friend was migrating from Random to RandomGenerator, but he ran into a
> roadblock:
> Random is serializable, but those new implementations of RandomGenerator are not
> serializable.
> Was this an oversight or an evaluated decision?
> Is it possible to make them serializable?
For me, this is not an overlook and given that the interface RandomGenerator is open (anybody can implement it),
this does not seem possible.
If you read the doc of Random.from(), this is clear that a RandomGenerator is not serializable by design
[ https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/util/Random.html#from(java.util.random.RandomGenerator) | https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/util/Random.html#from(java.util.random.RandomGenerator) ]
> Glavo
regards,
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250131/ee21a78d/attachment-0001.htm>
More information about the core-libs-dev
mailing list