--- old/src/share/classes/java/util/LinkedHashMap.java 2013-12-09 20:35:32.203305438 -0800 +++ new/src/share/classes/java/util/LinkedHashMap.java 2013-12-09 20:35:31.927305424 -0800 @@ -28,7 +28,6 @@ import java.util.function.Consumer; import java.util.function.BiConsumer; import java.util.function.BiFunction; -import java.io.Serializable; import java.io.IOException; /** @@ -63,14 +62,14 @@ * 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 - * 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 - * access for each mapping in the specified map, in the order that key-value - * mappings are provided by the specified map's entry set iterator. No - * other methods generate entry accesses. In particular, operations on - * collection-views do not affect the order of iteration of the backing - * map. + * building LRU caches. Invoking the {@code put}, {@code get}, + * {@code getOrDefault} or {@code replace} methods results in an access to the + * corresponding entry (assuming it exists after the invocation completes). The + * {@code putAll} method generates one entry access for each mapping in the + * specified map, in the order that key-value mappings are provided by the + * specified map's entry set iterator. No other methods generate entry + * accesses. In particular, operations on collection-views do not + * affect the order of iteration of the backing map. * *

The {@link #removeEldestEntry(Map.Entry)} method may be overridden to * impose a policy for removing stale mappings automatically when new mappings @@ -443,8 +442,19 @@ } /** - * Removes all of the mappings from this map. - * The map will be empty after this call returns. + * {@inheritDoc} + */ + public V getOrDefault(Object key, V defaultValue) { + Node e; + if ((e = getNode(hash(key), key)) == null) + return defaultValue; + if (accessOrder) + afterNodeAccess(e); + return e.value; + } + + /** + * {@inheritDoc} */ public void clear() { super.clear(); --- old/test/java/util/LinkedHashMap/Basic.java 2013-12-09 20:35:33.223305487 -0800 +++ new/test/java/util/LinkedHashMap/Basic.java 2013-12-09 20:35:32.987305476 -0800 @@ -23,7 +23,7 @@ /** * @test - * @bug 4245809 + * @bug 4245809 8029795 * @summary Basic test for LinkedHashMap. (Based on MapBash) */ @@ -175,7 +175,7 @@ throw new Exception("Clone: altered by read."); // Test ordering properties with access order - m = new LinkedHashMap(1000, .75f, true); + m = new LinkedHashMap(2*mapSize, .75f, true); for (int i=0; i