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 112 commits into
base: master
Choose a base branch
from

Conversation

archiecobbs
Copy link
Contributor

@archiecobbs archiecobbs commented May 10, 2025

This PR adds a new Lint category "suppression" and associated warnings for @SuppressWarnings annotations that are unnecessary because they don't actually suppress any warnings.

Summary of changes:

  • Add a new lint category "suppression" (disabled by default) and an associated warning for @SuppressWarnings annotations that don't actually suppress any warnings.
  • Update the LintMapper to keep track of which @SuppressWarnings suppressions have been validated¹ and (later) generate warnings about those that never were.
  • Update Log.warning() so it automatically validates any current suppression of the warning's lint category in effect.
  • Augment Lint.isEnabled() and Lint.isSuppressed() with a new parameter boolean validate that specifies whether to also validate any current suppression.
  • Add new method Lint.isActive() to check whether a category is enabled or suppression of the category is being tracked - in other words, the calculation for the warning needs to be performed. This is used when the calculation of a warning is non-trivial making it worth checking whether it should be skipped.
  • Update *.gmk build files to add -Xlint:-suppression flags so that the build doesn't break (the JDK itself contains hundreds of unnecessary @SuppressWarnings annotations).

Prerequisites to this PR:

¹ The suppression of a lint category is "validated" as soon as it suppresses some warning in that category


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

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 5, 2025

@archiecobbs This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@archiecobbs
Copy link
Contributor Author

/touch

@openjdk
Copy link

openjdk bot commented Jul 5, 2025

@archiecobbs The pull request is being re-evaluated and the inactivity timeout has been reset.

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

Successfully merging this pull request may close these issues.

1 participant