bug-classpath
[Top][All Lists]
Advanced

[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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]