-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
8284780: Need methods to create pre-sized HashSet and LinkedHashSet #8302
Conversation
👋 Welcome back XenoAmess! A progress list of the required criteria for merging this PR into |
@XenoAmess 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. |
Webrevs
|
Need to add apiNote documentation section to capacity-based constructors like for maps. |
/csr needed |
@dfuch has indicated that a compatibility and specification (CSR) request is needed for this pull request. |
@stuart-marks csr please |
@liach done. |
@XenoAmess This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@XenoAmess oops, sorry for the delay. I think it would be good to get these into 19 as companions to As before, I'd suggest reducing the number of changes to use sites in order to make review easier. I would suggest keeping the changes under src in java.base, java.net.http, java.rmi, and jdk.zipfs, and omitting all the other changes. Also keep the changes under test/jdk. There needs to be a test for these new methods. I haven't thought much how to do that. My first attempt would be to modify our favorite WhiteBoxResizeTest and add a bit of machinery that asserts the table length of the HashMap contained within the created HashSet/LinkedHashSet. I haven't looked at it though, so it might not work out, in which case you should pursue an alternative approach. I'll look at the specs and suggest updates as necessary and then handle filing of a CSR. |
Done.
Test added...I don't really know if the test be done in the way you want, but I think it could work. |
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.
I looked at all the use sites and they look fine. Some look like they could use additional cleanup, but that's probably beyond the scope of this change. (Also, I haven't seen StringTokenizer
in a long time....) It's amazing how many bugs there are -- the majority look like they allocated the HashSet with the wrong capacity! Again, this proves the worth of these new APIs.
That's some old code lingering in locale-related stuff. Will fix them after this PR gets integrated. |
Reviewers for i18n, net, nio, and security, please review call site changes in your areas. 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.
Reviewed i18n-related changes and they look good. One minor suggestion in Calendar
, but that can be applied later.
@XenoAmess 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 202 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@stuart-marks, @naotoj, @bplb, @dfuch, @ascarpino) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
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.
java.io
and java.nio
look all right.
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.
Changes to net
and http
look good.
@XenoAmess Please do not rebase or force-push to an active PR as it invalidates existing review comments. All changes will be squashed into a single commit automatically when integrating. See OpenJDK Developers’ Guide for more information. |
/integrate |
@XenoAmess |
Running tests and awaiting review from security team. Our internal test system is backlogged and tests might not complete in time to get into JDK 19. |
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.
I gave a quick look at the security files touched and seems straightforward. I didn't see any problems
/sponsor |
Going to push as commit e01cd7c.
Your commit was automatically rebased without conflicts. |
@stuart-marks @XenoAmess Pushed as commit e01cd7c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The HashSet(int) constructor accepts the capacity of the set rather than its size. Unfortunately, HashSet requires N/0.75 capacity to hold N elements. So, if we call new HashSet(n) to hold N elements, the map will be too small and need to be resized/rehashed midway. We add a new methods Sets.newHashSetWithExpectedSize and Sets.newLinkedHashSetWithExpectedSize that calculate the correct capacity for the specified expected size. See * https://bugs.openjdk.org/browse/JDK-8284975 * https://bugs.openjdk.org/browse/JDK-8287419 * openjdk/jdk#8302
The HashSet(int) constructor accepts the capacity of the set rather than its size. Unfortunately, HashSet requires N/0.75 capacity to hold N elements. So, if we call new HashSet(n) to hold N elements, the map will be too small and need to be resized/rehashed midway. We add a new methods Sets.newHashSetWithExpectedSize and Sets.newLinkedHashSetWithExpectedSize that calculate the correct capacity for the specified expected size. See * https://bugs.openjdk.org/browse/JDK-8284975 * https://bugs.openjdk.org/browse/JDK-8287419 * openjdk/jdk#8302 (cherry picked from commit 26c1d33)
The HashSet(int) constructor accepts the capacity of the set rather than its size. Unfortunately, HashSet requires N/0.75 capacity to hold N elements. So, if we call new HashSet(n) to hold N elements, the map will be too small and need to be resized/rehashed midway. We add a new methods Sets.newHashSetWithExpectedSize and Sets.newLinkedHashSetWithExpectedSize that calculate the correct capacity for the specified expected size. See * https://bugs.openjdk.org/browse/JDK-8284975 * https://bugs.openjdk.org/browse/JDK-8287419 * openjdk/jdk#8302 (cherry picked from commit 26c1d33)
I've filed JDK-8289872 for this. It's a small thing but best to fix it before we forget about it. |
Sorry for I already forgotten it. |
as title.
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8302/head:pull/8302
$ git checkout pull/8302
Update a local copy of the PR:
$ git checkout pull/8302
$ git pull https://git.openjdk.java.net/jdk pull/8302/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 8302
View PR using the GUI difftool:
$ git pr show -t 8302
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8302.diff