Why is the table attribute of a hashtable serialization?

Why is the field table Hashtableserialized, although it is marked as transient?

+3
source share
3 answers

It is marked as transient because it is not safe to use the default serialization scheme in the Entry array. Rather, when the Hashtable is deserialized, the keys in the table must be overwritten, and the records must be added to the slots according to the new hash code values. This is necessary because keys can have different hash codes after deserialization ... for various reasons. This work will be done by the Hashtable method readObject().

+7
source

writeObject() readObject() ( ), , . 800 Java 1.6.

Sun, , " ".

+1

Hashtable ( , 1.6), Entry[] table transient, writeObject(), ObjectOutputStream.

, Hashtable .

? , , .

+1

Source: https://habr.com/ru/post/1738676/


All Articles