Bug 38345

Summary: VerifyError, Inconsistent stack height with try/switch/if combination
Product: [Eclipse Project] JDT Reporter: Jim Hugunin <jim-aj>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: major    
Priority: P3    
Version: 2.1   
Target Milestone: 3.0 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Jim Hugunin CLA 2003-06-02 16:08:36 EDT
When compiled and run under eclipse-2.1, the program below will produce:
java.lang.VerifyError: (class: TrySwitch, method: m signature: (I)I) 
Inconsistent stack height 0 != 1
---------------------------------------------------
public class TrySwitch {
	public static void main(String[] args) throws Throwable {
		m(10);
	}
	
	static boolean done = true;
	static int m(int i) {
		try {
			switch(i) {
				default: return 10;
				case 10:
					if (false) { 
						break;
					} else {
						throw new RuntimeException();
					}
				case 11: break;
			}
		} catch (Throwable e) {
			System.err.println("caught: " + e);
		}
		return 33;
	}
}
---------------------------------------------------

This is the smallest test case I could create which replicates the original 
bug.  The original code is generated by the JACK Java agent tool so simple 
workarounds like removing the silly "if (false)" are very hard to apply in 
practice.

This bug was originally submitted by Feilong Chen [mailto:f0c5023@cs.tamu.edu] 
as a bug in the AspectJ-1.1 compiler which is built on top of the JDT-1.1 
compiler.  Any questions about JACK or suggested practical workaround should 
be handled by Feilong Chen.

BTW - The AspectJ team has been very impressed with the quality of your work.  
This is the first serious bug report we've had which turned out to be in the 
underlying JDT compiler we built on top of.
Comment 1 Philipe Mulet CLA 2003-06-03 05:17:30 EDT
This is a duplicate of a bug resolved since 2.1. 
The fix is integrated into our 2.1.1 delivery (we should be finalized soon).

*** This bug has been marked as a duplicate of 37621 ***