The signature for readObject is:
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
which takes in a reference of a concrete class type.
The signature for readExternal is:
void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
which takes in a reference of an interface type.
So why this discrepency? Is it just an oversight?
ObjectInputStreamhas several methods not inObjectInputthat are used specifically to support the default serialization mechanism. Therefore, serialization needs to come from anObjectInputStream, but externalization can come from anyObjectInput.