RFR (S): CR 8005926: (thread) Merge ThreadLocalRandom state into java.lang.Thread
Aleksey Shipilev
aleksey.shipilev at oracle.com
Tue Jan 15 09:57:32 UTC 2013
On 01/15/2013 01:40 PM, Peter Levart wrote:
> If this is an API change, then it might as well be a change in the
> serializability of the ThreadLocalRandom instance. Since TLR extends
> Random which is already Serializable, this could be done by throwing
> appropriate exception in writeObject().
>
> I don't think anyone would really notice.
>
> Serializability of a java.util.Random is meant to transfer the state of
> the object over the wire (including current seed). This can't be done
> for ThreadLocalRandom since it's a singleton with thread-bound state. So
> serializability of TLR is dubious.
That's an interesting thought indeed. However, I would say already
receiving TLR from the stream and throwing the "don't want it" exception
would be surprising. We are at the curse of having these fields exposed
in serialized form; the only thing we can do is to minimize further leakage.
Chris, do you need help preparing the patch?
-Aleksey.
More information about the core-libs-dev
mailing list