RFR 9: 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
Brian Burkhalter
brian.burkhalter at oracle.com
Wed Dec 3 21:43:08 UTC 2014
Please review at your convenience.
Issue: https://bugs.openjdk.java.net/browse/JDK-8065570
Patch: http://cr.openjdk.java.net/~bpb/8065570/webrev.00/
One interesting thing not part of this patch is that the byte order of the ByteBuffer returned by ByteBuffer.asReadOnlyBuffer() is always BIG_ENDIAN, whereas that of the XBuffer returned by XBuffer.asReadOnlyBuffer() is the byte order of the original XBuffer. This seems inconsistent. For instance, this code sequence
ByteBuffer buf = ByteBuffer.allocate(256);
buf.order(ByteOrder.LITTLE_ENDIAN);
System.out.println(buf.asIntBuffer().asReadOnlyBuffer().order());
System.out.println(buf.asReadOnlyBuffer().asIntBuffer().order());
will print
LITTLE_ENDIAN
BIG_ENDIAN
Thanks,
Brian
More information about the nio-dev
mailing list