-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8362637: Convert java.nio.ByteOrder to an enum #27657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
👋 Welcome back rriggs! A progress list of the required criteria for merging this PR into |
|
@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: 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
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 |
|
@RogerRiggs The following label will be automatically applied to this pull request:
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. |
|
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. |
There was a problem hiding this 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public enum ByteOrder { | |
| public enum ByteOrder { |
| LITTLE_ENDIAN, | ||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| LITTLE_ENDIAN, | |
| /** | |
| LITTLE_ENDIAN, | |
| /** |
There was a problem hiding this 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.
|
getIntB/getIntL/putIntB/putIntL/getLongB/getLongL/putLongL/getLongL If the optimizer can handle it, these methods should be provided in ByteOrder |
|
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. |
|
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. |
|
/integrate |
|
Going to push as commit 95380e1.
Your commit was automatically rebased without conflicts. |
|
@RogerRiggs Pushed as commit 95380e1. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Convert java.nio.ByteOrder to an enum.
The class declaration is changed from
public classtopublic enum.Enums are
Comparableso 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
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27657/head:pull/27657$ git checkout pull/27657Update a local copy of the PR:
$ git checkout pull/27657$ git pull https://git.openjdk.org/jdk.git pull/27657/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27657View PR using the GUI difftool:
$ git pr show -t 27657Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27657.diff
Using Webrev
Link to Webrev Comment