Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>serialversionuid is not automatically generated because it is dangerous. When serialversionuid is set, it implies that two versions of a class are compatible with respect to serialization.</p> <p>Imagine you have a class called Foo, and it has <strong>no serialversionuid</strong> (the default), and you serialize an instance of Foo to a file. Later, you add some new members to the Foo class. If you try to deserialize the Foo object from the file, you will get a serialization failure stating that the objects are incompatible. They <em>are</em> incompatible, this is <em>what you want</em> and is the default. They are incompatible because new members in the Foo class cannot be initialized from the old serialized instance of Foo.</p> <p>Now, you might say, "I don't care, in my application it is acceptable for those fields to be uninitialized". If that <em>really</em> is the case, you can set the serialversionuid of the <em>new</em> Foo class to be the same as the <em>old</em> Foo class. This will tell Java that the objects are compatible with respect to serializablity, and Java will not complain when you deserialize the old Foo instance into the new Foo class (but the new fields will still be uninitialized).</p> <p>If you are creating a new class for the first time, and you set the serialversionuid, <strong><em>you are entering a contract</em></strong>. That contract is, <em>"For all future versions of this class with the same serialversionuid, I will guarantee they are compatible with respect to state and serialization"</em>.</p> <p>If you change a class, and you <em>explicitly</em> want to <em>disallow</em> deserialization of old versions, you can change the serialversionuid to a new value. This will cause an exception to be thrown if an old object is attempted to be deserialized into a new class instance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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