Community
Participate
Working Groups
3.0rc2 a warning on possible fallthought in switches would be nice and javac has one :)
post 3.0
e.g. public class X { void foo(int i) { switch(i) { case 0 : case 1 : return; case 2 : System.out.println(i); <<<<<<<<<<<<<<<< case 3 : System.out.println(i); // fall-through default : return; } } } The line denoted by <<<<<<<<<<<< should be complained against, since it is an undocumented fall-through situation. To make it simple, any comment on a line would make the fall-through case treated as documented. The comment would need to span over the entire line (i.e. cannot just be a trailing comment to a statement).
API proposal: - a new warning name for the batch compiler, fallThrough; - a new warning token for use with SuppressWarnings, fall-through; - a new problem IProblem#PossibleFallThroughCase; - a new problem reporting method ProblemReporter#possibleFallThroughCase; - a new compiler option CompilerOptions#ReportPossibleFallThroughCase, default reporting level is Ignore, option name for pref file is org.eclipse.jdt.core.compiler.problem.possibleFallThroughCase.
Created attachment 34583 [details] Suggested API + support See FlowAnalysisTest, tests #6 to 18, and BatchCompilerTest, tests #49 to 51 for examples.
Retarget to 3.2 M5.
Created attachment 34671 [details] Reviewed API - testing under progress
Fixed in HEAD. Verifier please be aware that bug 127730 has been opened to track progress on the ability to 'comment out' the fall-through warning (default case label in the initial post). This is not supported yet.
Verified for 3.2 M5 using build I20060215-0800
*** Bug 30184 has been marked as a duplicate of this bug. ***