On 5 May 2016, at 01:21, Stuart Marks <stuart.ma...@oracle.com> wrote:
> Hi Daniel, > > On 5/4/16 3:08 AM, Daniel Fuchs wrote: >> I wonder about serial interoperability with earlier >> versions of the JDK. For instance it will not be possible to >> send a Set created with Set.of(...) in JDK 9 to a JDK 8 VM. >> I wonder if there is any good solution to that. >> You could of course use writeReplace() to return a plain >> HashSet - but then you would only get a plain HashSet on >> the other end. That might be fine if that other end >> is JDK 8, but maybe not so good if it's actually JDK 9. > > Right, in general, you can't serialize a "new" class in a JDK release and > deserialize it on an older JDK. If backward serialization compatibility were > a goal, one could serialize them as a HashSet within an unmodifiable wrapper. > But yes, deserializing that would increase the space consumption considerably. I have some sympathy for this. Since we are specifying that these Collections are serializable, it would be nice for them to deserialize on an older release, but I don’t think we should compromise the serial form to achieve that. In fact, I agree with Stephen, I think we should go the same way as that of the serial form of 310 classes. So is there anything we can do for serial interoperability? What if, we agree the serial form and the private supporting implementation types in 9 ( say, some time this month ). Backport these to, at least, 8u, where they do not impact spec and are benign. JDK 9 is not scheduled to ship until March 2017, with the regular Critical Patch Updates that most vendors provide, I’d bet that a large number of 8u’s in production at that time would contain the required types to deserialize these collections. There’s no guarantee of course, but in practical terms at least we made a reasonable effort. -Chris.