/** * Perform special handling on serialization. */ protected Object writeReplace() throws ObjectStreamException { expungeStaleEntries(); // Extract weak references as they are not serializable. this.serialized_list = SCollection.createLinkedList(); for(int i=0; i<size; i++) { E next = array[i].get(); if(next!=null) serialized_list.add(next); } return this; }