To maintain version compatibility during serialization, that is, during version upgrade, deserialization still maintains the uniqueness of objects.
There are two generation methods:
One is the default 1L, for example, private static final long serialVersionUID = 1L;
One is to generate a 64-bit hash field based on the class name, Interface Name, member method, and attribute. For example:
Private static final long serialVersionUID = xxxxL;
When a class implements the Serializable interface, if serialVersionUID is not defined, Eclipse will provide this
The prompt function tells you to define it. Click the "warning" icon in the class in Eclipse, and Eclipse will
Two automatic generation methods are provided. If you do not want to define it, it is also set in Eclipse.
You can disable it as follows:
Window ==> Preferences ==> Java ==> Compiler ==> Error/Warnings ==>
Potential programming problems
Change the value of Serializable class without serialVersionUID to ignore.
If you do not consider compatibility issues, turn it off, but this function is good. If Serializable is implemented in any category, if serialVersionUID is not added, eclipse will give you a warning that this serialVersionUID is backward compatible for this type of Serializable.
If your class Serialized is stored on the hard disk, but then you change the field of the category (increase, decrease, or rename), when you Deserialize, an Exception will occur, this will cause incompatibility issues.
However, when the serialVersionUID is the same, it will Deserialize different fields with the default value of type to avoid incompatibility issues.
Author "loading"