Externalizable needs a serialVersionUID too.

Yesterday I learned that even if your Java class serializes via java.io.Externalizable, so giving the class complete control over the marshaling and unmarshaling of the data, you must still defined a serialVersionUID or Java will create one for you. As methods signatures are included in the calculation of serialVersionUID my newly added method caused the creation of a different version id and so, unexpectedly, the marshaled data on the wire was incompatible. To fix the problem I just needed to define serialVersionUID to be the calculated version prior to my addition of the method. Luckily, the log contained the version number I needed!

No comments: