eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Enhanced warning suppression
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
Via https://bugs.openjdk.org/browse/JDK-8356043 javac starts to report when `@SuppressWarnings` is unnecesary (which ecj does since 2008).
There are, however, a few interesting bits in this, which are worth considering for ecj:
* make the warning about unnecessary SW suppressable by saying `@SuppressWarnings("suppression")`
* if we want to further align warnings between javac and ecj we may refer to the following file to learn about details of warning categories: https://github.com/openjdk/jdk/blob/master/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
* for a list of javac warning categories I was pointed to https://docs.oracle.com/en/java/javase/25/docs/specs/man/javac.html#option-Xlint-custom
* alternatively, `javac --help-lint` should print the same
* would it be useful to add this list to ecj, so that instead of reporting `Unsupported @SuppressWarnings("this-escape")` we could just remain silent? If a token is in the list of javac's categories, it's less likely to be a simple typo.
* in discussion I was reminded that the following clumsy message could perhaps be avoided: "At least one of the problems in category 'foo' is not analysed due to a compiler option being ignored":
* if "supression" warnings are enabled, this might tell the compiler to perform even disabled analyses. We should discuss if "technically" enabling **all** analyses and filtering only during `ProblemHandler.handle()` is acceptable in that case.
* previous discussion in this regard happened here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=506888#c12 (with negative result)
* for a recent issue see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2279
* OTOH, it might suffice to implement `@SuppressWarnings("suppression")` and where the undesired info appears, just add "suppression".
Contributor guide
Assessment
This issue has not been assessed yet.