当对象被序列化时,它不存储对象的静态和 transient 。那么反序列化时如何验证serialVersionUID的静态值呢?至于反序列化时的验证,对象和类都必须存储序列版本引用。 但是,对象在序列化时不存储静态和 transient 值,因此它如何验证?
最佳答案
当对象被序列化时,首先它的类的描述符被序列化(仅一次),并且该描述符包含serialVersionUID
。它不作为对象静态状态的一部分传输。
参见 newClassDesc
in the Object Serialization Specification, Object Serialization Stream Protocol chapter .
As for verification while deserialization, an object and the class, both will have to store the serial version reference
不,他们不会。我不知道这是什么意思。
关于java - 对象如何在序列化时存储静态值 serialVersionID 并在反序列化时对其进行验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50691313/