[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/22732] IntBuffer.compareTo is non-transitive
From: |
gcc-bugzilla at gcc dot gnu dot org |
Subject: |
[Bug classpath/22732] IntBuffer.compareTo is non-transitive |
Date: |
16 Oct 2005 01:26:51 -0000 |
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.
------- Comment #1 from from-classpath at savannah dot gnu dot org 2004-04-01
17:03 -------
I congratulate you on not requiring me to log in to submit a bug report. Betas
the hell out of Apache. :-)
In case you need to contact me to ask about this. this bug was submitted by
Elliotte Harold. You can reach me at address@hidden,unc.edu.
------- Comment #2 from from-classpath at savannah dot gnu dot org 2004-04-29
18:05 -------
I commited a fix to cvs for all buffer classes. The new implementation is
backed by a new mauve test and should be okay now. Thx for your report.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22732
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug classpath/22732] IntBuffer.compareTo is non-transitive,
gcc-bugzilla at gcc dot gnu dot org <=