上面打错了一个地方
在第54条里有
如果一个专门为了继承而设计的类不是可序列化的,那么要编写出可系列化的子类几乎是不可能的。特别地,如果超类没有提供一个可访问的、无参数的构造函数的话,那么子类要做到可系列化是不可能的。
If a class that is designed for inheritance is not serializable, it may be impossible to write a serializable subclass. Specifically, it will be impossible if the superclass does not provide an accessible parameterless constructor.为什么?

解决方案 »

  1.   

    在jdk的文档里找到这样的话
    To allow subtypes of non-serializable classes to be serialized, the subtype may assume responsibility for saving and restoring the state of the supertype's public, protected, and (if accessible) package fields. The subtype may assume this responsibility only if the class it extends has an accessible no-arg constructor to initialize the class's state. It is an error to declare a class Serializable if this is not the case. The error will be detected at runtime. During deserialization, the fields of non-serializable classes will be initialized using the public or protected no-arg constructor of the class. A no-arg constructor must be accessible to the subclass that is serializable. The fields of serializable subclasses will be restored from the stream. 有几个问题
    1.The subtype may assume this responsibility only if the class it extends has an accessible no-arg constructor to initialize the class's state.为什么?运行时错误是怎么产生的?
    2.During deserialization, the fields of non-serializable classes will be initialized using the public or protected no-arg constructor of the class.难道子类继承了超类的域以后,不能自己控制该域是否可以序列化,而要看超类有没有提供可访问的无参数构造函数?有点不明白