Skip to content
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

8268764: Use Long.hashCode() instead of int-cast where applicable #4491

Closed
wants to merge 4 commits into from

Conversation

@stsypanov
Copy link
Contributor

@stsypanov stsypanov commented Jun 15, 2021

In some JDK classes there's still the following hashCode() implementation:

long objNum;

public int hashCode() {
    return (int) objNum;
}

This outdated expression should be replaced with Long.hashCode(long) as it

  • uses all bits of the original value, does not discard any information upfront. For example, depending on how you are generating the IDs, the upper bits could change more frequently (or the opposite).

  • does not introduce any bias towards values with more ones (zeros), as it would be the case if the two halves were combined with an OR (AND) operation.

See https://stackoverflow.com/a/4045083

This is related to #4309


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8268764: Use Long.hashCode() instead of int-cast where applicable

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4491/head:pull/4491
$ git checkout pull/4491

Update a local copy of the PR:
$ git checkout pull/4491
$ git pull https://git.openjdk.java.net/jdk pull/4491/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4491

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4491.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jun 15, 2021

👋 Welcome back stsypanov! 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 openjdk bot added the rfr label Jun 15, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 15, 2021

@stsypanov The following labels will be automatically applied to this pull request:

  • 2d
  • core-libs
  • hotspot-compiler
  • security
  • serviceability
  • sound

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

@mlbridge
Copy link

@mlbridge mlbridge bot commented Jun 15, 2021

@kevinjwalls
Copy link

@kevinjwalls kevinjwalls commented Jun 30, 2021

The changes look good to me, we have done the same thing elsewhere. This changes things in different functional areas, which is maybe unusual, but seems fine for a small change as long as nobody objects.

Some of the files also need a (C) year update.

@stsypanov
Copy link
Contributor Author

@stsypanov stsypanov commented Jul 1, 2021

Hi Kevin, thanks for review! I've updated copy-right year

@kevinjwalls
Copy link

@kevinjwalls kevinjwalls commented Jul 1, 2021

OK, one more (C) in src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java and done. 8-)
Needs a second Review before integrating, thanks.

@stsypanov
Copy link
Contributor Author

@stsypanov stsypanov commented Jul 1, 2021

Right, done!

@stsypanov
Copy link
Contributor Author

@stsypanov stsypanov commented Jul 1, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Jul 1, 2021

@stsypanov This PR has not yet been marked as ready for integration.

prrace
prrace approved these changes Jul 21, 2021
Copy link
Contributor

@prrace prrace left a comment

Speaking only to the media classes in the desktop module (you'll need approval from others for the other cases),
I can't think of any actual problem this will create, but honestly I can't see any actual value in it either.

@openjdk
Copy link

@openjdk openjdk bot commented Jul 21, 2021

⚠️ @stsypanov the full name on your profile does not match the author name in this pull requests' HEAD commit. If this pull request gets integrated then the author name from this pull requests' HEAD commit will be used for the resulting commit. If you wish to push a new commit with a different author name, then please run the following commands in a local repository of your personal fork:

$ git checkout 8268764
$ git commit -c user.name='Preferred Full Name' --allow-empty -m 'Update full name'
$ git push

@openjdk
Copy link

@openjdk openjdk bot commented Jul 21, 2021

@stsypanov 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:

8268764: Use Long.hashCode() instead of int-cast where applicable

Reviewed-by: kevinw, prr, kizune, serb

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 1209 new commits pushed to the master branch:

  • a5f09d1: 8275031: runtime/ErrorHandling/MachCodeFramesInErrorFile.java fails when hsdis is present
  • ef0922e: 8274560: JFR: Add test for OldObjectSample event when using Shenandoah
  • 1e30695: 8274466: G1: use field directly rather than method in G1CollectorState::in_mixed_phase
  • dd93c6e: 8272167: AbsPathsInImage.java should skip *.dSYM directories
  • 829dea4: 8274945: Cleanup unnecessary calls to Throwable.initCause() in java.desktop
  • 75f5145: 8274925: Shenandoah: shenandoah/TestAllocHumongousFragment.java test failed on lock rank check
  • 83c3771: 8273881: Metaspace: test repeated deallocations
  • 3f01d03: 8275021: Test serviceability/sa/TestJmapCore.java fails with: java.io.IOException: Stack frame 0x4 not found
  • 3f07337: 8273614: Shenandoah: intermittent timeout with ConcurrentGCBreakpoint tests
  • 0d80f6c: 8274379: Allow process of unsafe access errors in check_special_condition_for_native_trans
  • ... and 1199 more: https://git.openjdk.java.net/jdk/compare/a0f32cb1406e4957e84befd9b68444adb662bd13...master

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 (@kevinjwalls, @prrace, @azuev-java, @mrserb) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready label Jul 21, 2021
@prrace
Copy link
Contributor

@prrace prrace commented Jul 21, 2021

/reviewers 3

@openjdk
Copy link

@openjdk openjdk bot commented Jul 21, 2021

@prrace
The number of required reviews for this PR is now set to 3 (with at least 1 of role reviewers).

@openjdk openjdk bot removed the ready label Jul 21, 2021
@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Aug 19, 2021

@stsypanov 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!

@stsypanov
Copy link
Contributor Author

@stsypanov stsypanov commented Aug 19, 2021

Let's wait, bridgekeeper.

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Sep 16, 2021

@stsypanov 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!

@stsypanov
Copy link
Contributor Author

@stsypanov stsypanov commented Sep 16, 2021

Let's wait, bridgekeeper.

@openjdk openjdk bot added the ready label Sep 21, 2021
@stsypanov
Copy link
Contributor Author

@stsypanov stsypanov commented Sep 21, 2021

/integrate

@openjdk openjdk bot added the sponsor label Sep 21, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Sep 21, 2021

@stsypanov
Your change (at version 20ad76b) is now ready to be sponsored by a Committer.

mrserb
mrserb approved these changes Oct 12, 2021
@mrserb
Copy link
Member

@mrserb mrserb commented Oct 12, 2021

/sponsor

@openjdk
Copy link

@openjdk openjdk bot commented Oct 12, 2021

Going to push as commit 124f823.
Since your change was applied there have been 1223 commits pushed to the master branch:

  • 8657f77: 8271514: support JFR use of new ThreadsList::Iterator
  • b8bd259: 8271737: Only normalize the cached user.dir property once
  • 89999f7: 8275131: Exceptions after a touchpad gesture on macOS
  • 07b1f1c: 8274548: (fc) FileChannel gathering write fails with IOException "Invalid argument" on macOS 11.6
  • f623460: 8274911: testlibrary_tests/ir_framework/tests/TestIRMatching.java fails with "java.lang.RuntimeException: Should have thrown exception"
  • e393c5e: 8275074: Cleanup unused code in JFR LeakProfiler
  • e16b93a: 8274770: [PPC64] resolve_jobject needs a generic implementation to support load barriers
  • 1ab6414: 8275051: Shenandoah: Correct ordering of requested gc cause and gc request flag
  • b460d6d: 8275091: /src/jdk.management.jfr/share/classes/module-info.java has non-canonical order
  • d04d4ee: 8274894: Use Optional.empty() instead of ofNullable(null) in HttpResponse.BodySubscribers.discarding
  • ... and 1213 more: https://git.openjdk.java.net/jdk/compare/a0f32cb1406e4957e84befd9b68444adb662bd13...master

Your commit was automatically rebased without conflicts.

@openjdk
Copy link

@openjdk openjdk bot commented Oct 12, 2021

@mrserb @stsypanov Pushed as commit 124f823.

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

@stsypanov stsypanov deleted the 8268764 branch Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment