RFR: 8344159: Add lint warnings for unnecessary warning suppression
Archie Cobbs
acobbs at openjdk.org
Wed Sep 24 15:02:02 UTC 2025
On Tue, 23 Sep 2025 22:26:08 GMT, Pavel Rappo <prappo at openjdk.org> wrote:
> Thanks for this explanation. I can now see what you mean in the _Different Compiler Versions_ section of the CSR. That's some quality reasoning and future-proofing.
Credit goes to @jddarcy for pinpointing those possible traps.
> I suppose, it would unnecessarily complicate the design if we stipulate that `@SuppressWarnings("suppression")` should only emit a warning if there are no `@SuppressWarnings` in any of the _child scopes_. Note, not just ineffective `@SuppressWarnings`s, but none at all.
Here's an analogy that helps me justify the current design, fwiw. Have you ever been to New York or another city and walked by an otherwise completely blank wall that has "POST NO BILLS" signs stuck to it, and then thought about how ironic it is that posting bills is required in order to notify people not to post bills?
Sticking `@SuppressWarnings("suppression")` on a declaration is analogous. We're posting a notification not to do something, even though the notification itself risks doing it. But that's OK and we make a special exception for it.
If we didn't make such exceptions, then when you walked by such a wall you'd see a workman repeatedly posting and unposting the "POST NO BILLS" bills :)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25167#issuecomment-3329111827
More information about the serviceability-dev
mailing list