1

I have remote system with java8 that interacts with another system (hopefully java17) by sending and receiving serialized java dto via network. Every java class have it's own serialVersionUID, but I am uncertain if there will be errors when newer jvm will try to deserialize object that was serialized by significantly older jvm. Or it should be backward compatible?

Clarifying, it's binary serialization done by implementing java.io.Serializable interface.

5
  • Assuming you're serializing to JSON, XML or any other String based format, you would be fine since serialVersionUID is not a concern in those cases. If you're using Socket API and using ObjectStrems, that would be an issue. Commented Feb 17, 2022 at 8:58
  • I'm not doing [de]serialization directly self, it's done by implementing java.io.Serializable interface and leting underlaying jvm to do that work (to binary data and send it over network). Commented Feb 17, 2022 at 9:05
  • @Kayaman, it clearly stated that JEP 353 (openjdk.java.net/jeps/353) of Java 13 has specific set of Risks and Assumptions and third point specify possible incompatibility between EOF (End of File) value. This could be mitigated by careful handling of EOF. But the program might should have two versions for both JVMs. Commented Feb 17, 2022 at 9:53
  • @Kayaman, yeah but OP wants to send those serialized objects between two JVMs of two different versions (Java 8 and Java 17 no less). How do you think he's going to achieve that? Commented Feb 17, 2022 at 10:08
  • 2
    @SachithDickwella You can bet that whatever ill-advised things they may do to sockets they won't break object serialization. Otherwise all hell would break loose. Commented Feb 17, 2022 at 23:03

1 Answer 1

3

The Java version doesn't affect anything. If the classes being serialized don't have incompatible changes between the two systems (in the best case they are the same class, but serialization allows for some changes to happen too), then you don't have any compatibility issues.

Only if one party has a different class version and they aren't compatible you need to perform manual work (like implement Externalizable). Otherwise serialization is backwards compatible, although there are other reasons why it might not be a good reason to use it (such as it being very Java specific).

Sign up to request clarification or add additional context in comments.

2 Comments

You only answer half of the question here. What would happen when the serialized object send over the network between Java 8 and Java 17 as in the OP?
@SachithDickwella That is answered in the first sentence.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.