Bug 52221 - [Compiler] should reject Local type usage when defined in other switch case block
Summary: [Compiler] should reject Local type usage when defined in other switch case b...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M8   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-17 04:42 EST by Philipe Mulet CLA
Modified: 2004-03-24 11:02 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2004-02-17 04:42:43 EST
Build 3.0M7

1.4 compliant compilers should reject the following code:

class X {
    public static void main(String[] args) {
        switch(args.length) {
            case 1:
                class Local {
	        }
                break;
                
	    case 0 :
		System.out.println(new Local()); // Local undefined
        }
    }
}
Comment 1 Philipe Mulet CLA 2004-02-17 04:43:28 EST
Javac 1.4.1, Jikes 1.18 do tolerate this code as we do.
Comment 2 Philipe Mulet CLA 2004-02-17 06:22:11 EST
Interestingly enough, the spec still allows the variable 'i' to be seen across 
switch case blocks... only a definite assignment issue is raised. The name can 
be resolved.

class X {
    public static void main(String[] args) {
        
        switch(args.length) {
            
            case 1:
                int i = 0;
                break;
                
			case 0 :
			    System.out.println(i);
        }
    }
}
Comment 3 Philipe Mulet CLA 2004-02-17 09:35:32 EST
Fixed, added regression tests: Compliance13/Compliance14#test073 & test074
Comment 4 Jerome Lanneluc CLA 2004-03-24 11:02:18 EST
Verified in build I200403240800.