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

8274835: Remove unnecessary castings in java.base #5454

Conversation

turbanoff
Copy link
Member

@turbanoff turbanoff commented Sep 9, 2021

Redundant castings make code harder to read.
Found them by IntelliJ IDEA.
I tried to select only casts which are definitely safe to remove. Also didn't touch primitive types casts.


Progress

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

Issue

  • JDK-8274835: Remove unnecessary castings in java.base

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5454

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

Using diff file

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

Redundant castings make code harder to read
@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Sep 9, 2021

👋 Welcome back turbanoff! 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
Copy link

@openjdk openjdk bot commented Sep 9, 2021

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

  • core-libs
  • i18n
  • net
  • security

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.

@openjdk openjdk bot added security core-libs net i18n labels Sep 9, 2021
adjust comment to the actual state
@turbanoff turbanoff changed the title [PATCH] Remove unnecessary castings in java.base 8274835: Remove unnecessary castings in java.base Oct 6, 2021
@openjdk openjdk bot added the rfr label Oct 6, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 6, 2021

Webrevs

Copy link
Member

@seanjmullan seanjmullan left a comment

The security related files look fine.

@openjdk
Copy link

@openjdk openjdk bot commented Oct 6, 2021

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

8274835: Remove unnecessary castings in java.base

Reviewed-by: mullan, naoto, lancea, bpb

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

  • 124f823: 8268764: Use Long.hashCode() instead of int-cast where applicable
  • 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
  • ... and 398 more: https://git.openjdk.java.net/jdk/compare/96614da0254e7fd4ac9dd3c3059bf23c1aaf37ff...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 (@seanjmullan, @naotoj, @LanceAndersen, @bplb) 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 Oct 6, 2021
naotoj
naotoj approved these changes Oct 6, 2021
Copy link
Member

@naotoj naotoj left a comment

Calendar-related changes look good to me.

@jddarcy
Copy link
Member

@jddarcy jddarcy commented Oct 6, 2021

Curious. The JDK build is done with javac -Xlint:cast warning enabled (JDK-8032734) which is intended to catch issues like this. Perhaps IntelliJ is using a different (or sharper) analysis.

bplb
bplb approved these changes Oct 6, 2021
Copy link
Member

@bplb bplb left a comment

java.io change looks all right.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 7, 2021

Mailing list message from Tagir Valeev on core-libs-dev:

On Thu, Oct 7, 2021 at 12:15 AM Joe Darcy <darcy at openjdk.java.net> wrote:

Curious. The JDK build is done with javac -Xlint:cast warning enabled (JDK-8032734) which is intended to catch issues like this. Perhaps IntelliJ is using a different (or sharper) analysis.

Yes, our analysis is written independently of Javac (mostly by Anna
Kozlova) and we had a long history of false-positives/false-negatives
in this inspection, so it was tuned many times. It's not nearly
simple. For now, it's turned on for the whole IntelliJ IDEA Ultimate
repository (a warning causes the CI build to fail). I've found only
five explicit suppressions in our codebase. Not sure if all of them
are still necessary.

@turbanoff
Copy link
Member Author

@turbanoff turbanoff commented Oct 12, 2021

/integrate

@openjdk openjdk bot added the sponsor label Oct 12, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 12, 2021

@turbanoff
Your change (at version 70345f0) is now ready to be sponsored by a Committer.

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Nov 10, 2021

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

@dfuch
Copy link
Member

@dfuch dfuch commented Nov 12, 2021

/sponsor

@openjdk
Copy link

@openjdk openjdk bot commented Nov 12, 2021

Going to push as commit 5a2452c.
Since your change was applied there have been 822 commits pushed to the master branch:

  • 3b2585c: 8276658: Clean up JNI local handles code
  • aeba653: 8276743: Make openjdk build Zip Archive generation "reproducible"
  • 51a5731: 8277016: Use blessed modifier order in jdk.httpserver
  • c4b4432: 8277012: Use blessed modifier order in src/utils
  • 13deb38: 8276848: sun.net.httpserver.simpleserver.CommandLinePositiveTest: test does not specify port
  • 710f496: 8273277: C2: Move conditional negation into rc_predicate
  • 6b833db: 8275329: ZGC: vmTestbase/gc/gctests/SoftReference/soft004/soft004.java fails with assert(_phases->length() <= 1000) failed: Too many recored phases?
  • 1e941de: 8275197: Remove unused fields in ThaiBuddhistChronology
  • 6954b98: 8186670: Implement _onSpinWait() intrinsic for AArch64
  • 3445e50: 8276265: jcmd man page is outdated
  • ... and 812 more: https://git.openjdk.java.net/jdk/compare/96614da0254e7fd4ac9dd3c3059bf23c1aaf37ff...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Nov 12, 2021
@openjdk openjdk bot added integrated and removed ready rfr sponsor labels Nov 12, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Nov 12, 2021

@dfuch @turbanoff Pushed as commit 5a2452c.

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

@turbanoff turbanoff deleted the remove-unnecessary-castings-in-java.base branch Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs i18n integrated net security
7 participants