Bug 67836

Summary: [compiler] warning on fall through
Product: [Eclipse Project] JDT Reporter: Adam Kiezun <akiezun>
Component: CoreAssignee: Maxime Daniel <maxime_daniel>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: joerg, maxime_daniel
Version: 3.0   
Target Milestone: 3.2 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Suggested API + support
none
Reviewed API - testing under progress none

Description Adam Kiezun CLA 2004-06-18 11:58:41 EDT
3.0rc2
a warning on possible fallthought in switches would be nice
and javac has one :)
Comment 1 Philipe Mulet CLA 2004-06-18 12:40:17 EDT
post 3.0
Comment 2 Philipe Mulet CLA 2006-02-10 08:06:13 EST
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).
Comment 3 Maxime Daniel CLA 2006-02-13 04:55:12 EST
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.
Comment 4 Maxime Daniel CLA 2006-02-13 11:47:06 EST
Created attachment 34583 [details]
Suggested API + support

See FlowAnalysisTest, tests #6 to 18, and BatchCompilerTest, tests #49 to 51 for examples.
Comment 5 Maxime Daniel CLA 2006-02-14 10:27:38 EST
Retarget to 3.2 M5.
Comment 6 Maxime Daniel CLA 2006-02-14 10:36:24 EST
Created attachment 34671 [details]
Reviewed API - testing under progress
Comment 7 Maxime Daniel CLA 2006-02-15 04:50:05 EST
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.
Comment 8 Jerome Lanneluc CLA 2006-02-15 12:20:38 EST
Verified for 3.2 M5 using build I20060215-0800
Comment 9 Markus Keller CLA 2009-11-03 10:27:05 EST
*** Bug 30184 has been marked as a duplicate of this bug. ***