OSDN Git Service

2007-01-23 Marco Trudel <mtrudel@gmx.ch>
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Jan 2007 23:30:54 +0000 (23:30 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Jan 2007 23:30:54 +0000 (23:30 +0000)
* java/util/Arrays.java (binarySearch): Change comparison order.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121091 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/classpath/ChangeLog
libjava/classpath/java/util/Arrays.java
libjava/classpath/lib/java/util/Arrays$ArrayList.class
libjava/classpath/lib/java/util/Arrays.class

index 3a3d8a2..489b9aa 100644 (file)
@@ -1,3 +1,7 @@
+2007-01-23  Marco Trudel  <mtrudel@gmx.ch>
+
+       * java/util/Arrays.java (binarySearch): Change comparison order.
+
 2007-01-17  Tom Tromey  <tromey@redhat.com>
 
        * tools/gnu/classpath/tools/javah/PathOptionGroup.java
 2007-01-17  Tom Tromey  <tromey@redhat.com>
 
        * tools/gnu/classpath/tools/javah/PathOptionGroup.java
index fbbf43f..7231424 100644 (file)
@@ -1,5 +1,5 @@
 /* Arrays.java -- Utility class with methods to operate on arrays
 /* 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.
    Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -370,10 +370,13 @@ public class Arrays
     while (low <= hi)
       {
         mid = (low + hi) >>> 1;
     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;
         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
           hi = mid - 1;
         else
           // This gets the insertion point right on the last loop
index 98cdfd0..bd2e14a 100644 (file)
Binary files a/libjava/classpath/lib/java/util/Arrays$ArrayList.class and b/libjava/classpath/lib/java/util/Arrays$ArrayList.class differ
index 5dcf6af..6b86dec 100644 (file)
Binary files a/libjava/classpath/lib/java/util/Arrays.class and b/libjava/classpath/lib/java/util/Arrays.class differ