Summary: | [1.5][compiler] false positive for "missing return result" when switching enum | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Görge Albrecht <eclipse> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | CLOSED INVALID | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | Olivier_Thomann |
Version: | 3.4 | ||
Target Milestone: | 3.5 M2 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Görge Albrecht
2008-08-14 05:32:05 EDT
This code doesn't compile with javac 1.5, 1.6 and 1.7. An extra return statement is required. Closing as INVALID. Sorry. Of course you're right. I should have made the check myself. Interestingly enough, the following method doesn't need an extra return at the end. (BTW, the default statement isn't reachable either. But this is another issue ;-) 1: public class SwitchTest { 2: enum ABC {A, B, C; } 3: 4: String switchABC(ABC abc) { 5: switch (abc) { 6: case A: 7: return "A"; 8: case B: 9: return "B"; 10: case C: 11: return "C"; 12: default: 13: throw new RuntimeException("not reachable"); 14: } 15: } I'll check the cases against the JLS and file a bug/enhancement req against javac... |