From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31570 invoked by alias); 23 Jan 2007 23:07:05 -0000 Received: (qmail 31433 invoked by uid 22791); 23 Jan 2007 23:07:05 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 23 Jan 2007 23:06:59 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id l0NN6ujW021643 for ; Tue, 23 Jan 2007 18:06:56 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l0NN6ugT030824 for ; Tue, 23 Jan 2007 18:06:56 -0500 Received: from opsy.redhat.com (ton.toronto.redhat.com [172.16.14.15]) by pobox.corp.redhat.com (8.13.1/8.12.8) with ESMTP id l0NN6tWm006540; Tue, 23 Jan 2007 18:06:55 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 8AB263786DF; Tue, 23 Jan 2007 13:57:12 -0700 (MST) To: GCJ-patches Subject: Patch: FYI: Arrays patch From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom Date: Tue, 23 Jan 2007 23:07:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org X-SW-Source: 2007-q1/txt/msg00154.txt.bz2 I'm checking this in on the 4.2 branch, the trunk, and the RH 4.1 merge branch. This patch was a bit controversial when proposed for Classpath. Please track the discussion there. Tom Index: ChangeLog from Marco Trudel * java/util/Arrays.java (binarySearch): Change comparison order. Index: java/util/Arrays.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/Arrays.java,v retrieving revision 1.34 diff -u -r1.34 Arrays.java --- java/util/Arrays.java 8 Jan 2007 17:55:34 -0000 1.34 +++ java/util/Arrays.java 20 Jan 2007 02:01:37 -0000 @@ -1,5 +1,5 @@ /* Arrays.java -- Utility class with methods to operate on arrays - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -639,10 +639,13 @@ while (low <= hi) { mid = (low + hi) >>> 1; - final int d = Collections.compare(key, a[mid], c); + // NOTE: Please keep the order of a[mid] and key. Although + // not required by the specs, the RI has it in this order as + // well, and real programs (erroneously) depend on it. + final int d = Collections.compare(a[mid], key, c); if (d == 0) return mid; - else if (d < 0) + else if (d > 0) hi = mid - 1; else // This gets the insertion point right on the last loop