The serialversionUID field holds a unique number that identifies the class' current development. The idea is to maintain a field that can be used to check where a serialized object is based on the same class that the current VM has loaded. It's not a required field, but it can be very helpful. It's only usable for classes that implement Serializable. ------------------ Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
Suren, The serialVersionUID allows you to explicitly specify the value of something called a stream unique identifier (SUID) that's normally calculated by Java's serialization mechanism. You're never required to define the serialVersionUID field, but you may find it useful sometimes. The SUID value (either one you explicitly define or one that's calculated at run time) of a class is included with the stream of bytes that's written when you serialize / marshall an instance of that class. Then, when that byte stream is being deserialized / unmarshalled, the SUID value in the byte stream is compared with the one for the local class definition to make sure that the two are identical and therefore, compatible. I can't provide you with more information on how and when to use serialVersionUID without writing a very long response. However, if I haven't fully answered your questions (or even if I have ), I'd encourage you to consider picking up a copy of my book. It includes a chapter on data persistence where I discuss serialization in general and SUIDs in particular in much greater detail. ------------------ Brett Spell Author, Professional Java Programming
since GenericServlet implements Serializable and most people agree that it is a good practice to declare serialVersionUID for classes that implements Serializable, would it also be a good practice to hardcode serialVersionUID in a servlet?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop