Bug 352442 - Compiler does not detects the unreachable code
Summary: Compiler does not detects the unreachable code
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-19 07:45 EDT by Ankur Sharma CLA
Modified: 2011-07-19 08:29 EDT (History)
3 users (show)

See Also:


Attachments

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