Bug 68863

Summary: Missing entry in local variable attribute
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.0.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Philipe Mulet CLA 2004-06-29 10:27:28 EDT
R3.0

On following code, we are not generating the proper variable entry in local 
variable attribute:

public class X {
	public static void main(String[] args) {
		int i;	
		outer: {
			if (args == null) {
				i = 0;
				break outer;
			}
			return;
		}
		System.out.println(i);	// no entry in var attribute
	}
}

Thus if breaking in debugging on println(i) line, the variable 'i' isn't 
visible where it should be.
Comment 1 Philipe Mulet CLA 2004-06-29 10:36:16 EDT
we should generate sthg like:

      Local variable table:
        [pc: 6, pc: 9] local: i index: 1 type: I
        [pc: 0, pc: 18] local: args index: 0 type: [Ljava/lang/String;
        [pc: 10, pc: 18] local: i index: 1 type: I
Comment 2 Philipe Mulet CLA 2004-06-29 11:45:02 EDT
Similar issue with do-while statement.
Comment 3 Philipe Mulet CLA 2004-06-29 11:51:47 EDT
Similar issue for all control flow statements (including foreach).
Comment 4 Philipe Mulet CLA 2004-06-29 11:56:50 EDT
The following templates where missing #addDefinitelyAssignedVariables.

if (mergedInitStateIndex != -1) {
  codeStream.removeNotDefinitelyAssignedVariables(
    currentScope, mergedInitStateIndex);
  codeStream.addDefinitelyAssignedVariables(      
    currentScope, mergedInitStateIndex);
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
Comment 5 Philipe Mulet CLA 2004-06-29 12:23:35 EDT
Could be backported to 3.0 maintenance stream.

Fixed in 1.5 stream, added regression tests: ConformTest#test241-244 + 
ForeachStatementTest#test027.
Comment 6 Philipe Mulet CLA 2004-06-30 07:22:50 EDT
Backported to 3.0.x stream.
Comment 7 David Audel CLA 2004-09-06 10:22:42 EDT
Verified for 3.0.1 RC1