harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r450697 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/LinkedHashMap.java test/java/tests/api/java/util/LinkedHashMapTest.java
Date Thu, 28 Sep 2006 05:12:31 GMT
Author: pyang
Date: Wed Sep 27 22:12:30 2006
New Revision: 450697

URL: http://svn.apache.org/viewvc?view=rev&rev=450697
Log:
Apply patch for HARMONY-1512 ([classlib][luni][LinkedHashMap]LinkedHashMap.putAll should inherit
from HashMap and avoids expand backed element array more than once.)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/LinkedHashMap.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/LinkedHashMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/LinkedHashMap.java?view=diff&rev=450697&r1=450696&r2=450697
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/LinkedHashMap.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/LinkedHashMap.java
Wed Sep 27 22:12:30 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -362,19 +362,6 @@
             tail = m;
         }
 
-    }
-
-    /**
-     * Put all entries from the given map into the LinkedHashMap
-     * 
-     * @param m
-     *            Input map
-     */
-    @Override
-    public void putAll(Map<? extends K, ? extends V> m) {
-        for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) {
-            put(e.getKey(), e.getValue());
-        }
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java?view=diff&rev=450697&r1=450696&r2=450697
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java
Wed Sep 27 22:12:30 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,6 +54,18 @@
 			return size() > 5;
 		}
 	}
+    
+    private static class MockMapNull extends AbstractMap {
+        @Override
+        public Set entrySet() {
+            return null;
+        }
+
+        @Override
+        public int size() {
+            return 10;
+        }
+    }
 
 	/**
 	 * @tests java.util.LinkedHashMap#LinkedHashMap()
@@ -171,6 +183,26 @@
 			assertTrue("Failed to clear all elements", hm2.get(
 					new Integer(i).toString()).equals((new Integer(i))));
 	}
+
+    /**
+     * @tests java.util.LinkedHashMap#putAll(java.util.Map)
+     */
+    public void test_putAll_Ljava_util_Map_Null() {
+        LinkedHashMap linkedHashMap = new LinkedHashMap();
+        try {
+            linkedHashMap.putAll(new MockMapNull());
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // expected.
+        }
+
+        try {
+            linkedHashMap = new LinkedHashMap(new MockMapNull());
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // expected.
+        }
+    } 
 
 	/**
 	 * @tests java.util.LinkedHashMap#entrySet()



Mime
View raw message