Skip to content

8344159: Add lint warnings for unnecessary warning suppression #25167

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

Draft
wants to merge 70 commits into
base: master
Choose a base branch
from

Conversation

archiecobbs
Copy link
Contributor

@archiecobbs archiecobbs commented May 10, 2025

This PR adds support for warning about @SuppressWarnings annotations that are unnecessary because they don't actually suppress any warnings.

The JDK itself contains 400+ instances of unnecessary @SuppressWarnings annotations. The relevant build files have been updated accordingly to include the -Xlint:-suppression compiler flag.

Summary of changes:

  • Add a new lint warning for @SuppressWarnings annotations that don't actually suppress any warnings and a new lint category suppression that includes it (default disabled)
  • Update Log.warning() to automatically validate any current suppression of the warning's lint category
  • Update Lint.isEnabled() and Lint.isSuppressed() with parameter boolean validate to optionally also validate any applicable suppression
  • Add method Lint.isActive() to test whether a category is enabled or suppression of the category is being tracked
  • Update singleton LintMapper to keep track of which suppressions are validated and (later) warn about those that never are
  • Update *.gmk build files to suppress suppression warnings so that building with -Werror still works

Prerequisites to this PR:


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
  • Change requires CSR request JDK-8356043 to be approved

Warning

 ⚠️ Found leading lowercase letter in issue title for 6723459: javac to flag where warning suppression is not required

Issues

  • JDK-8344159: Add lint warnings for unnecessary warning suppression (Enhancement - P4)
  • JDK-6723459: javac to flag where warning suppression is not required (Enhancement - P3)
  • JDK-8356043: Add lint warnings for unnecessary warning suppression (CSR)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25167

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

Using diff file

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

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org build build-dev@openjdk.org client client-libs-dev@openjdk.org core-libs core-libs-dev@openjdk.org compiler compiler-dev@openjdk.org labels May 10, 2025
@openjdk openjdk bot added kulla kulla-dev@openjdk.org hotspot-jfr hotspot-jfr-dev@openjdk.org labels May 10, 2025
@openjdk
Copy link

openjdk bot commented Jun 5, 2025

@archiecobbs this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8344159
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Jun 5, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build-dev@openjdk.org client client-libs-dev@openjdk.org compiler compiler-dev@openjdk.org core-libs core-libs-dev@openjdk.org csr Pull request needs approved CSR before integration hotspot-jfr hotspot-jfr-dev@openjdk.org kulla kulla-dev@openjdk.org serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

1 participant