Bug 26122 - JACKS: VerifyError when affecting final local in anonymous class header
Summary: JACKS: VerifyError when affecting final local in anonymous class header
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-13 11:46 EST by Olivier Thomann CLA
Modified: 2002-12-17 10:11 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 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.