User account creation filtered due to spam.

Bug 31646 - Arrays.sort() broken
Summary: Arrays.sort() broken
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: unspecified
: P3 major
Target Milestone: 0.95
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-21 12:44 UTC by Jeroen Frijters
Modified: 2007-10-09 09:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
proposed patch to fix the problem (309 bytes, patch)
2007-04-21 12:47 UTC, Jeroen Frijters
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeroen Frijters 2007-04-21 12:44:21 UTC
Arrays.sort() is broken as this code demonstrates:

class sort
{
  public static void main(String[] args)
  {
    int[] arr = new int[20];
    arr[0] = 0;
    arr[1] = 1;
    arr[2] = 2;
    arr[3] = 3;
    arr[4] = 4;
    arr[5] = 5;
    arr[6] = 6;
    arr[7] = 7;
    arr[8] = 8;
    arr[9] = 9;
    arr[10] = 9;
    arr[11] = 8;
    arr[12] = 7;
    arr[13] = 6;
    arr[14] = 5;
    arr[15] = 4;
    arr[16] = 3;
    arr[17] = 2;
    arr[18] = 1;
    arr[19] = 0;
    java.util.Arrays.sort(arr, 10, 20);
    for (int i = 10; i < 20; i++) System.out.print(arr[i] + ", ");
  }
}

Output:

0, 1, 2, 3, 4, 5, 5, 6, 7, 8,
Comment 1 Jeroen Frijters 2007-04-21 12:47:40 UTC
Created attachment 13401 [details]
proposed patch to fix the problem
Comment 2 cvs-commit@developer.classpath.org 2007-04-23 11:22:01 UTC
Subject: Bug 31646

CVSROOT:	/cvsroot/classpath
Module name:	classpath
Changes by:	Jeroen Frijters <jfrijters>	07/04/23 10:21:37

Modified files:
	.              : ChangeLog 
	java/util      : Arrays.java 

Log message:
	2007-04-23  Jeroen Frijters  <jeroen@frijters.net>
	
	        PR classpath/31646:
	        * java/util/Arrays.java (qsort): Corrected initial median calculation.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.9281&r2=1.9282
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Arrays.java?cvsroot=classpath&r1=1.35&r2=1.36



Comment 3 Jeroen Frijters 2007-04-23 11:23:55 UTC
Fixed.
Comment 4 cvs-commit@developer.classpath.org 2007-04-23 11:54:49 UTC
Subject: Bug 31646

CVSROOT:	/cvsroot/classpath
Module name:	classpath
Branch:		classpath-0_95-branch
Changes by:	Mark Wielaard <mark>	07/04/23 10:54:33

Modified files:
	.              : ChangeLog 
	java/util      : Arrays.java 

Log message:
	2007-04-23  Jeroen Frijters  <jeroen@frijters.net>
	
	       PR classpath/31646:
	       * java/util/Arrays.java (qsort): Corrected initial median calculation.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&only_with_tag=classpath-0_95-branch&r1=1.9222.2.21&r2=1.9222.2.22
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Arrays.java?cvsroot=classpath&only_with_tag=classpath-0_95-branch&r1=1.35&r2=1.35.2.1



Comment 5 Tom Tromey 2007-04-23 17:16:29 UTC
Subject: Bug 31646

Author: tromey
Date: Mon Apr 23 17:15:51 2007
New Revision: 124071

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124071
Log:
2007-04-23  Jeroen Frijters  <jeroen@frijters.net>

	PR classpath/31646:
	* java/util/Arrays.java (qsort): Corrected initial median calculation.

Modified:
    trunk/libjava/classpath/ChangeLog
    trunk/libjava/classpath/java/util/Arrays.java
    trunk/libjava/classpath/lib/java/util/Arrays.class

Comment 6 Tom Tromey 2007-04-23 17:18:17 UTC
Subject: Bug 31646

Author: tromey
Date: Mon Apr 23 17:17:56 2007
New Revision: 124072

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124072
Log:
2007-04-23  Jeroen Frijters  <jeroen@frijters.net>

	PR classpath/31646:
	* java/util/Arrays.java (qsort): Corrected initial median calculation.

Modified:
    branches/redhat/gcc-4_1-branch/libjava/classpath/ChangeLog
    branches/redhat/gcc-4_1-branch/libjava/classpath/java/util/Arrays.java