Skip to content

Conversation

@RogerRiggs
Copy link
Contributor

@RogerRiggs RogerRiggs commented Oct 6, 2025

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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8369130 to be approved

Issues

  • JDK-8362637: Convert java.nio.ByteOrder to an enum (Enhancement - P4)
  • JDK-8369130: Convert java.nio.ByteOrder to an enum (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27657/head:pull/27657
$ git checkout pull/27657

Update a local copy of the PR:
$ git checkout pull/27657
$ git pull https://git.openjdk.org/jdk.git pull/27657/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27657

View PR using the GUI difftool:
$ git pr show -t 27657

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27657.diff

Using Webrev

Link to Webrev Comment

Declare LITTLE_ENDIAN before BIG_ENDIAN so comparing enums 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.
@bridgekeeper
Copy link

bridgekeeper bot commented Oct 6, 2025

👋 Welcome back rriggs! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 6, 2025

@RogerRiggs This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8362637: Convert java.nio.ByteOrder to an enum

Reviewed-by: alanb, liach, bpb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 182 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added csr Pull request needs approved CSR before integration nio nio-dev@openjdk.org labels Oct 6, 2025
@openjdk
Copy link

openjdk bot commented Oct 6, 2025

@RogerRiggs The following label will be automatically applied to this pull request:

  • nio

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 6, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 6, 2025

Webrevs

@liach
Copy link
Member

liach commented Oct 6, 2025

Why do we reorder the BIG_ENDIAN and LITTLE_ENDIAN fields?

@AlanBateman
Copy link
Contributor

Why do we reorder the BIG_ENDIAN and LITTLE_ENDIAN fields?

enums are Comparable and giving LITTLE_ENDIAN the 0 ordinal means it is less than BIG_ENDIAN. I don't think byte orders will be compared too often but it does avoid a surprise.

Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this interesting interpretation, Alan. Looks good. Some bikeshedding attached.

public static final ByteOrder BIG_ENDIAN
= new ByteOrder("BIG_ENDIAN");

public enum ByteOrder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public enum ByteOrder {
public enum ByteOrder {

Comment on lines +44 to +45
LITTLE_ENDIAN,
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LITTLE_ENDIAN,
/**
LITTLE_ENDIAN,
/**

Copy link
Member

@bplb bplb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as well.

@wenshao
Copy link
Contributor

wenshao commented Oct 14, 2025

getIntB/getIntL/putIntB/putIntL/getLongB/getLongL/putLongL/getLongL If the optimizer can handle it, these methods should be provided in ByteOrder

@liach
Copy link
Member

liach commented Oct 14, 2025

I think we will do that later. A lot of these operations are used in early bootstrap when we don't want to set up everything enums use.

@RogerRiggs
Copy link
Contributor Author

ByteOrder is just an enum, the get and set methods suggested belong elsewhere. The optimizer can do the right thing relative to the enum regardless of where they are implemented.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Oct 16, 2025
@RogerRiggs
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Oct 16, 2025

Going to push as commit 95380e1.
Since your change was applied there have been 200 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 16, 2025
@openjdk openjdk bot closed this Oct 16, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 16, 2025
@openjdk
Copy link

openjdk bot commented Oct 16, 2025

@RogerRiggs Pushed as commit 95380e1.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated nio nio-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

5 participants