How to determine the correct serial version identifier?

How to determine the correct serial version identifier? Should some large long value use some generators or any wld integer?

+5
source share
5 answers

Frankly, while serialVersionUIDit is different between the different versions of your class, all that matters.

Which would be bad if there are two versions of the same class with different serializable fields with the same serialVersionUID- which are likely to cause a problem when doing serialization.

, (, ), serialVersionUID .

IDE, Eclipse, , Serializable , .

API Java Serialization, . " ", serialVersionUID.

+5

:

  • version - , ;
  • timestamp - - . 200906121213, .
+2

serialver Sun Java Development Kit (JDK). "-show" .

, Foo,

serialver Foo

- :

Foo: serialVersionUID = -6618469841127325812L;

, "static", . .

+1

:

cd\

[serialver] [] -classpath [] [ ] [] [ ]

.

serialver -classpath C:\Users\nileshjadav\Documents\java\file_io ByteStreamDemo

, , ByteStreamDemo.java ByteStreamDemo.class, ByteStreamDemo

+1

, , serialVersionUID java serialver.

  • JDK bin . , "serialver", ".

  • Add the class path where your class file is located, or go to the directory where your class file is located.

  • run serialver .. This will give you a SerialID.

  • Listing the class name in this utility does not include the .class extension.

-1
source

All Articles