[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/30061] New: Comparator interface arguments get reversed
From: |
dwhire at yahoo dot com |
Subject: |
[Bug classpath/30061] New: Comparator interface arguments get reversed |
Date: |
4 Dec 2006 06:03:00 -0000 |
Bug is demonstrated in the following code:
import java.util.Arrays;
import java.util.Comparator;
public class Test1 implements Comparator {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Test1 t = new Test1();
t.doit();
}
void doit (){
System.out.println("test1 vs 001");
String [] sa = {"1","2"} ;
Item i = new Item();
i.key = "X";
Arrays.binarySearch(sa, i, (Comparator) this);
i.key = "2";
Arrays.binarySearch(sa, i, (Comparator) this);
}
public int compare(Object o1, Object o2) {
showType("o1 as String", o1);
showType("o2 as Item", o2);
return -1 ;
}
static void showType(String exp, Object obj){
String type ;
System.out.println ("expected " + exp);
if (obj ==null)
System.out.println("got null");
else {
type = obj.getClass().getName();
if (type.equals("java.lang.String"))
System.out.println("got String " +
(String)obj);
else
System.out.println("got Item " +
((Item)obj).key);
}
}
class Item {
String key ;
}
}
--
Summary: Comparator interface arguments get reversed
Product: classpath
Version: unspecified
Status: UNCONFIRMED
Severity: blocker
Priority: P3
Component: classpath
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dwhire at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30061
- [Bug classpath/30061] New: Comparator interface arguments get reversed,
dwhire at yahoo dot com <=
- [Bug classpath/30061] Comparator interface arguments get reversed, dwhire at yahoo dot com, 2006/12/04
- [Bug classpath/30061] Comparator interface arguments get reversed, dwhire at yahoo dot com, 2006/12/05
- [Bug classpath/30061] Comparator interface arguments get reversed, csm at gnu dot org, 2006/12/05
- [Bug classpath/30061] Comparator interface arguments get reversed, dwhire at yahoo dot com, 2006/12/06
- [Bug classpath/30061] Comparator interface arguments get reversed, dwhire at yahoo dot com, 2006/12/06
- [Bug classpath/30061] Comparator interface arguments get reversed, csm at gnu dot org, 2006/12/06
- [Bug classpath/30061] Comparator interface arguments get reversed, csm at gnu dot org, 2006/12/06
- [Bug classpath/30061] Comparator interface arguments get reversed, dwhire at yahoo dot com, 2006/12/07
- [Bug classpath/30061] Comparator interface arguments get reversed, csm at gnu dot org, 2006/12/07
- [Bug classpath/30061] Comparator interface arguments get reversed, dwhire at yahoo dot com, 2006/12/07