RFR: 8348427: DeferredLintHandler API should use JCTree instead of DiagnosticPosition [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Feb 6 22:13:12 UTC 2025


On Thu, 6 Feb 2025 22:03:27 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> > > learn a little bit more about this. It looks like the only time immediate mode is used explicitly (i.e., other due to `DeferredLintHandler`'s default state) is when resolving imports ([here](https://github.com/openjdk/jdk/blob/89e5e7ab73472b7d02aac5b8b0c7e9f26db6ec32/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java#L368)). In that case, of course, there can be no enclosing `@SuppressWarnings` so that makes sense.
> > 
> > 
> > Can we use a similar "flush" strategy ? E.g. make the warnings be part of an import declaration, and then process them as part of a flush? While it's good that you knocked one of the two usages off -- it's a bit sad to have this machinery "just" for one case.
> > Separately, I wonder if warnings issued from import statements should be suppressible as well (perhaps piggy backing on the toplevel class `@SuppressWarnings` uhmmm). It seems bad that there's some warnings that can't be suppressed programmatically.
> 
> I think it would be useful to understand which warnings can be generated during `resolveImports`. @jddarcy pointed me at:
> 
> https://openjdk.org/jeps/211
> 
> See related change:
> 
> https://hg.openjdk.org/jdk9/jdk9/langtools/rev/82384454947c
> 
> Where we explicitly disable deprecation warnings on import since 9. Is there any other?

If this was indeed the only possible case, there is a possible silver lining, because either warnings in imports are enabled (e.g. `--source 8`) in which case we can just report them immediately, as they can't be suppressed, or they are disabled (e.g. `--source >= 9`) in which case no warning should even be generated, period.

But I'm sure reality is more complex than that :-)

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

PR Comment: https://git.openjdk.org/jdk/pull/23281#issuecomment-2641172482


More information about the compiler-dev mailing list