Marco Trudel writes:
> Andrew Haley wrote:
> > Marco Trudel writes:
> > > Andrew Haley wrote:
> > >
> > > No. The point is that completely different objects might be passed
> > which
> > > have no relation with each other. A stupid example:
> > >
> > > Object[] o1 = { "22", "23", "24" };
> > > Object o2 = new java.awt.Button("2");
> > >
> > > And then the comparator does:
> > >
> > > public int compare(Object o1, Object o2)
> > > {
> > > String s1 = Integer.parseInt((String)o1);
> > > String s2 = ((Button)o2).getName();
> > > return s1.compareTo(s2);
> > > }
> >
> > Here is a quote from the definition of Comparable.compare:
> >
> > "The implementor must ensure that sgn(compare(x, y)) == -sgn(compare(y,
> > x))
> > for all x and y."
>
> Ah yeah, right... Actually I read that (just forgot it).
> Seems like the implementation of compare() is wrong. Funny thing is that
> this is in a Sun AWT class. So Sun doesn't even follow their own
> specifications ;-)
This is, of course, the delusion of Write Once, Run Anywhere. :-)
Once the Sun sources are freed, we'll be able to start pushing bug
fixes upstream for this stuff.
In the meantime, BTW, I have no objectio at all to making the change
to Classpath you sugested, not for correctness' sake, but for
compatibility. I just want to make sure we know *why* we're changing
something before we change it.
Andrew.