]> gcc.gnu.org Git - gcc.git/commitdiff
Arrays.java (binarySearch): Change comparison order.
authorMarco Trudel <mtrudel@gmx.ch>
Tue, 23 Jan 2007 23:30:54 +0000 (00:30 +0100)
committerTom Tromey <tromey@gcc.gnu.org>
Tue, 23 Jan 2007 23:30:54 +0000 (23:30 +0000)
2007-01-23  Marco Trudel  <mtrudel@gmx.ch>

* java/util/Arrays.java (binarySearch): Change comparison order.

From-SVN: r121091

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 3a3d8a221fe4c19c532713e433d331a2c796712d..489b9aa8cf7d2af2e98b73f2f8a17d4b1ba2d56c 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
index fbbf43f209b21c3e3dcad1f7f2c1936a9e765121..723142437855b74e036258b2d2b814e5974373f9 100644 (file)
@@ -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.
@@ -370,10 +370,13 @@ public class Arrays
     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
index 98cdfd0e0705d639895434ee2fc61107a31559bb..bd2e14ab1bc0aac206701569d174c432ebe771f2 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 5dcf6af3f41a7aaab1dab9160cfb8614baa42880..6b86decd3e39fb78fc6b791b1ac9af6fdcc8c953 100644 (file)
Binary files a/libjava/classpath/lib/java/util/Arrays.class and b/libjava/classpath/lib/java/util/Arrays.class differ
This page took 0.094287 seconds and 5 git commands to generate.