Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352442

Summary: Compiler does not detects the unreachable code
Product: [Eclipse Project] JDT Reporter: Ankur Sharma <ankur_sharma>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: amj87.iitr, deepakazad, markus.kell.r
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ankur Sharma CLA 2011-07-19 07:45:14 EDT
snippet


		switch ("one") {
		case "one":
			System.out.println("Accept");
			return true;
		case "two":
			System.out.println("Unreachable");
			return true;
		default:
			System.out.println("Fail");
			return false;
		}


the second case statement and the default case are unreachable. The compiler can mark them as unreachable code or show a warning that I am using switch on String constant or both :)
Comment 1 Ayushman Jain CLA 2011-07-19 08:29:24 EDT
Switching on constants is anyway kind of redundant. So IMHO, we should warn when the switch is done on a constant. Something like

"Redundant switch on a constant"