Bug 282770

Summary: [compiler] Dead code detection should have specific @SuppressWarnings
Product: [Eclipse Project] JDT Reporter: Peter Becker <peter>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: jarthana, markus.kell.r, Olivier_Thomann, stephan.herrmann
Version: 3.5   
Target Milestone: 3.6 M3   
Hardware: All   
OS: All   
Whiteboard:

Description Peter Becker CLA 2009-07-07 23:48:32 EDT
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.
Comment 1 Stephan Herrmann CLA 2009-07-11 09:55:48 EDT
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?
Comment 2 Olivier Thomann CLA 2009-07-14 12:26:32 EDT
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. 
Comment 3 Olivier Thomann CLA 2009-07-15 10:45:36 EDT
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 ?
Comment 4 Peter Becker CLA 2009-07-15 20:18:05 EDT
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.
Comment 5 Olivier Thomann CLA 2009-10-05 12:03:50 EDT
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.
Comment 6 Olivier Thomann CLA 2009-10-05 13:45:30 EDT
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
Comment 7 Markus Keller CLA 2009-10-06 06:35:12 EDT
Updated failing quick fix tests.
Comment 8 Jay Arthanareeswaran CLA 2009-10-27 02:42:39 EDT
Verified for 3.6M3 with build I20091026-0800