Bug 26122

Summary: JACKS: VerifyError when affecting final local in anonymous class header
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Olivier Thomann CLA 2002-11-13 11:46:44 EST
Using 1112, I got a VerifyError when trying to run the generated code for this
test case:

class A {
    A(int j) {}
    public static void main(String[] args) {
        final int i;
        new A(i = 1) {
            { System.out.print(i); }
        };
    }
}
Run:
java.lang.VerifyError: (class: A, method: main signature:
([Ljava/lang/String;)V) Accessing value from uninitialized register 1
Exception in thread "main" 

Javac 1.4.1 passes it. Javac 1.3 fails as we do.

The generated bytecodes are:

	public static void main(String[] arg);
	/*  Method descriptor  #18 ([Ljava/lang/String;)V */
	Code attribute:
		/* Stack: 4, Locals: 2 */
		0	new #20 A$1
		3	iload_1     <<<<<<<< ILLEGAL
		4	iconst_1
		5	dup
		6	istore_1
		7	invokespecial #23 <Constructor A$1(int arg, int arg)>
		10	return

The javac 1.4.1 bytecodes are:
	public static void main(String[] arg);
	/*  Method descriptor  #11 ([Ljava/lang/String;)V */
	Code attribute:
		/* Stack: 4, Locals: 2 */
		0	new #2 A$1
		3	dup
		4	iconst_1
		5	dup
		6	istore_1
		7	iload_1  <<<<<< NOW THIS IS LEGAL
		8	invokespecial #3 <Constructor A$1(int arg, int arg)>
		11	pop
		12	return
Comment 1 Philipe Mulet CLA 2002-11-14 07:24:14 EST
Seems like we should pass along synthetic arguments after user ones.
Comment 2 Philipe Mulet CLA 2002-11-14 07:27:02 EST
Note that javac 1.3.1 has same bug as we do.
Comment 3 Olivier Thomann CLA 2002-11-14 12:08:08 EST
Change summary.
Comment 4 Philipe Mulet CLA 2002-11-15 06:11:17 EST
Fix applied. Substantial changes are related to this adaptation: signature 
computation, code gen and local variable position allocation.
Comment 5 David Audel CLA 2002-12-17 10:11:19 EST
Verified.