Potentially yes, you are right.
In fact, this happened to us some time ago with some swing classes (I really donโt remember what exactly), but it is serialized on jdkX and de-serailizng them on jdkX+1 (it was a very long time ago, sorry for the lack of these details) things started to burst with an InvalidClassException . At that time, we paid support and discovered the problem - the answer was, well, that these classes changed in such a way that it would be impossible to deserialize them correctly - you are stuck with this version or jdk+1 to jdk+1 and use this. Since then, this has not happened to me, not even once.
All in all, I think that makes serialization too complicated. You must support this process so that changes in future versions can be relevant and compatible with previous ones in terms of serialization.
HashMap , on the other hand, has a very smart way to serialize data. It serializes (by the way, likes load_factor , etc.). Only its keys and values โโare nothing more. Therefore, regardless of whether the implementation is changed, it will be possible to de-serialize. For this reason, some of the fields that are not needed are marked as transient, for example:
transient int modCount; transient Set<Map.Entry<K,V>> entrySet;
The idea is that it should serialize the data compared to the structure.
If the HashMap changes in such a way that Serialization will break into jdk-11 , for example, it will make many developers pissed off, I doubt it will ever be traversed (if it is really necessary)
Eugene
source share