On Wed, Jan 16, 2013 at 7:01 AM, Chris Hegarty <chris.hega...@oracle.com>wrote:
> Thanks to all for the reviews and suggestions here. As you probably seen, > I pushed these changes to jdk8/tl earlier today (sorry, I missed Alan as an > official reviewer on the changeset.). Consider it an initial version, > pending any outcome from this, or other, discussions. > > Also, 8006409: "ThreadLocalRandom should dropping padding fields from its > serialized form", has been filed to follow up on the changes required to > update the serial form. > > For those watching, I was preferable to push on with these changes ( and I > apologize if it appeared pushy ), as the Double/Long Adder/Accumulator > implementation, Striped64, now has a dependency on this change. It has > become unbearable to keep in sync with different version of across > different repositories. Taking a look at this, I don't see any reason why we can't simply do (while maintaining serialization compatibility): diff --git a/src/share/classes/java/util/concurrent/ThreadLocalRandom.java b/src/share/classes/java/util/concurrent/ThreadLocalRandom.java --- a/src/share/classes/java/util/concurrent/ThreadLocalRandom.java +++ b/src/share/classes/java/util/concurrent/ThreadLocalRandom.java @@ -368,50 +368,6 @@ private static final long serialVersionUID = -5851777807851030925L; /** - * @serialField rnd long - * @serialField initialized boolean - * @serialField pad0 long - * @serialField pad1 long - * @serialField pad2 long - * @serialField pad3 long - * @serialField pad4 long - * @serialField pad5 long - * @serialField pad6 long - * @serialField pad7 long - */ - private static final ObjectStreamField[] serialPersistentFields = { - new ObjectStreamField("rnd", long.class), - new ObjectStreamField("initialized", boolean.class), - new ObjectStreamField("pad0", long.class), - new ObjectStreamField("pad1", long.class), - new ObjectStreamField("pad2", long.class), - new ObjectStreamField("pad3", long.class), - new ObjectStreamField("pad4", long.class), - new ObjectStreamField("pad5", long.class), - new ObjectStreamField("pad6", long.class), - new ObjectStreamField("pad7", long.class) }; - - /** - * Saves the {@code ThreadLocalRandom} to a stream (that is, serializes it). - */ - private void writeObject(java.io.ObjectOutputStream out) - throws java.io.IOException { - - java.io.ObjectOutputStream.PutField fields = out.putFields(); - fields.put("rnd", 0L); - fields.put("initialized", true); - fields.put("pad0", 0L); - fields.put("pad1", 0L); - fields.put("pad2", 0L); - fields.put("pad3", 0L); - fields.put("pad4", 0L); - fields.put("pad5", 0L); - fields.put("pad6", 0L); - fields.put("pad7", 0L); - out.writeFields(); - } - - /** * Returns the {@link #current() current} thread's {@code ThreadLocalRandom}. */ private Object readResolve() {