--- old/src/share/classes/java/util/LinkedHashMap.java 2013-05-22 15:46:38.000000000 -0700 +++ new/src/share/classes/java/util/LinkedHashMap.java 2013-05-22 15:46:38.000000000 -0700 @@ -55,9 +55,9 @@ * order they were presented.) * *

A special {@link #LinkedHashMap(int,float,boolean) constructor} is - * provided to create a linked hash map whose order of iteration is the order - * in which its entries were last accessed, from least-recently accessed to - * most-recently (access-order). This kind of map is well-suited to + * provided to create a LinkedHashMap whose order of iteration is the + * order in which its entries were last accessed, from least-recently accessed + * to most-recently (access-order). This kind of map is well-suited to * building LRU caches. Invoking the put or get method * results in an access to the corresponding entry (assuming it exists after * the invocation completes). The putAll method generates one entry @@ -243,23 +243,6 @@ } /** - * Transfers all entries to new table array. This method is called - * by superclass resize. It is overridden for performance, as it is - * faster to iterate using our linked list. - */ - @Override - @SuppressWarnings("unchecked") - void transfer(HashMap.Entry[] newTable) { - int newCapacity = newTable.length; - for (Entry e = header.after; e != header; e = e.after) { - int index = indexFor(e.hash, newCapacity); - e.next = (HashMap.Entry)newTable[index]; - newTable[index] = e; - } - } - - - /** * Returns true if this map maps one or more keys to the * specified value. * @@ -320,7 +303,7 @@ // These fields comprise the doubly linked list used for iteration. Entry before, after; - Entry(int hash, K key, V value, HashMap.Entry next) { + Entry(int hash, K key, V value, Object next) { super(hash, key, value, next); } @@ -344,7 +327,7 @@ /** * This method is invoked by the superclass whenever the value - * of a pre-existing entry is read by Map.get or modified by Map.set. + * of a pre-existing entry is read by Map.get or modified by Map.put. * If the enclosing Map is access-ordered, it moves the entry * to the end of the list; otherwise, it does nothing. */ @@ -360,8 +343,8 @@ void recordRemoval(HashMap m) { remove(); } - } - + } + private abstract class LinkedHashIterator implements Iterator { Entry nextEntry = header.after; Entry lastReturned = null; @@ -422,29 +405,27 @@ * allocated entry to get inserted at the end of the linked list and * removes the eldest entry if appropriate. */ - void addEntry(int hash, K key, V value, int bucketIndex) { - super.addEntry(hash, key, value, bucketIndex); + @Override + void addEntry(int hash, K key, V value, int bucketIndex, boolean checkIfNeedTree) { + super.addEntry(hash, key, value, bucketIndex, checkIfNeedTree); // Remove eldest entry if instructed Entry eldest = header.after; if (removeEldestEntry(eldest)) { removeEntryForKey(eldest.key); - } + } } - /** - * This override differs from addEntry in that it doesn't resize the - * table or remove the eldest entry. + /* + * Create a new LinkedHashMap.Entry and setup the before/after pointers */ - void createEntry(int hash, K key, V value, int bucketIndex) { - @SuppressWarnings("unchecked") - HashMap.Entry old = (HashMap.Entry)table[bucketIndex]; - Entry e = new Entry<>(hash, key, value, old); - table[bucketIndex] = e; - e.addBefore(header); - size++; + @Override + HashMap.Entry newEntry(int hash, K key, V value, Object next) { + Entry newEntry = new Entry<>(hash, key, value, next); + newEntry.addBefore(header); + return newEntry; } - + /** * Returns true if this map should remove its eldest entry. * This method is invoked by put and putAll after