Bug 276833 - switch fall-through problem not detected if body is empty
Summary: switch fall-through problem not detected if body is empty
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-19 04:37 EDT by Dani Megert CLA
Modified: 2009-06-26 11:20 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2009-05-19 04:37:48 EDT
I20090518-2000.

1. enable switch fall-through detection
2. have this code 
    switch (i) {
        case 1:
        case 2:
            System.out.println(2);
            break;
        default:
            break;
    }

==> case1 falls-through into case 2 but it is not reported.
Comment 1 Dani Megert CLA 2009-05-19 05:52:59 EDT
While this is a common code pattern some users would still like to detect such a scenario to catch mistakes. However, we should not change existing diagnosis but instead offer a new of strict mode where this is detected.
Comment 2 Markus Keller CLA 2009-05-19 08:25:17 EDT
Unlike the case with missing break or return, I don't think the empty body case is worth another warning/preference.

We currently do the same as javac (see bug 67836), and I think that's the best balance between worthwhile detection of potential problems and almost 100% false positives for a common coding pattern.
Comment 3 Olivier Thomann CLA 2009-06-26 11:09:01 EDT
Daniel, do you really want to see this fixed or you agree with Markus's comment ?
Comment 4 Dani Megert CLA 2009-06-26 11:20:54 EDT
Markus is right but there are situations where you would like to detect/see such cases. I suggest we keep the bug open but not work on it for now.