...
A non-serializable or serializable class can be extended and its subclass can be made serializable or becomes so automatically. During deserialization of the subclass, the JVM calls the no-argument constructor of the most derived superclass that does not implement java.io.Serializable
either directly or indirectly. In the code snippet that immediately follows, class A
's no-argument constructor is called when C
is deserialized . Since since A
does not implement Serializable
. Subsequently, Object's
constructor is invoked. This procedure cannot be carried out programmatically, therefore the JVM generates the equivalent bytecode at runtime. Typically, when the superclass's constructor is called by a subclass, the subclass remains on the stack. However, in deserialization this does not happen. Only the unvalidated bytecode is present. This allows any security checks within the superclass's constructor to be bypassed.
...