[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/30061] Comparator interface arguments get reversed
From: |
dwhire at yahoo dot com |
Subject: |
[Bug classpath/30061] Comparator interface arguments get reversed |
Date: |
7 Dec 2006 05:27:17 -0000 |
------- Comment #8 from dwhire at yahoo dot com 2006-12-07 05:27 -------
(In reply to comment #7)
> Also, if I change your compare function to (note what it returns if o2 is
> null):
> public int compare(Object o1, Object o2) {
>
> if (o1 == null ) return 1 ; // null is greater
>
> // in this context
>
> if (o2 == null ) return -1 ; // or else IKVM/GNU
>
> // claaspath will fail
>
> String s1 = (String) o1 ;
>
> String s2 = (String) o2 ;
>
> return s1.compareTo(s2);
>
> }
> I get the same output on jamvm+Classpath as I do on Sun java.
Yes, I was already aware that returning -1 if o2 is null bypasses the problem.
I still insist that reversing the arguments as it is done in Classpath is a bad
idea even if the "contract" permits it. We should not use a permissive contract
as an excuse to write inconsistant code.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30061
- [Bug classpath/30061] New: 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/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 <=
- [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