Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 80266 invoked from network); 21 Jan 2009 12:48:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Jan 2009 12:48:19 -0000 Received: (qmail 12831 invoked by uid 500); 21 Jan 2009 12:48:17 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 12806 invoked by uid 500); 21 Jan 2009 12:48:17 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 12795 invoked by uid 99); 21 Jan 2009 12:48:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Jan 2009 04:48:17 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of aleksey.shipilev@gmail.com designates 209.85.198.244 as permitted sender) Received: from [209.85.198.244] (HELO rv-out-0708.google.com) (209.85.198.244) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Jan 2009 12:48:06 +0000 Received: by rv-out-0708.google.com with SMTP id k29so4463707rvb.0 for ; Wed, 21 Jan 2009 04:47:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=Bv/eeCDycjE5f1HqpbwvWCnxucaiXSaEq0RIBWV1SFA=; b=trVx52tyGZwHcJ9Y0wGwqPWBDbe2HoBGc2pdLsHs+auMPaDGDW4cgZTTHdo0MvLt8y 1Mw2ZLlgwaivpacgh3NuIv41bs8DTrl+SaZmotq7/QNrvFmhFpaiQw99PEPHPG/R99Hl uWChc8uR4pkggGbbl7eu9NesHvd4J04OW4cDo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=w2xR87mnrfg5d2LOKcFIjjAsLg/nbduYpvhE3jbWEU45bnWLIpficasPEex6bPPbZr x/jAjA8qo/lklRpZb9SDrntsxq7+A2x6wg9awOkT8vdNgzQfQpAOdHGJo3Hgm7s7CN1U 34hSaeabrQuJS++LaVGerJ6RaTlxelVAJn1N4= MIME-Version: 1.0 Received: by 10.141.48.10 with SMTP id a10mr56988rvk.266.1232542065273; Wed, 21 Jan 2009 04:47:45 -0800 (PST) In-Reply-To: <49771881.7020704@gmail.com> References: <49770FB7.5020404@gmail.com> <4bebff790901210421y2a8bbb39ge833cccf849e145a@mail.gmail.com> <49771881.7020704@gmail.com> Date: Wed, 21 Jan 2009 15:47:45 +0300 Message-ID: <4bebff790901210447h77f1b8fbt36f0f1122450bf42@mail.gmail.com> Subject: Re: [eut][classlib][luni] different behaviors of TreeSet.remove() between RI and Harmony From: Aleksey Shipilev To: dev@harmony.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Yeah, that was a lucky coincidence. I had changed: - Entry temp = new Entry(2); + Entry temp = new Entry(10); ...and both RI and Harmony prints out "false". Thanks, Aleksey. On Wed, Jan 21, 2009 at 3:43 PM, Regis wrote: > > Aleksey Shipilev wrote: >> >> Hi Regis, >> >>> From Java class library side, the behaviour in this case is unspecified. >> >> I believe you hit on the known issue with EUT, please refer to >> archived Harmony thread [1]. Reading back that thread you might notice >> that this is the inconsistency in EUT which (by some miracle occasion) >> works well with RI. There's the Eclipse bug against that submitted >> [2]. >> >> Thanks, >> Aleksey. >> >> [1] http://markmail.org/message/svoktdxopww6sv7p >> [2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=212583 >> >> On Wed, Jan 21, 2009 at 3:06 PM, Regis wrote: >>> >>> Hi, >>> >>> I track the eut test testAddWorkingSet in org.eclipse.ui.tests, found >>> this >>> failure was caused by Harmony TreeSet can't remove a element already in >>> the >>> set. After further investigation, I found the test changed the elements >>> after added them to set, that corrupt the set, but RI could remove the >>> element successfully even the set is not ordered. >>> >>> Following test demo the scenario: >>> >>> public class TestTreeSet { >>> public static void main(String[] args) { >>> TreeSet set = new TreeSet(); >>> Entry temp = new Entry(2); >>> set.add(new Entry(1)); >>> set.add(temp); >>> set.add(new Entry(3)); >>> set.add(new Entry(4)); >>> set.add(new Entry(5)); >>> set.add(new Entry(6)); >>> temp.setValue(0); >>> >>> for (Iterator iterator = set.iterator(); iterator.hasNext();) { >>> Entry entry = (Entry) iterator.next(); >>> System.out.println(entry.value); >>> } >>> >>> System.out.println(set.remove(temp)); >>> } >>> >>> public static class Entry implements Comparable { >>> private int value; >>> >>> public Entry(int value) { >>> this.value = value; >>> } >>> >>> public void setValue(int value) { >>> this.value = value; >>> } >>> >>> public int getValue() { >>> return value; >>> } >>> >>> public int compareTo(Object arg0) { >>> return value - ((Entry) arg0).value; >>> } >>> } >>> >>> public static class TestComparator implements Comparator { >>> >>> public int compare(Object arg0, Object arg1) { >>> return ((Entry) arg0).getValue() - ((Entry) arg1).getValue(); >>> } >>> >>> } >>> } >>> >>> output of RI: >>> 1 >>> 0 >>> 3 >>> 4 >>> 5 >>> 6 >>> true >>> >>> output of Harmony: >>> 1 >>> 0 >>> 3 >>> 4 >>> 5 >>> 6 >>> false >>> >>> In Harmony, binary search is used to find the element, in this case, the >>> array is not ordered, so it can't work correctly. From spec: >>> >>> "The set will not contain the specified element once the call returns" >>> >>> So I think RI's behavior is more reasonable. >>> >>> This can be fixed by comparing every element in set when remove, but will >>> cause performance downgrade, what do you think? Any suggestions/ideas? >>> >>> -- >>> Best Regards, >>> Regis. >>> >> > > Thanks for your informations, Aleksey. > > -- > Best Regards, > Regis. >