Skip to content

8381238: Remove tautological uses of checked_cast#30482

Open
kimbarrett wants to merge 1 commit intoopenjdk:masterfrom
kimbarrett:remove-tautological-checked-cast
Open

8381238: Remove tautological uses of checked_cast#30482
kimbarrett wants to merge 1 commit intoopenjdk:masterfrom
kimbarrett:remove-tautological-checked-cast

Conversation

@kimbarrett
Copy link
Copy Markdown

@kimbarrett kimbarrett commented Mar 28, 2026

Please review this change that removes uses of checked_cast that are
unnecessary because they are tautological.

These were discovered by locally changing checked_cast to use the new
integer_cast for integral conversions, and noting which calls failed to
compile because of the anti-tautology check in the latter.

Testing: mach5 tier1


Progress

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

Errors

 ⚠️ OCA signatory status must be verified
 ⚠️ Pull request body is missing required line: - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).

Issue

  • JDK-8381238: Remove tautological uses of checked_cast (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30482

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Mar 28, 2026

👋 Welcome back kbarrett! 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
Copy Markdown

openjdk bot commented Mar 28, 2026

@kimbarrett This change is no longer ready for integration - check the PR body for details.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Mar 28, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 28, 2026

@kimbarrett The following label will be automatically applied to this pull request:

  • hotspot

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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 28, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Mar 28, 2026

Webrevs

Copy link
Copy Markdown
Contributor

@mhaessig mhaessig left a comment

Choose a reason for hiding this comment

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

Thank you for fixing these, @kimbarrett. This looks good.

Copy link
Copy Markdown
Member

@dholmes-ora dholmes-ora 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 to me. But one does have to wonder why such casts were used in the first place.

stream->write_int(value());
if(is_callee_saved() || is_derived_oop()) {
stream->write_int(checked_cast<int>(content_reg()->value()));
stream->write_int(content_reg()->value());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this was put in by JDK-8309685 to apparently suppress a conversion warning (though I can't see how a function typed as int could possibly cause such a warning ???). Was that change in error or have the warnings changed since then?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some of these checks make the code safe when the types of code elsewhere change. Just because something is a 32-bit type today doesn't tell us it always will be.

Copy link
Copy Markdown
Author

@kimbarrett kimbarrett Mar 30, 2026

Choose a reason for hiding this comment

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

Hi @kimbarrett, thanks for making a comment in an OpenJDK project!

All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user kimbarrett" for the summary.

If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.

Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm I was wrong above - it seems stream->write_int takes a juint so do we not need the cast for the signed-to-unsigned conversion?

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 30, 2026
@bridgekeeper bridgekeeper bot added the oca Needs verification of OCA signatory status label Apr 1, 2026
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 1, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 16, 2026

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot. This can be overridden with the /reviewers command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot hotspot-dev@openjdk.org oca Needs verification of OCA signatory status

Development

Successfully merging this pull request may close these issues.

5 participants