diff -r ee8a922f4268 -r d0f57d3ea898 emul/compact/src/main/java/java/util/Hashtable.java --- a/emul/compact/src/main/java/java/util/Hashtable.java Mon Jan 28 13:28:02 2013 +0100 +++ b/emul/compact/src/main/java/java/util/Hashtable.java Mon Jan 28 13:52:28 2013 +0100 @@ -836,116 +836,6 @@ } /** - * Save the state of the Hashtable to a stream (i.e., serialize it). - * - * @serialData The capacity of the Hashtable (the length of the - * bucket array) is emitted (int), followed by the - * size of the Hashtable (the number of key-value - * mappings), followed by the key (Object) and value (Object) - * for each key-value mapping represented by the Hashtable - * The key-value mappings are emitted in no particular order. - */ - private void writeObject(java.io.ObjectOutputStream s) - throws IOException { - Entry entryStack = null; - - synchronized (this) { - // Write out the length, threshold, loadfactor - s.defaultWriteObject(); - - // Write out length, count of elements - s.writeInt(table.length); - s.writeInt(count); - - // Stack copies of the entries in the table - for (int index = 0; index < table.length; index++) { - Entry entry = table[index]; - - while (entry != null) { - entryStack = - new Entry<>(0, entry.key, entry.value, entryStack); - entry = entry.next; - } - } - } - - // Write out the key/value objects from the stacked entries - while (entryStack != null) { - s.writeObject(entryStack.key); - s.writeObject(entryStack.value); - entryStack = entryStack.next; - } - } - - /** - * Reconstitute the Hashtable from a stream (i.e., deserialize it). - */ - private void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException - { - // Read in the length, threshold, and loadfactor - s.defaultReadObject(); - - // Read the original length of the array and number of elements - int origlength = s.readInt(); - int elements = s.readInt(); - - // Compute new size with a bit of room 5% to grow but - // no larger than the original size. Make the length - // odd if it's large enough, this helps distribute the entries. - // Guard against the length ending up zero, that's not valid. - int length = (int)(elements * loadFactor) + (elements / 20) + 3; - if (length > elements && (length & 1) == 0) - length--; - if (origlength > 0 && length > origlength) - length = origlength; - - Entry[] table = new Entry[length]; - count = 0; - - // Read the number of elements and then all the key/value objects - for (; elements > 0; elements--) { - K key = (K)s.readObject(); - V value = (V)s.readObject(); - // synch could be eliminated for performance - reconstitutionPut(table, key, value); - } - this.table = table; - } - - /** - * The put method used by readObject. This is provided because put - * is overridable and should not be called in readObject since the - * subclass will not yet be initialized. - * - *

This differs from the regular put method in several ways. No - * checking for rehashing is necessary since the number of elements - * initially in the table is known. The modCount is not incremented - * because we are creating a new instance. Also, no return value - * is needed. - */ - private void reconstitutionPut(Entry[] tab, K key, V value) - throws StreamCorruptedException - { - if (value == null) { - throw new java.io.StreamCorruptedException(); - } - // Makes sure the key is not already in the hashtable. - // This should not happen in deserialized version. - int hash = key.hashCode(); - int index = (hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[index] ; e != null ; e = e.next) { - if ((e.hash == hash) && e.key.equals(key)) { - throw new java.io.StreamCorruptedException(); - } - } - // Creates the new entry. - Entry e = tab[index]; - tab[index] = new Entry<>(hash, key, value, e); - count++; - } - - /** * Hashtable collision list. */ private static class Entry implements Map.Entry {