Look at the implementation of readObject and writeObject of hashMap. Even though data members are transient, it is reading/writing out all the data members that carry the relevant data. They are not really transient
That is exactly my point. If they are not transient, why to use the keyword.
The reason why they did this is the entry table of the HashMap is sparse, so they made the table transient and overrode the read/Write method to put the data in a non-sparse manner.
What do you meant by sparse table here? and how would it become non-sparse by making them transient. I mean, what relation does transient have with being sparse or not sparse.
Also, as I questioned earlier, I see the readObject and writeObjects as private. So how are these methods actually being called. I mean I don't see any reference elsewhere in these classes. or Am I missing anything here ?