Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you're using Eclipse as your IDE, you can right-click on the warning about the missing serialVersionUID and you'll get two options:</p> <p>1) Define the Eclipse default, which has the value 1L; or<br> 2) Define a randomly generated long value</p> <p>If you care about versioning of serialized objects, you'll need to manually regenerate a new value each time you modify the class. The Javadoc for the Serializable interface has this to say about what happens if you don't declare a serialVersionUID at all:</p> <blockquote> <p>If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value.</p> </blockquote> <p>In practice, I've found that even if you start with identical source code on two or more machines (checked out of Subversion, for example) where serialVersionUID was undefined in a class, the compiler-generated value in the class is different on each machine when the code is compiled. This can cause confusing errors during development.</p> <p>If you are sure that you'll never have a situation where you have stale serialized objects that are out-of-sync with a newer version of the class (or two JVMs sending out-of-sync serialized objects to each other, perhaps across a network or socket connection) then just set a value of 1L for serialVersionUID and leave it that way forever.</p> <p><a href="http://download-llnw.oracle.com/javase/6/docs/api/java/io/Serializable.html" rel="nofollow noreferrer">http://download-llnw.oracle.com/javase/6/docs/api/java/io/Serializable.html</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload