@backstreetbrogrammer
--------------------------------------------------------------------------------
Chapter 12 - Serialization using transient keyword
--------------------------------------------------------------------------------
Suppose one of the objects in the “object graph” is not accessible (meaning we can’t modify it due to permission issues) and not marked as Serializable. In that case, are we blocked to serialize our main class which has reference to that read-only object?
One option is to subclass that read-only class, but it may be marked as final. OR, we don’t know if the read-only class object has other similar objects in its own “object graph”.
There are other private members fields (primitive and reference) of a class which contains sensitive data like passwords, or it doesn’t make sense to serialize it - like the state of an in-memory Thread.
That’s where the transient modifier comes in. By marking the members fields (primitive and reference) as transient, these fields are NOT serialized just like static fields.
What happens to data marked transient on deserialization? It reverts to its default Java values, such as 0.0D for double, false for boolean or null for an object.
Java Serialization Playlist: • Java Serialization
Java Serialization Github: https://github.com/backstreetbrogramm...
Dynamic Programming Playlist: • Dynamic Programming
Dynamic Programming Github: https://github.com/backstreetbrogramm...
#java #javadevelopers #javaprogramming #javaserialization
On this page of the site you can watch the video online 26 - Java Serialization using transient keyword - Theory with a duration of hours minute second in good quality, which was uploaded by the user Rishi’s programming channel 06 December 2022, share the link with friends and acquaintances, this video has already been watched 261 times on youtube and it was liked by 0 viewers. Enjoy your viewing!