DoubleBuffer.compareTo is not anti-symmetric

Mark Thornton mthornton at optrak.co.uk
Fri Nov 20 11:46:39 PST 2009


Martin Buchholz wrote:
> This is a bug report.
>
> import java.nio.*;
>
> public class BufferCompare {
>     public static void main(String[] args) {
>         DoubleBuffer b1 = DoubleBuffer.wrap(new double[] { Double.NaN });
>         DoubleBuffer b2 = DoubleBuffer.wrap(new double[] { 1.0 });
>         System.out.printf("%b%n", b1.compareTo(b2));
>         System.out.printf("%b%n", b2.compareTo(b1));
>     }
> }
> ==> javac -source 1.6 -Xlint:all BufferCompare.java
> ==> java -esa -ea BufferCompare
> true
> true
>
Is the %b format specification really what you intended? Use %d instead!

Mark Thornton



More information about the nio-dev mailing list