harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhouke...@apache.org
Subject svn commit: r934328 - in /harmony/enhanced/java/trunk/classlib/modules/luni/src: main/java/java/util/LinkedHashMap.java test/api/common/org/apache/harmony/luni/tests/java/util/LinkedHashMapTest.java
Date Thu, 15 Apr 2010 08:39:48 GMT
Author: zhoukevin
Date: Thu Apr 15 08:39:47 2010
New Revision: 934328

URL: http://svn.apache.org/viewvc?rev=934328&view=rev
Log:
Apply patch for HARMONY-6498: java.util.LinkedHashMap should implements Map<K, V> interface
according to Java Spec

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

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/util/LinkedHashMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/util/LinkedHashMap.java?rev=934328&r1=934327&r2=934328&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/util/LinkedHashMap.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/util/LinkedHashMap.java
Thu Apr 15 08:39:47 2010
@@ -48,7 +48,7 @@ package java.util;
  *
  * @since 1.4
  */
-public class LinkedHashMap<K, V> extends HashMap<K, V> {
+public class LinkedHashMap<K, V> extends HashMap<K, V> implements Map<K, V>
{
 
     private static final long serialVersionUID = 3801124242820219131L;
 
@@ -246,7 +246,7 @@ public class LinkedHashMap<K, V> extends
         }
     }
 
-    static final class LinkedHashMapEntry<K, V> extends Entry<K, V> {
+    static final class LinkedHashMapEntry<K, V> extends HashMap.Entry<K, V> {
         LinkedHashMapEntry<K, V> chainForward, chainBackward;
 
         LinkedHashMapEntry(K theKey, V theValue) {
@@ -305,7 +305,7 @@ public class LinkedHashMap<K, V> extends
      */
     @Override
     @SuppressWarnings("unchecked")
-    Entry<K, V>[] newElementArray(int s) {
+    HashMap.Entry<K, V>[] newElementArray(int s) {
         return new LinkedHashMapEntry[s];
     }
 
@@ -351,7 +351,7 @@ public class LinkedHashMap<K, V> extends
      * @param key @param index @return Entry
      */
     @Override
-    Entry<K, V> createEntry(K key, int index, V value) {
+    HashMap.Entry<K, V> createEntry(K key, int index, V value) {
         LinkedHashMapEntry<K, V> m = new LinkedHashMapEntry<K, V>(key, value);
         m.next = elementData[index];
         elementData[index] = m;
@@ -359,7 +359,7 @@ public class LinkedHashMap<K, V> extends
         return m;
     }
 
-    Entry<K, V> createHashedEntry(K key, int index, int hash) {
+    HashMap.Entry<K, V> createHashedEntry(K key, int index, int hash) {
         LinkedHashMapEntry<K, V> m = new LinkedHashMapEntry<K, V>(key, hash);
         m.next = elementData[index];
         elementData[index] = m;

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedHashMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedHashMapTest.java?rev=934328&r1=934327&r2=934328&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedHashMapTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedHashMapTest.java
Thu Apr 15 08:39:47 2010
@@ -17,12 +17,15 @@
 
 package org.apache.harmony.luni.tests.java.util;
 
+import java.io.Serializable;
 import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
@@ -642,6 +645,22 @@ public class LinkedHashMapTest extends j
 		assertTrue("Entries left in map", !it1.hasNext());
 	}
 
+	public void test_getInterfaces() {
+        Class<?>[] interfaces = HashMap.class.getInterfaces();
+        assertEquals(3, interfaces.length);
+
+        List<Class<?>> interfaceList = Arrays.asList(interfaces);
+        assertTrue(interfaceList.contains(Map.class));
+        assertTrue(interfaceList.contains(Cloneable.class));
+        assertTrue(interfaceList.contains(Serializable.class));
+
+        interfaces = LinkedHashMap.class.getInterfaces();
+        assertEquals(1, interfaces.length);
+
+        interfaceList = Arrays.asList(interfaces);
+        assertTrue(interfaceList.contains(Map.class));
+    }
+
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.



Mime
View raw message