26 - Java Serialization using transient keyword - Theory

Publicado em: 06 Dezembro 2022
no canal de: Rishi’s programming channel
261
0

‪@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


Nesta página do site você pode assistir ao vídeo on-line 26 - Java Serialization using transient keyword - Theory duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Rishi’s programming channel 06 Dezembro 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 261 vezes e gostou 0 espectadores. Boa visualização!