On 11/17/20 9:08 PM, Stuart Marks wrote:
@plevart wrote:
Yes, but that is JDK16+ vs. JDK15- and not App V1 vs. App V2 thing. If both 
apps run on JDK16+, there will be no exception.
Sure, the IMM_LIST_NULLS tag only helps with serialization compatibility across 
JDK releases.


I would say it goes the other way - it worsens the serialization compatibility. You are introducing a serialization format that is incompatible with older JDK releases. OTOH the problem of introducing nulls into List(s) in serializable data structures already exists because serializable List implementations that allow nulls already exist, so by introducing another one that is able to be deserialized on older JDK would not worsen the situation.


  There are lots of ways an app can make incompatible changes to the serialized 
forms of its objects that we have no way of detecting.


So why bother with making the result of serialized stream.toList() not de-serializable on older JDK(s)? By making a favor to a hypothetical app that runs on older JDK and does not expect nulls in Lists of a data structure, you are also preventing an app that allows nulls in similar data structure from deserializing the datastructure on older JDK when the serialized form was produced with serializing stream.toList() on newer JDK.

But I see that the new  IMM_LIST_NULLS type is needed for one other thing - the immutable list implementation of that type has different behavior of indexOf and lastIndexOf methods (it doesn't throw NPE when null is passed to those methods) so this behavior has to be preserved in the deserialized instance and there is not way to achieve that on old JDK with existing serialization format, so there has to be an incompatible change in the serialization format for that matter.

Peter


Reply via email to