Bug 67836 - [compiler] warning on fall through
Summary: [compiler] warning on fall through
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 enhancement (vote)
Target Milestone: 3.2 M5   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 30184 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-06-18 11:58 EDT by Adam Kiezun CLA
Modified: 2009-11-03 10:27 EST (History)
2 users (show)

See Also:


Attachments
Suggested API + support (39.57 KB, patch)
2006-02-13 11:47 EST, Maxime Daniel CLA
no flags Details | Diff
Reviewed API - testing under progress (18.14 KB, patch)
2006-02-14 10:36 EST, Maxime Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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. ***