Remove the warning caused by serialversionuid

Source: Internet
Author: User

This warning is often reported in eclipse 3.1 +.

Remove these warnings and make the following settings:
Window-preferences-Java, set the serializable class without serialversionuid from warning to ignore. Then eclipse will re-compileProgramAnd the warning information will disappear.

Serialversionuid is used to indicate the compatibility between different versions of the class. If you modify this class, you need to modify this value. Otherwise, errors will occur when the class serialized in the old version is restored.
You can use the serialver.exe tool in the bincatalog of JDK to generate the serialversionuid.
For test. Class, run the command: serialver Test
To ensure the compatibility of the class version during deserialization, it is best to add the Private Static final long serialversionuid attribute to each class to be serialized. The specific values are defined by yourself. In this way, even if a class is modified after the corresponding object has been serialized, the object can still be correctly deserialized. Otherwise, if this attribute is not displayed, the JVM calculates the attribute value based on the class information. The calculation result of the modified class is often different from that of the modified class, this causes object deserialization to fail because the class version is incompatible.
Another disadvantage of not displaying the definition of this property value is that it is not conducive to program porting between different JVMs. Because different compilers may implement different calculation policies for this attribute value, although the class is not changed, the JVM is different, there is still a problem that the class version is incompatible and cannot be correctly deserialized.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.