You may need custom serialization in java in may cases. For example, you have legacy java classes which you are not willing to modify for any reason. There can be some design constraints as well. Or even simply, the class is expected to be changed in future releases which could break the deserialization of previously […]
XMLEncoder class is used to serialize or encode a java object into XML file, while XMLDecoder is used to deserialize the xml file back to java object. Learn to use them in detail.
Knowing the difference between Externalizable vs Serializable is important in two aspects, one – if could be asked as an interview question, two – you can use the knowledge to make better informed decision for performance improvement for applying serialization into your application.
You can achieve more efficient serialization by implementing Externalizable interface and overriding it’s methods writeExternal() and readExternal().
In one of my previous post related to “Implementing Serializable interface in java“, Mr. Bitoo asked a good question “at the time of the deserializtion, how the JVM creates the object without calling the constructor??“. I thought of replying him in same post in a comment, but in another moment I thought of this a […]
The transient keyword in java is used on class attributes/variables to indicate that serialization process of such class should ignore such variables while creating a persistent byte stream for any instance of that class. A transient variable is a variable that can not be serialized. According to Java Language Specification [jls-220.127.116.11]: “Variables may be marked […]
In java, serialization is the process of turning an object-in-memory into a stream of bytes so you can do stuff like store it on disk or send it over the network. De-serialization is the reverse process: turning a stream of bytes into an object in memory. In my earlier post about “implementing serializable interface in […]
We all know that easiest way of deep cloning (with some performance overhead) is Serialization. It involves serializing the object to bytes and from bytes to object again. I will suggest you to use in memory deep cloning whenever it is the only need and you don’t need to persist the object for future use. […]
We all know what Serializable interface guarantees i.e. ability to serialize the classes. This interface recommends you to use serialVersioUID also. Now, even if you use both in your classes, do know what can break your design even now?? Lets identify the future changes in your class which will be compatible and others which will […]