RFR: 8362637: Convert java.nio.ByteOrder to an enum
Chen Liang
liach at openjdk.org
Tue Oct 7 12:40:43 UTC 2025
On Mon, 6 Oct 2025 18:21:26 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> Convert java.nio.ByteOrder to an enum.
> The class declaration is changed from `public class` to `public enum`.
> Enums are `Comparable` so declare LITTLE_ENDIAN before BIG_ENDIAN so LITTLE_ENDIAN is less than BIG_ENDIAN.
> The implementation is simplified, removing the constructor and explicit static fields.
> Remove the override of `toString`; the javadoc provided by Enum is sufficient.
>
> No changes to other classes or implementations are needed to pass Tier 1-3.
Thanks for this interesting interpretation, Alan. Looks good. Some bikeshedding attached.
src/java.base/share/classes/java/nio/ByteOrder.java line 38:
> 36: */
> 37:
> 38: public enum ByteOrder {
Suggestion:
public enum ByteOrder {
src/java.base/share/classes/java/nio/ByteOrder.java line 45:
> 43: */
> 44: LITTLE_ENDIAN,
> 45: /**
Suggestion:
LITTLE_ENDIAN,
/**
-------------
Marked as reviewed by liach (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/27657#pullrequestreview-3309910954
PR Review Comment: https://git.openjdk.org/jdk/pull/27657#discussion_r2410481352
PR Review Comment: https://git.openjdk.org/jdk/pull/27657#discussion_r2410483570
More information about the nio-dev
mailing list