In a previous article, Everything You Need to Know About Java Serialization Explained, I explained how we can serialize/deserialize one object using the Serializable
interface and explain how we can customize the serialization process using writeObject
and readObject
methods.
Disadvantages of Java Serialization Process
But these customizations are not sufficient because the JVM has full control of the serialization process and those customization logics are just additions to the default serialization process. We still have to use the default serialization logic by calling ObjectOutputStream.defaultWriteObject()
and ObjectInputStream.defaultReadObject()
from writeObject
and readObject
methods. And if we do not call these default methods, our object will not be serialized/deserialized.