RFR: 8344159: Add lint warnings for unnecessary warning suppression

Archie Cobbs acobbs at openjdk.org
Tue Sep 23 21:52:26 UTC 2025


On Tue, 23 Sep 2025 21:25:26 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

> The reason I ask is that I can probably see how it could be useful to emit a "suppression" warning from this:

It's a reasonable option to consider. I think the main worry is that it could complicate build situations where the same code was being compiled with `-Werror` under two different compiler versions. Suppose you had code like this:

method m() {
   // warning here
}

that generated a `"foo"` warning in JDK N but not JDK M. So you do this:

@SuppressWarnings("foo")
method m() {
  // warning here
}

OK, now you get a `"suppression"` warning in JDK M but not JDK N. So next you do this:

@SuppressWarnings({ "foo", "suppression" })
method m() {
  // warning here
}

Oops! Now you get a `"suppression"` warning in JDK N.

Then the only way out would be `-Xlint:-suppression`, which means the feature has caused a wild goose chase and is being somewhat self-defeating.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/25167#issuecomment-3325659614


More information about the serviceability-dev mailing list