My friend asked me if we serialize an object in java 1.5 and then deserialize it back in java 1.6 then it will throw an exception. What is that exception and why that is thrown?
But i doubt there will be any exception. Reason being nothing is changed in class definition, so it should not face any problem in rebuilding the object back from the serialized form. Am i right? If not, then what and why the exception is thrown?
Note: The class remains untouched not any field, not methods and not serialVersionUID is changed.
The serialization format has a detailed specification, which is changed only to accomodate new language features (such as enums in Java 5), and I'm pretty sure any such changes are carefully made downwards-compatible.
So unless you encounter a bug (which is certainly possible) or try to deserialize something with a Java version where some features did not exist yet, deserialization should work across different Java versions, vendors and platforms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With