-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
base: master
Are you sure you want to change the base?
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 |
❗ This change is not yet ready to be integrated. |
@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.
Convert java.nio.ByteOrder to an enum.
The class declaration is changed from
public class
topublic 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
Issues
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