Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 340485

Summary: [1.7][compiler] Type miscalculation in rethrow
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, Olivier_Thomann
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Srikanth Sankaran CLA 2011-03-19 07:22:28 EDT
BETA_JAVA7

While reviewing the code changes done for bug 340022, I noticed that,
the following program doesn't compile with 1.7 mode anymore. On 1.5
it compiles and runs fine. Javac5 and 7 are ok.

public class X {
	public static void main(String [] args) {
		doSomething(false);
	}


	public static void doSomething (boolean bool) {
		try {
			if (bool)
				throw new GrandSonOfFoo();
			else 
				throw new GrandDaughterOfFoo();
		} catch(Foo e) {
			try { 
					throw e; 
			} catch (SonOfFoo e1) {
			 	e1.printStackTrace();
			} catch (DaughterOfFoo e1) {
				System.out.println("caught a daughter of foo");
			} catch (Foo f) {}
		}
	}
	
}
class Foo extends Exception {}
class SonOfFoo extends Foo {}
class GrandSonOfFoo extends SonOfFoo {}
class DaughterOfFoo extends Foo {}
class GrandDaughterOfFoo extends DaughterOfFoo {}
Comment 1 Srikanth Sankaran CLA 2011-03-20 02:58:09 EDT
Patch posted at https://bugs.eclipse.org/bugs/show_bug.cgi?id=340022#c5
fixes this issue and has a junit also.
Comment 2 Srikanth Sankaran CLA 2011-03-21 05:01:52 EDT
(In reply to comment #1)
> Patch posted at https://bugs.eclipse.org/bugs/show_bug.cgi?id=340022#c5
> fixes this issue and has a junit also.

Resolved by the patch posted at (released into BETA_JAVA7 branch)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=340022#c8
Comment 3 Olivier Thomann CLA 2011-06-28 09:37:30 EDT
Verified.