Java serialization: readObject() vs. readResolve()

前端 未结 10 970
花落未央
花落未央 2020-12-02 04:07

The book Effective Java and other sources provide a pretty good explanation on how and when to use the readObject() method when working with serializable Java class

10条回答
  •  醉酒成梦
    2020-12-02 04:45

    readResolve can be used to change the data that is serialized through readObject method. For e.g. xstream API uses this feature to initialize some attributes that were not in the XML to be deserialized.

    http://x-stream.github.io/faq.html#Serialization

提交回复
热议问题