- Class should implement Serializable Marker Interface
- JVM is responsible for serializing the class and its super classes provided they also implement Serializable interface
- Transient and static variables are not serialized
- Performance cannot be controlled much.
- Based on recursive algorithm. Apart from fields, even the objects refereed in the class is handled for serialization recursively provided the super classes also implement Serializable interface
- Does not call constructor of the object during serialization/deserialization
- Uses Reflection for recover object.
- This causes lot of metadata information of the class to be added to the stream triggering performance and bandwidth issue.
- Reads required information about the object from ObjectInputStream and Reflection
- serialVersionUID should be generated explicitly. If not jvm will generate one using all fields, methods of the class which in turn takes not only long time but if anything in the class changes this ID will also change causing the object unable to recover .
- Object is saved using ObjectOutputStream
- Object is read using ObjectInputStream
- Class should implement Externizable – contains 2 methods
- Responsiblity of the developer to handle the serialization and deserialization using the above 2 methods
- Can control performance based on the design
- public non-org constructor is needed
- Fast and consumes less memory
- Object is saved using the logic added in writeExternal() method.
- Object is read using the logic added in readExternal() method.