You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2006/08/11 13:32:04 UTC
svn commit: r430759 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/java/util/TreeMap.java
test/java/tests/api/java/util/TreeMapTest.java
Author: pyang
Date: Fri Aug 11 04:32:03 2006
New Revision: 430759
URL: http://svn.apache.org/viewvc?rev=430759&view=rev
Log:
Patch applied for HARMONY-1066 ([classlib][luni] java.util.TreeMap.headMap(Object) & tailMap(Object) methods do not return serializable SortedMap)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java?rev=430759&r1=430758&r2=430759&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java Fri Aug 11 04:32:03 2006
@@ -297,14 +297,16 @@
}
}
- static final class SubMap<K,V> extends AbstractMap<K,V> implements SortedMap<K,V> {
+ static final class SubMap<K,V> extends AbstractMap<K,V> implements SortedMap<K,V>, Serializable {
+ private static final long serialVersionUID = -6520786458950516097L;
+
private TreeMap<K,V> backingMap;
boolean hasStart, hasEnd;
K startKey, endKey;
- Set<Map.Entry<K,V>> entrySet = null;
+ transient Set<Map.Entry<K,V>> entrySet = null;
SubMap(K start, TreeMap<K,V> map) {
backingMap = map;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java?rev=430759&r1=430758&r2=430759&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java Fri Aug 11 04:32:03 2006
@@ -15,6 +15,7 @@
package tests.api.java.util;
+import java.io.Serializable;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.Comparator;
@@ -25,6 +26,8 @@
import java.util.SortedMap;
import java.util.TreeMap;
+import org.apache.harmony.testframework.serialization.SerializationTest;
+
import tests.support.Support_MapTest2;
import tests.support.Support_UnmodifiableCollectionTest;
@@ -41,11 +44,11 @@
}
// Regression for Harmony-1026
- public static class MockComparator<T extends Comparable<T>> implements Comparator<T>{
+ public static class MockComparator<T extends Comparable<T>> implements Comparator<T>, Serializable{
public int compare(T o1, T o2) {
if( o1 == o2 ) return 0;
- if( null == o1 ) return -1;
+ if( null == o1 || null == o2) return -1;
T c1 = (T)o1;
T c2 = (T)o2;
return c1.compareTo(c2);
@@ -271,6 +274,9 @@
Collection<Double> valueCollection = smap.values();
assertEquals(0, valueCollection.size());
+
+ // Regression for Harmony-1066
+ assertTrue(head instanceof Serializable);
}
/**
@@ -375,6 +381,9 @@
for (int i = 900; i < objArray.length; i++)
assertTrue("Map contains incorrect entries", tail
.containsValue(objArray[i]));
+
+ // Regression for Harmony-1066
+ assertTrue(tail instanceof Serializable);
}
/**
@@ -403,7 +412,31 @@
!myTreeMap.containsValue(new Integer(0)));
}
-
+
+ /**
+ * @tests java.util.TreeMap#SerializationTest()
+ */
+ // Regression for Harmony-1066
+ public void test_SubMap_Serializable() throws Exception {
+ TreeMap<Integer, Double> map = new TreeMap<Integer, Double>();
+ map.put(1, 2.1);
+ map.put(2, 3.1);
+ map.put(3, 4.5);
+ map.put(7, 21.3);
+ SortedMap<Integer, Double> headMap = map.headMap(3);
+ assertTrue(headMap instanceof Serializable);
+ assertFalse(headMap instanceof TreeMap);
+ assertTrue(headMap instanceof SortedMap);
+
+ assertFalse(headMap.entrySet() instanceof Serializable);
+ assertFalse(headMap.keySet() instanceof Serializable);
+ assertFalse(headMap.values() instanceof Serializable);
+
+ // This assertion will fail on RI. This is a bug of RI.
+ SerializationTest.verifySelf(headMap);
+
+ }
+
/**
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.