ABO:
チェック時java.util.ArrayList内の実装通知を側における要素データオブジェクト配列のArrayListであることが、過渡のArrayListが直列であっても。
transient Object[] elementData; // non-private to simplify nested class access
それでは、どのようArrayListのは、そのデータを保存しないデシリアライズからelementDataアレイ保つことによってプロセスを過渡的に?
dasblinkenlight:
メンバーをマークするとtransient
、フィールドは、それがシリアライズされていないだけで、シリアライズ取得されていないという意味ではありません自動的にフィールドのJavaの組み込みのシリアル化メカニズムを使用して。
以下の場合にArrayList
直列化カスタムによって実行されるwriteObject
:方法[SRC]
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException {
// Write out element count, and any hidden stuff
int expectedModCount = modCount;
s.defaultWriteObject();
// Write out size as capacity for behavioural compatibility with clone()
s.writeInt(size);
// Write out all elements in the proper order.
for (int i=0; i<size; i++) {
s.writeObject(elementData[i]);
}
if (modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
}
デシリアライズを使用して行われますreadObject
。