6

In Java it is strongly recommended that all serializable classes explicitly declare serialVersionUID since the default serialVersionUID computation is highly sensitive to class details and compiler implementation is unreliable.

What's so special about serialization in C#?

asked May 12, 2015 at 8:15
6
  • Note that, in Java, it's deliberately unreliable. Commented May 12, 2015 at 8:21
  • @Juan That's only relevant in Java context Commented May 12, 2015 at 8:22
  • Sorry, still sleepy this morning! Commented May 12, 2015 at 8:22
  • Suggest you read this question/answer: stackoverflow.com/questions/15631341/… Commented May 12, 2015 at 9:16
  • @immibis What is achieved by making it deliberately unreliable? Commented May 13, 2015 at 5:43

1 Answer 1

1

In .Net Serialization is less cranky than in Java.

By default it supports new fields just defaulting them, and it just ignore any data it doesn't expect.

You can still implement the same kind of version control by implementing the ISerializable interface in your class and adding your own custom VersionId to your class and check it there.

You can read more about this here

answered May 12, 2015 at 8:22
Sign up to request clarification or add additional context in comments.

1 Comment

Java Serialization also support addition and removal of fields. GetField.get methods even include an option to use a specific value if missing for custom deserialisation. The difference is, if you want to retain compatibility after you have changed a class, Java requires you to explicitly state the version.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.