commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bugs #8413] IntBuffer.compareTo is non-transitive


From: anonymous
Subject: [bugs #8413] IntBuffer.compareTo is non-transitive
Date: Thu, 01 Apr 2004 12:01:20 -0500
User-agent: Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:1.3.1) Gecko/20030723 wamcom.org

This mail is an automated notification from the bugs tracker
 of the project: classpath.




/**************************************************************************/
[bugs #8413] Full Item Snapshot:

URL: <http://savannah.gnu.org/bugs/?func=detailitem&item_id=8413>
Project: classpath
Submitted by: 0
On: Thu 04/01/04 at 12:01

Severity:  5 - Average
Resolution:  None
Assigned to:  None
Status:  Open
Platform Version:  None


Summary:  IntBuffer.compareTo is non-transitive

Original Submission:  
I think I noticed a bug in the Gnu Classpath implementation of 
java.nio.IntBuffer while browsing CVS and I wouldn't be surprised if the same 
bug is present in the other buffer classes as well. FYI, I have never seen the 
Sun source code for the java.nio classes.

The compareTo method begins like this:

  public int compareTo (Object obj)
  {
    IntBuffer a = (IntBuffer) obj;

    if (a.remaining () != remaining ())
      return 1;

This fails transitivity. Consider two buffers a and b with different remaining 
sizes:

a.compareTo(b) returns 1 and b.compareTo(a) returns 1. In other words a > b and 
b > a. 

I have not actually written test code for this, so possibly I'm missing 
something. If so, I apologize. Also my apologies if this is a duplicate report. 
Savannah was acting up and I couldn't search the bug database. :-(

I suspect you need something like this instead:

    if (a.remaining () != remaining ()) {
        if (a.remaining() > b.remaining) return 1;
        else return -1;
  }

However, I don't yet know which case should return 1 and which one should 
return -1. 












For detailed info, follow this link:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=8413>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/







reply via email to

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