From harmony-dev-return-11281-apmail-incubator-harmony-dev-archive=incubator.apache.org@incubator.apache.org Wed Aug 02 07:08:34 2006 Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 52324 invoked from network); 2 Aug 2006 07:08:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Aug 2006 07:08:33 -0000 Received: (qmail 36787 invoked by uid 500); 2 Aug 2006 07:08:31 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 36736 invoked by uid 500); 2 Aug 2006 07:08:31 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 36725 invoked by uid 99); 2 Aug 2006 07:08:31 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2006 00:08:31 -0700 X-ASF-Spam-Status: No, hits=1.9 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 202.81.18.152 is neither permitted nor denied by domain of richard.liangyx@gmail.com) Received: from [202.81.18.152] (HELO ausmtp04.au.ibm.com) (202.81.18.152) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2006 00:08:29 -0700 Received: from sd0109e.au.ibm.com (d23rh905.au.ibm.com [202.81.18.225]) by ausmtp04.au.ibm.com (8.13.6/8.13.5) with ESMTP id k727EDHs046802 for ; Wed, 2 Aug 2006 17:14:13 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.250.243]) by sd0109e.au.ibm.com (8.13.6/8.13.6/NCO v8.1) with ESMTP id k727BDO2110088 for ; Wed, 2 Aug 2006 17:11:25 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k7275aaA005584 for ; Wed, 2 Aug 2006 17:05:36 +1000 Received: from d23m0011.cn.ibm.com ([9.181.32.74]) by d23av02.au.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k7275R8i003980 for ; Wed, 2 Aug 2006 17:05:36 +1000 Received: from [127.0.0.1] ([9.181.106.60]) by d23m0011.cn.ibm.com (Lotus Domino Release 6.5.5HF262) with ESMTP id 2006080215065988-20374 ; Wed, 2 Aug 2006 15:06:59 +0800 Message-ID: <44D04E99.8020509@gmail.com> Date: Wed, 02 Aug 2006 15:04:57 +0800 From: Richard Liang User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: [classlib][luni] Is fully comply with Comparator.compare(T, T) necessary (Re JIRA harmony 1026) References: <44D0499A.6050601@gmail.com> In-Reply-To: <44D0499A.6050601@gmail.com> X-MIMETrack: Itemize by SMTP Server on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 02/08/2006 15:06:59, Serialize by Router on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 02/08/2006 15:07:34, Serialize complete at 02/08/2006 15:07:34 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Spark Shen wrote: > I constructed a MockComparator as below: > public static class MockComparator implements Comparator { > public int compare(T o1, T o2) { > if(null == o1) return -1; > if(o1.equals(o2)) { > return 0; > } > return 1; > } > } > > This comparator regards null as the smallest object and TreeMap uses > this Comparator as a null-tolerable comparator. > And this comparator is used to test the behavior of TreeMap.headMap() > when the input is null. > > Since null is recognized as smallest, the expected length of the > returned SortedMap of TreeMap.headMap(null) will be zero. > > My point here is that, under this situation, the MockComparator does > not care about the order of non-null objects, it just know > null is always smaller. So, is it acceptable that - in this > comparator, compare method does not judge the order of all the > non-null objects? > (does not comply with doc of comparator.compare) > What will happen when both o1 and o2 are null? My understanding about mocked objects is that: we could only implement some necessary logic, but the logic must be compliant with the specification. Correct me if I'm wrong. Thanks a lot. Best regards, Richard > Best regards > -- Richard Liang China Software Development Lab, IBM --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org For additional commands, e-mail: harmony-dev-help@incubator.apache.org