Bug 248319

Summary: [compiler][1.5] Valid Java source produces class file that doesn't verify (VerifyError, javac compiles correctly)
Product: [Eclipse Project] JDT Reporter: Joachim Sauer <mail>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, philippe_mulet
Version: 3.4Flags: philippe_mulet: review+
Target Milestone: 3.5 M3   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Proposed fix + updated regression tests none

Description Joachim Sauer CLA 2008-09-23 13:53:35 EDT
Build ID: I20080617-2000

Steps To Reproduce:
1. Compile the following Class using Eclipse ecj:

public class Foo {
	public static void main(final String[] args) {
		new Foo().verifyError();
	}
	private Object verifyError() {
		try {
			if (someBooleanMethod()) {
				return null;
			}

			return getStuff();
		} catch (final Exception ex) {
			return null;
		} finally {
			while (someBooleanMethod()) {
				anyMethod();
			}
		}
	}
	private void anyMethod() {
		// do nothing
	}
	private Object getStuff() {
		return null;
	}
	private boolean someBooleanMethod() {
		return false;
	}
}

2. Try to run it (I tried it using Sun Java 1.5.0_15)
3. Get VerifyError instead of boring, no-output execution:

java.lang.VerifyError: (class: Foo, method: verifyError signature: ()Ljava/lang/Object;) Accessing value from uninitialized register 3


More information:
This is as far as I could break down the test case (the original code was much more complex). Now when I change anything the VerifyError goes away.
Comment 1 Olivier Thomann CLA 2008-09-23 14:19:11 EDT
Reproduced with HEAD with compliance 1.5.
Compliance 1.6 or 1.4 doesn't produce the problem.
I am investigating.
Comment 2 Olivier Thomann CLA 2008-09-23 20:55:38 EDT
Created attachment 113314 [details]
Proposed fix + updated regression tests
Comment 3 Olivier Thomann CLA 2008-09-23 20:56:07 EDT
Philippe, please review.
Comment 4 Philipe Mulet CLA 2008-10-02 11:50:06 EDT
Fix looks good.

Shouldn't we address it as well in 3.4.2 ? A verifyError due to StackMapTable sounds bad, since the code pattern is not that complex.
Comment 5 Olivier Thomann CLA 2008-10-14 12:04:12 EDT
Philippe, +1 for 3.4.2 ?
Comment 6 Olivier Thomann CLA 2008-10-14 12:06:35 EDT
Fixed and released for 3.5M3.
Updated existing regression tests.

Will reopen if this needs to be addressed for 3.4.2.
Comment 7 Frederic Fusier CLA 2008-10-28 06:09:40 EDT
Verified for 3.5M3 using build I20081026-2000.