5

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?

1 Answer 1

2

ObjectInputStream has several methods not in ObjectInput that are used specifically to support the default serialization mechanism. Therefore, serialization needs to come from an ObjectInputStream, but externalization can come from any ObjectInput.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.