简体   繁体   English

请提供在类和序列化对象具有相同的serialVersionUID的反序列化过程中失败的方案/条件?

[英]Please provide scenarios/conditions those fail during deserialization when a class & serialized object have same serialVersionUID?

Please provide scenarios/conditions those fail during deserialization when a class & serialized object have same serialVersionUID ? 请提供在类和序列化对象具有相同的serialVersionUID反序列化过程中失败的方案/条件?

I'm looking scenarios like following 我正在寻找以下情况

1) If a data type of an instance variable is changed then deserialization will fail 1)如果实例变量的数据类型更改,则反序列化将失败

Could you please provide all such scenarios. 您能提供所有这样的方案吗? I couldn't find such scenarios list anywhere in the internet. 我在互联网的任何地方都找不到这样的场景列表。

Thanks 谢谢

Java对象序列化规范第5.6.1节中列出了将使反序列化失败的更改。

The Exceptions thrown from readObject() give a first impression of what could happen. 从readObject()抛出的异常给人以第一印象。

http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectInputStream.html#readObject() http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectInputStream.html#readObject()

  • ClassNotFoundException - Class of a serialized object cannot be found. ClassNotFoundException-找不到序列化对象的类。
  • InvalidClassException - Something is wrong with a class used by serialization. InvalidClassException-序列化使用的类出了点问题。
  • StreamCorruptedException - Control information in the stream is inconsistent. StreamCorruptedException-流中的控件信息不一致。
  • OptionalDataException - Primitive data was found in the stream instead of objects. OptionalDataException-在流中找到原始数据,而不是对象。
  • IOException - Any of the usual Input/Output related exceptions. IOException-任何与输入/输出相关的常规异常。

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

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