Search code examples
javaserializationarraylisttransient

java serialize transient elements


am preparing myselg for some java t and I see something interesting in the java code:

in the ArrayList class I can see this :

  /**
     * The array buffer into which the elements of the ArrayList are stored.
     * The capacity of the ArrayList is the length of this array buffer.
     */
    private transient Object[] elementData;

so how is the list serializable is the array holding the data is tdefined as transient:?

Do they use some trick we can not see like bridge methods, fields or similar..

Thnxs


Solution

  • ArrayList uses readObject() and writeObject() for serialization.