Skip to content

8373668: Add override keyword to *Klass classes#28820

Closed
xmas92 wants to merge 2 commits intoopenjdk:masterfrom
xmas92:JDK-8373668
Closed

8373668: Add override keyword to *Klass classes#28820
xmas92 wants to merge 2 commits intoopenjdk:masterfrom
xmas92:JDK-8373668

Conversation

@xmas92
Copy link
Member

@xmas92 xmas92 commented Dec 15, 2025

Using override provides better visibility and compiler support for suspicious virtual methods. It makes it clears when reading a class header file if a new virtual interface is introduced or if it simply overridden.

Testing

  • GHA
  • Running tier1 on Oracle supported platforms

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-8373668: Add override keyword to *Klass classes (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28820

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 15, 2025

👋 Welcome back aboldtch! 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 Dec 15, 2025

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

8373668: Add override keyword to *Klass classes

Reviewed-by: jwaters, dholmes, kbarrett, tschatzl

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:

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 hotspot hotspot-dev@openjdk.org label Dec 15, 2025
@openjdk
Copy link

openjdk bot commented Dec 15, 2025

@xmas92 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 Dec 15, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 15, 2025

Webrevs

Copy link

@kimbarrett kimbarrett 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.

A couple of pre-existing whitespace issues that you can fix or ignore.

I wonder if there would be any measurable benefit to using final instead in some
cases? But that should be looked at separately. It might be simpler to declare some
classes to be final.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 15, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Dec 15, 2025
@xmas92
Copy link
Member Author

xmas92 commented Dec 15, 2025

I wonder if there would be any measurable benefit to using final instead in some
cases? But that should be looked at separately. It might be simpler to declare some
classes to be final.

I know that I experimented with this at some point for the oop iterator. The result then was that it was not a reliable way to guarantee de-virtualisation. I also remember reading some blog post somewhere which explored different compilers and the benefits of final. I think it ultimately was not reliable enough to replace doing hand rolling things for where it matters, but got some improvements in some cases. However this was a few years ago so things might have improved.

Regardless of performance improvements, I think the final keyword makes the intended inheritance more clear and would be a worthwhile future RFE.

Copy link
Contributor

@TheShermanTanker TheShermanTanker left a comment

Choose a reason for hiding this comment

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

+1 for use of helpful C++ features!

Copy link
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.

This all seems reasonable. I hope an IDE assisted with determining where override was needed, and virtual was not.

I think it would be good to see things marked final in the future as well.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 16, 2025
@xmas92
Copy link
Member Author

xmas92 commented Dec 16, 2025

Thanks for the reviews. (Rebuilt with latest master merged locally.)
/integrate

@openjdk
Copy link

openjdk bot commented Dec 16, 2025

Going to push as commit 78c2d57.
Since your change was applied there have been 13 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 16, 2025

@xmas92 Pushed as commit 78c2d57.

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

@xmas92 xmas92 deleted the JDK-8373668 branch January 5, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Development

Successfully merging this pull request may close these issues.

5 participants