简体   繁体   English

反序列化如何定位SerialVersionUid

[英]How deserialization locates SerialVersionUid

since the serialVersionUid is static static that does mean it is not serializable.因为 serialVersionUid 是静态static的,这意味着它不可序列化。 From what i understand when deserialization happens before the object is returned to the previous state it was in, the serialVersionUid is compared to the class one and if equal the process finishes successfully otherwise exception is thrown.据我了解,在对象返回到之前的状态之前发生反序列化时,将 serialVersionUid 与第一类进行比较,如果相等,则进程成功完成,否则抛出异常。

But how does that happen?但这是怎么发生的呢? How does serialization know which serialVersionUid to look for since it doesn't have it saved?序列化如何知道要查找哪个 serialVersionUid,因为它没有保存? Or is the serialversionuid is saved in some kind of header during the process of serialization and later is extracted from there?还是 serialversionuid 在序列化过程中保存在某种标头中,然后从那里提取?

Thanks for the help in advance!我在这里先向您的帮助表示感谢!

serialVersionUID is a special (final) static variable and it is used by during serialization (unlike standard static fields which are not serialized). serialVersionUID 是一个特殊的(最终)静态变量,它在序列化期间使用(与未序列化的标准静态字段不同)。

Here is a good explanation: https://howtodoinjava.com/java/serialization/serialversionuid/这里有一个很好的解释: https ://howtodoinjava.com/java/serialization/serialversionuid/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM