As we all know Serialization in java is a mechanism of writing the state of an object into a byte stream.
It is mainly used to send object's state across the network. But what happens when object is not serialized and is sent across the network .
Will it give errors?
Thank you
We use Object Serialization for mainly two reasons:
1. Communication over the network
2. Lightweight persistence–the archival of an object
Before I respond to what errors you will get, let me take a dig at
Why do we need Serialization?
The main drivers for this are our network infrastructure and the hardware disks that understands bits and bytes but not JAVA objects. Serialization helps to translate graph of Java objects into an array of bytes for storage or transmission. All this happens due to the ObjectInputStream/ObjectOutputStream classes, full-fidelity metadata, and the willingness of programmers to "opt in" to this process by tagging their classes with the Serializable marker interface.
What happens if you try to send non-serialized Object over network?
When traversing a graph, an object may be encountered that does not support the Serializable interface. In this case the NotSerializableException will be thrown and will identify the class of the non-serializable object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With