Community
Participate
Working Groups
As far as I can tell there is no option to selectively turn off dead code detection warnings using the @SuppressWarnings annotation. The feature either has to be disabled (globally/per-project) or @SuppressWarnings("all") has to be used. While the latter is acceptable, it seems a specific @SuppressWarnings("dead-code") could be appropriate or alternatively it could be considered to fall under the @SuppressWarnings("unused") category.
This indeed looks inconsistent. The batch compiler supports -warn:-deadCode. The UI supports configuration (error/warn/ignore), only the @SuppressWarnings annotation has no support for deadCode. Might be just an oversight/forgetting to add to CompilerOptions.warningTokens and related methods?
Philippe, do you have anything against adding more tokens to SuppressWarnings support? To be consistent, we could support all batch compiler options through the SuppressWarnings tokens.
The rules that we always used for SuppressWarnings is that it should be reserved to cases that cannot be easily "fixed". Are you requiring this in order to workaround bug 282768 ?
Yes, I noticed the lack of the @SuppressWarnings due to bug 282768. I wonder how you define "easily fixed", though. I can see cases where people might want to keep some dead code around in the same way as they keep unused code around (there is an @SuppressWarnings for that after all). Not that I would ever encourage this behavior, but I have seen it and I can see people doing the same with the dead code detection.
I prefer to add "dead code" warnings as part of the "unused" SuppressWarnings support instead of adding a new token. This should be good enough to "fix" this issue.
Added deadCode warnings under the @SuppressWarnings("unused") handling. Released for 3.6M3. Added regression tests in: org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test275 org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test276 org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test277
Updated failing quick fix tests.
Verified for 3.6M3 with build I20091026-0800