Community
Participate
Working Groups
The JDT editor (Keppler SR2) believes switch cases can be entered from dead code. An example is provided below. I added the given errors and warnings at the lines where they are given. When I remove the "break" lines, the warnings also go away. /** */ public class t { /** */ public enum X { /** */ A, /** */ B; } /** @param x x * @return x */ public String f(X x) { switch (x) { case A: return "a"; break; //<-- ERROR: Unreachable code case B: return "b"; //<-- WARNING: Switch case may be entered by falling through previous case break; //<-- ERROR: Unreachable code default: return "?"; //<-- WARNING: Switch case may be entered by falling through previous case break; //<-- ERROR: Unreachable code } } }
I think what is happening is having complained about break not being reachable, we perhaps mark is fake reachable to avoid having to report further problems in subsequent statements. In this case, it seems to have the exact opposite of the intended effect. Shankha, please take a look. TIA.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
This is still relevant. (In reply to Srikanth Sankaran from comment #1) > I think what is happening is having complained about break not being > reachable, > we perhaps mark is fake reachable to avoid having to report further problems > in > subsequent statements. In this case, it seems to have the exact opposite of > the > intended effect. > > Shankha, please take a look. TIA. Shankha isn't around. I can take a stab at it. Initial investigation shows it's not really a fake reachable but marked as COMPLAINED_UNREACHABLE. So, I suppose to cover all the cases, we can omit the fall-through warning if the complaint level is > NOT_COMPLAINED. Will see if a simple fix can be arrived at.