-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8253640: Make MEMFLAGS an enum class #378
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
8253640: Make MEMFLAGS an enum class #378
Conversation
👋 Welcome back stefank! A progress list of the required criteria for merging this PR into |
Webrevs
|
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.
Hi Stefan,
I was just looking this morning at this enum and wished it were a class. This will make reworking the reservation APIs less error prone.
Found some small nits, but leave it up to you if you change anything.
(For some reason I always believed that using enum class would prevent us from using sentinel values but for the life of me I cannot remember why I thought this...)
Thanks, Thomas
return index >= 0 && index < mt_number_of_types; | ||
} | ||
|
||
// Check if flag value is a valid MEMFLAGS enum value |
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.
Small nit, can you please clarify that this includes "mtNone"?
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.
Good point!
@@ -151,14 +151,20 @@ class AllocatedObj { | |||
/* | |||
* Memory types | |||
*/ | |||
enum MemoryType { | |||
enum class MEMFLAGS { |
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.
Remark (possible for a later change): As you wrote, I think using uint8 would be okay and safer here.
@stefank 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 more 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 5 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
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.
lgtm
Thanks! |
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.
Lgtm.
Thanks, Thomas! |
/integrate |
@stefank Since your change was applied there have been 24 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 3ed960e. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
I'd like to propose that we make MEMFLAGS an enum class, to prevent them from being implicitly converted to integers.
I've been refactoring code that uses MEMFLAGS and have found that the functions often take integers and/or use default values. Because of this the compiler won't always tell you if you mess up the order. If we make the MEMFLAGS more type safe, the compiler will complain immediately if you send in the arguments in the wrong order.
Changes in the patch:
Notes:
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/378/head:pull/378
$ git checkout pull/378