Because classes that do not implement
Serializable
could still be serialized by theObjectOutputStream
.
That is incorrect. That would throw a NotSerializableException
.
The reason writeObject()
takes an Object
instead of Serializable
is that the signature comes from implementing the interface ObjectOutput
which is defined independent of serialization. But, it then prevents ObjectOutputStream
from changing its signature.
public interface ObjectOutput {
// ...
void writeObject(Object obj);
}