Java Serialization readObject input vs readExternal input

Signatures for readObject:

private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;

which accepts a reference to a particular type of class.

Signatures for readExternal:

void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

which accepts a reference to the type of interface.

So why is this a mismatch? Is it just supervision?

+5
source share
1 answer

ObjectInputStreamhas several non-in methods ObjectInputthat are used specifically to support the default serialization mechanism. Therefore, serialization must come from ObjectInputStream, but externalization can come from anyone ObjectInput.

+2
source

All Articles