harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "spark shen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap
Date Wed, 02 Aug 2006 04:47:18 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-1026?page=comments#action_12425119 ] 
            
spark shen commented on HARMONY-1026:
-------------------------------------

Change to WeakHashMap is trival and deliberate. It changes some coding convention problems
to make the code more perfect. 
1. Use StringBuilder to assemble string used in toString() method
2. move unnecessary 'else' clauses in WeakHashMap.HashIterator.next() method

Is that acceptable?

Best regards,
Spark Shen

> [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1026
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1026
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>         Assigned To: Paulex Yang
>         Attachments: harmony-1026.diff
>
>
> java.util.TreeMap.headMap(Object) method does not return
> empty SortedMap when the specified object is null and the tree map uses a
> null-tolerable comparator.
> The following test case gives a hint.
> public static class MockComparator<T> implements Comparator<T> {
>         
>         public int compare(T o1, T o2) {
>             if(null == o1) return -1;
>             if(o1.equals(o2)) {
>                 return 0;
>             }
>             return 1;
>         }
>         
> }
> public void test_headMapLjava_lang_Object() {
>         TreeMap<Integer, Double> map = new TreeMap<Integer, Double>(
>                 new MockComparator<Integer>());
>         map.put(1, 2.1);
>         map.put(2, 3.1);
>         map.put(3, 4.5);
>         map.put(7, 21.3);
>         SortedMap<Integer, Double> smap = map.headMap(null);
>         assertEquals(0, smap.size());
>         Set<Integer> keySet = smap.keySet();
>         assertEquals(0, keySet.size());
>         Set<Map.Entry<Integer, Double>> entrySet = smap.entrySet();
>         assertEquals(0, entrySet.size());
> }
> I will attach a patch to fix this problem.
> Best regards,
> Spark Shen

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message