@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
In questa pagina del sito puoi guardare il video online 26 - Java Serialization using transient keyword - Theory della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Rishi’s programming channel 06 dicembre 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 261 volte e gli è piaciuto 0 spettatori. Buona visione!