Skip to content

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 boolean validate parameter 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 worthwhile to check whether that calculation is needed.
  • 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).

¹ 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

Issues

  • JDK-8344159: Add lint warnings for unnecessary warning suppression (Enhancement - P4)
  • JDK-6723459: Compiler should 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 the merge-conflict Pull request has merge conflict with target branch label Aug 6, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Aug 11, 2025
@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Aug 14, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Aug 20, 2025
@archiecobbs
Copy link
Contributor Author

/touch

@openjdk
Copy link

openjdk bot commented Aug 30, 2025

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

@archiecobbs
Copy link
Contributor Author

/label remove hotspot-jfr

@openjdk
Copy link

openjdk bot commented Aug 30, 2025

@archiecobbs
The hotspot-jfr label was successfully removed.

@archiecobbs
Copy link
Contributor Author

/label remove kulla

@openjdk
Copy link

openjdk bot commented Aug 30, 2025

@archiecobbs
The label kulla is not a valid label.
These labels are valid:

  • graal
  • serviceability
  • hotspot
  • hotspot-compiler
  • ide-support
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • hotspot-runtime
  • jmx
  • build
  • nio
  • client
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr

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