Java: When to add readObjectNoData() during serialization?

后端 未结 4 1674
广开言路
广开言路 2021-02-02 10:58

I am reading the serialization chapter in Effective Java. I am trying to understand the paragraph below, which is found in the book.

If you implemen

4条回答
  •  面向向阳花
    2021-02-02 11:01

    "Extendable" means "can have a subclass".

    readObjectNoData is used in an unusual case where the serializer (writer) is working with a version of a class with no base class, whereas the deserializer (reader) of the class has a version of the class that IS based on a subclass. The subclass can say "it's ok if my base class isn't in the serialized data - just make an empty one" by implementing readObjectNoData. See these release notes.

提交回复
热议问题