Class Serialization

Posted by Martin Homik | Posted in Java | Posted on 26-03-2008

0

In the past two weeks or so I have been fighting with different IDEs such as Netbeans, Eclipse, and IntelliJ. Though Eclipse is highly customizable, it can give you a very hard time. In particular when you have a J2EE package and validation is turned on. Then you get hundreds of errors and warnings. Lucky me, I was able to change the settings for my webapp project and to ignore many of the issues.

However, I came across a serialVersionUID warning which has been annoying several times before. In principle, you have to set a public, static, and final field of type Long for each class that implements the Serializable interface. I never knew how to come up with a suitable value, but a strength of Eclipse is to provide QuickFixes for many issues. In my case, I just pressed the almighty Ctrl+1 combination which offered to add a serialVersionUID field including a pre-calculated Long value. Cool.

By the way, a good online resource is here.

Write a comment