Skip to content

Conversation

@turbanoff
Copy link
Member

@turbanoff turbanoff commented Sep 15, 2022

Redundant castings make code harder to read.
Found them by IntelliJ IDEA.
I tried to choose only casts which are definitely safe to remove.
Most generification was done in JDK-8241618, but casts weren't removed.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8293879: Remove unnecessary castings in jdk.hotspot.agent

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10295/head:pull/10295
$ git checkout pull/10295

Update a local copy of the PR:
$ git checkout pull/10295
$ git pull https://git.openjdk.org/jdk pull/10295/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10295

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10295.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 15, 2022

👋 Welcome back aturbanov! 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 bot commented Sep 15, 2022

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

  • hotspot-gc
  • serviceability

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 serviceability serviceability-dev@openjdk.org hotspot-gc hotspot-gc-dev@openjdk.org labels Sep 15, 2022
@turbanoff turbanoff changed the title [PATCH] Remove unnecessary castings in jdk.hotspot.agent 8293879: Remove unnecessary castings in jdk.hotspot.agent Sep 15, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 15, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 15, 2022

Webrevs

@openjdk
Copy link

openjdk bot commented Sep 15, 2022

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

8293879: Remove unnecessary castings in jdk.hotspot.agent

Reviewed-by: lmesnik, cjplummer

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

  • 9a40b76: 8293842: IPv6-only systems throws UnsupportedOperationException for several socket/TCP options
  • bb9aa4e: 8293813: ProblemList com/sun/jdi/JdbLastErrorTest.java on windows-x64 in Xcomp mode
  • 4cec141: 8291509: Minor cleanup could be done in sun.security
  • 6beeb84: 8293875: ProblemList sun/management/jmxremote/bootstrap/RmiBootstrapTest.java#id1 on linux-x64
  • bf79f99: 8292989: Avoid dynamic memory in AsyncLogWriter
  • 2028ec7: 8289608: Change com/sun/jdi tests to not use Thread.suspend/resume
  • ecb456a: 8293779: redundant checking in AESCrypt.makeSessionKey() method
  • 6fca9ae: 8288474: Move EventContinuationFreezeOld from try_freeze_fast to freeze_slow
  • fbd8b42: 8293591: Remove use of Thread.stop from jshell tests
  • aff5ff1: 8244681: Add a warning for possibly lossy conversion in compound assignments
  • ... and 2 more: https://git.openjdk.org/jdk/compare/8f3bbe950fb5a3d9f6cae122209df01df0f342f0...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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 15, 2022
Copy link
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Nice cleanup.

It looks like a lot of these got introduced by JDK-8241618, which says:

I started to address the unchecked warnings. Unfortunately, this was a much bigger task than I anticipated. I had to generify most of the module.

So I guess with the new use of generics in place, the existing casts became unnecessary.

Comment on lines +130 to +134
return VMObjectFactory.newObject(GenerationSpec.class,
youngGenSpecField.getAddress());
} else {
return (GenerationSpec)
VMObjectFactory.newObject(GenerationSpec.class,
oldGenSpecField.getAddress());
return VMObjectFactory.newObject(GenerationSpec.class,
oldGenSpecField.getAddress());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make each of these one line instead of two.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other lines in this file don't exceed 80 chars. So, I think it's better to preserver line break here.

@turbanoff
Copy link
Member Author

Thank you for review!
/integrate

@openjdk
Copy link

openjdk bot commented Sep 19, 2022

Going to push as commit 5725a93.
Since your change was applied there have been 40 commits pushed to the master branch:

  • ab7f58a: 6286501: JTabbedPane throws NPE from its stateChanged listener in particular case
  • d41f69f: 8293849: PrintIdealPhase in compiler directives file is ignored when used with other compile commands
  • 471e2f1: 8292088: C2: assert(is_OuterStripMinedLoop()) failed: invalid node class: IfTrue
  • a93cf92: 8293920: G1: Add index based heap region iteration
  • 36c9034: 8293808: mscapi destroyKeyContainer enhance KeyStoreException: Access is denied exception
  • cbd0688: 8293851: hs_err should print more stack in hex dump
  • 04d7b7d: 8293503: gc/metaspace/TestMetaspacePerfCounters.java#Epsilon-64 failed assertGreaterThanOrEqual: expected MMM >= NNN
  • d77c464: 8293891: gc/g1/mixedgc/TestOldGenCollectionUsage.java (still) assumes that GCs take 1ms minimum
  • d7c1a76: 8293861: G1: Disable preventive GCs by default
  • 43f7f47: 8293499: Provide jmod --compress option
  • ... and 30 more: https://git.openjdk.org/jdk/compare/8f3bbe950fb5a3d9f6cae122209df01df0f342f0...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 19, 2022
@openjdk openjdk bot closed this Sep 19, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 19, 2022
@openjdk
Copy link

openjdk bot commented Sep 19, 2022

@turbanoff Pushed as commit 5725a93.

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

@turbanoff turbanoff deleted the redundant_casts_jdk.hotspot.agent branch October 27, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

3 participants