harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r532306 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/AbstractMap.java main/java/java/util/AbstractSet.java test/java/tests/api/java/util/TreeMapTest.java test/java/tests/api/java/util/TreeSetTest.java
Date Wed, 25 Apr 2007 10:40:40 GMT
Author: ayza
Date: Wed Apr 25 03:40:39 2007
New Revision: 532306

URL: http://svn.apache.org/viewvc?view=rev&rev=532306
Log:
Applying patch from HARMONY-1639 ( [classlib][luni] Fresh install of jedit 4.3pre6 doesn't
start - throws exception)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java?view=diff&rev=532306&r1=532305&r2=532306
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java
Wed Apr 25 03:40:39 2007
@@ -139,10 +139,15 @@
 
             Set<?> objectSet = map.entrySet();
             Iterator<Map.Entry<K, V>> it = entrySet().iterator();
-            while (it.hasNext()) {
-                if (!objectSet.contains(it.next())) {
-                    return false;
+
+            try {
+                while (it.hasNext()) {
+                    if (!objectSet.contains(it.next())) {
+                        return false;
+                    }
                 }
+            } catch (ClassCastException cce) {
+                return false;
             }
             return true;
         }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java?view=diff&rev=532306&r1=532305&r2=532306
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java
Wed Apr 25 03:40:39 2007
@@ -52,7 +52,12 @@
         }
         if (object instanceof Set) {
             Set<?> s = (Set<?>) object;
-            return size() == s.size() && containsAll(s);
+
+            try {
+                return size() == s.size() && containsAll(s);
+            } catch (ClassCastException cce) {
+                return false;
+            }
         }
         return false;
     }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java?view=diff&rev=532306&r1=532305&r2=532306
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
Wed Apr 25 03:40:39 2007
@@ -523,6 +523,39 @@
     }
 
     /**
+     * Tests equals() method.
+     * Tests that no ClassCastException will be thrown in all cases.
+     * Regression test for HARMONY-1639.
+     */
+    public void test_equals() throws Exception {
+        // comparing TreeMaps with different object types
+        Map m1 = new TreeMap();
+        Map m2 = new TreeMap();
+        m1.put("key1", "val1");
+        m1.put("key2", "val2");
+        m2.put(new Integer(1), "val1");
+        m2.put(new Integer(2), "val2");
+        assertFalse("Maps should not be equal 1", m1.equals(m2));
+        assertFalse("Maps should not be equal 2", m2.equals(m1));
+
+        // comparing TreeMap with HashMap
+        m1 = new TreeMap();
+        m2 = new HashMap();
+        m1.put("key", "val");
+        m2.put(new Object(), "val");
+        assertFalse("Maps should not be equal 3", m1.equals(m2));
+        assertFalse("Maps should not be equal 4", m2.equals(m1));
+
+        // comparing TreeMaps with not-comparable objects inside
+        m1 = new TreeMap();
+        m2 = new TreeMap();
+        m1.put(new Object(), "val1");
+        m2.put(new Object(), "val1");
+        assertFalse("Maps should not be equal 5", m1.equals(m2));
+        assertFalse("Maps should not be equal 6", m2.equals(m1));
+    }
+
+    /**
      * Sets up the fixture, for example, open a network connection. This method
      * is called before a test is executed.
      */

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java?view=diff&rev=532306&r1=532305&r2=532306
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java
Wed Apr 25 03:40:39 2007
@@ -296,6 +296,39 @@
 			assertTrue("Returned incorrect set", s.contains(objArray[i]));
 	}
 
+    /**
+     * Tests equals() method.
+     * Tests that no ClassCastException will be thrown in all cases.
+     * Regression test for HARMONY-1639.
+     */
+    public void test_equals() throws Exception {
+        // comparing TreeSets with different object types
+        Set s1 = new TreeSet();
+        Set s2 = new TreeSet();
+        s1.add("key1");
+        s1.add("key2");
+        s2.add(new Integer(1));
+        s2.add(new Integer(2));
+        assertFalse("Sets should not be equal 1", s1.equals(s2));
+        assertFalse("Sets should not be equal 2", s2.equals(s1));
+
+        // comparing TreeSet with HashSet
+        s1 = new TreeSet();
+        s2 = new HashSet();
+        s1.add("key");
+        s2.add(new Object());
+        assertFalse("Sets should not be equal 3", s1.equals(s2));
+        assertFalse("Sets should not be equal 4", s2.equals(s1));
+
+        // comparing TreeSets with not-comparable objects inside
+        s1 = new TreeSet();
+        s2 = new TreeSet();
+        s1.add(new Object());
+        s2.add(new Object());
+        assertFalse("Sets should not be equal 5", s1.equals(s2));
+        assertFalse("Sets should not be equal 6", s2.equals(s1));
+    }
+
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.



Mime
View raw message