RFR 8154556: Use java.nio.ByteOrder instead of boolean value
Alan Bateman
Alan.Bateman at oracle.com
Thu Apr 21 18:46:58 UTC 2016
On 21/04/2016 17:01, Paul Sandoz wrote:
> :
> I blindly copied the same behaviour from ByteBuffer.order:
>
> /**
> * Modifies this buffer's byte order.
> *
> * @param bo
> * The new byte order,
> * either {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}
> * or {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN}
> *
> * @return This buffer
> */
> public final ByteBuffer order(ByteOrder bo) {
> bigEndian = (bo == ByteOrder.BIG_ENDIAN);
> nativeByteOrder =
> (bigEndian == (Bits.byteOrder() == ByteOrder.BIG_ENDIAN));
> return this;
> }
>
> Was that behaviour intentional or an oversight? I am assuming the latter as it’s ambiguous what should happen if a third value, null, is passed.
I would assume so too.
>
> I updated the webrev in place to throw an NPE.
Okay.
>
>
>> BTW: Is there a reason for "throws IllegalArgumentException"? This an unchecked so I assume not needed there (the @throws in the javadoc should be sufficient).
>>
> I retained consistency with existing MH factory methods.
>
Okay although I assume it could be dropped elsewhere.
-Alan.
More information about the core-libs-dev
mailing list