-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
base: master
Are you sure you want to change the base?
Conversation
I have removed kulla-dev from the bot configuration so the stuck label is now benign. |
|
Hi @archiecobbs , are there bugs filed to clean the causes of the warnings? |
Sounds good; I linked the umbrella issue for the earlier round of cleanup to this issue in JBS. My interest is getting back to at least a subset of modules, including java.base, compiling under "-Xlint:all -Werror" and it sounds like that is the plan as follow-up work after this PR goes in; thanks. |
magicus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build changes look fine.
|
Bumping up the reviewer count to ensure someone from the compiler group approves. /reviewers 3 |
|
@archiecobbs |
|
Hi Archie. I've just seen this PR. It looks nice. While I've read the CSR, I haven't read any compiler-dev thread(s). At least not carefully. I also haven't seen the diff. IIUC, this annotation can be applied to itself: |
FWIW there is a discussion thread (starting here), but it's been on/off since November 2024.
Astute question :) In general, it's completely up to the particular warning. The scope can even extend before the annotation; this is the case with Regarding exactly how "it's completely up to the particular warning": Since #26138, the |
The reason I ask is that I can probably see how it could be useful to emit a "suppression" warning from this: I'm not suggesting the PR should implement it, I'm just thinking aloud. I realise that if it were to implement the annotation as non-self-referring, then there would need to be a way to suppress it too, however silly it may sound. IIRC there's no way to apply a meta annotation on a call site. Even if Another option is to go one scope higher and put an annotation there: The problem is that you may not have a higher scope. Which sounds like a rare, uninteresting corner case. |
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 method m() {
// warning here
}that generated a OK, now you get a Oops! Now you get a Then the only way out would be |
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. I suppose, it would unnecessarily complicate the design if we stipulate that |
Credit goes to @jddarcy for pinpointing those possible traps.
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 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 :) |
That analogy is amusing, but it either barely applies here, or I'm too tired to see how it does. In my most recent message, I mused about this: what if Basically, if Just to clarify, here's an example of what I mean: Here's an example of what I don't mean: The idea here is to minimise the chance of |
Sorry I didn't address this question before - but yes, this is a reasonable ida. It would basically be adding an exception to the exception. So, a bit of additional complexity but for a worthwhile cause. To stretch the analogy, it would be like making the observation: "If the area of the wall is zero, then you never need to post a "POST NO BILLS" bill on it". I can think of one possible wrinkle though: warnings can actually be suppressed in the source code in two ways, by |
|
erikj79
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build changes still look good.
|
@archiecobbs This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
/touch |
|
@archiecobbs The pull request is being re-evaluated and the inactivity timeout has been reset. |
This PR adds a new compiler warning for
@SuppressWarningsannotations that don't actually suppress any warnings.Summary of code changes:
"suppression"LintMapperto keep track of which@SuppressWarningssuppressions have been validated ¹Log.warning()so it validates any current suppression of the warning's lint category in effect.validateparameter toLint.isEnabled()andLint.isSuppressed()that specifies whether to also validate any current suppression.Lint.isActive()to check whether a category is enabled or suppression of the category is being tracked - in other words, whether the warning calculation needs to be performed. Used for non-trivial warning calculations.-Xlint:-suppressionflags to*.gmkbuild files so the build doesn't break¹ The suppression of a lint category is "validated" as soon as it suppresses some warning in that category
Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25167/head:pull/25167$ git checkout pull/25167Update a local copy of the PR:
$ git checkout pull/25167$ git pull https://git.openjdk.org/jdk.git pull/25167/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25167View PR using the GUI difftool:
$ git pr show -t 25167Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25167.diff
Using Webrev
Link to Webrev Comment