-Xlint:unnecessary ?

Attila Kelemen attila.kelemen85 at gmail.com
Sat Oct 7 13:11:50 UTC 2023


I'm not an expert on lint by any means, but your proposed syntax is not
obvious to me, since we can already comma separate warnings to enable and
disable them separately. So, with the current syntax,
"-Xlint:foobar,unnecessary" would read as: Enable "foobar" warnings, Enable
"unnecessary" warnings. Maybe you meant to say that the definition of
"unnecessary" flag would be: Print warnings for unnecessary usage of
enabled warnings? That is not exactly "precise" though, because in that
case I can't say that "Don't report warnings for foobar, but report
unnecessary usage of it" (not that this would be terribly useful).

Only slightly related, but what I would like to see with -Xlint is a
selective "-Werror". That is, fail only on specific warnings, which I would
set to fail on every warning, but "deprecated" (because "deprecated"
warnings normally appear without you introducing the issue). In fact, my
specific pain is that I can't set error prone (or whatever else) to fail on
"rawtype", because they are saying it is the responsibility of javac, but
then I can't make javac fail on it unless I turn off "deprecated" warnings
(which I don't want to turn off).

Archie Cobbs <archie.cobbs at gmail.com> ezt írta (időpont: 2023. okt. 7.,
Szo, 0:41):

> I had an idea for a new lint warning and wanted to get feedback from those
> who understand the lint system better than me about the idea and whether
> this is feasible.
>
> The name of the new warning would be something like "unnecessary".
>
> The idea is that if you said -Xlint:foobar,unnecessary then you would get
> a warning for any unnecessary @SuppressWarnings("foobar") annotations,
> meaning, there are actually no warnings that need suppressing at that spot,
> and so the annotation is unnecessary and can be removed.
>
> The reason you would need to do -Xlint:foobar,unnecessary instead of just
> plain -Xlint:unnecessary to cover all of them is because in some cases if
> -Xlint:foobar is not specified then the logic for detecting foobar
> warnings is completely disabled, so it's not possible to know when the
> warning would or would not have fired. Also, this makes the control more
> precise.
>
> The benefit of this of course is it helps avoid accidental warning
> suppression (false negatives) by making it easier to minimize your
> suppression surface.
>
> I started trying to evaluate doing this, but am not completely
> understanding how lint and "deferred lint" interact.
>
> Is there a lint expert who can comment on whether this would be feasible
> given the way lint is currently implemented?
>
> Thanks,
> -Archie
>
> --
> Archie L. Cobbs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20231007/546de5c6/attachment.htm>


More information about the compiler-dev mailing list