开发者

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 开发者_C百科& serialized object have same serialVersionUID?

I'm looking scenarios like following

1) If a data type of an instance variable is changed then deserialization will fail

Could you please provide all such scenarios. I couldn't find such scenarios list anywhere in the internet.

Thanks


The changes that will make deserialization fail are listed in the Java Object Serialization Specification, Section 5.6.1.


The Exceptions thrown from readObject() give a first impression of what could happen.

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

  • ClassNotFoundException - Class of a serialized object cannot be found.
  • InvalidClassException - Something is wrong with a class used by serialization.
  • StreamCorruptedException - Control information in the stream is inconsistent.
  • OptionalDataException - Primitive data was found in the stream instead of objects.
  • IOException - Any of the usual Input/Output related exceptions.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜