Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340484 - [1.7][compiler] Failure in computing precisely rethrown types.
Summary: [1.7][compiler] Failure in computing precisely rethrown types.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-19 06:13 EDT by Srikanth Sankaran CLA
Modified: 2011-08-05 02:54 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2011-03-19 06:13:38 EDT
While reviewing the code changes done for bug 340022, I realized that
the code as it is will compile the following code alright in 1.7 source
level while it should not. Indeed javac 7b131 refuses to compile it:

public class X {
	public static void main(String[] args) {
		try {
			throw new DaughterOfFoo();
		} catch(Foo e) {
			try { 
				while (true) {
					throw e; 
				}
			} catch (SonOfFoo e1) {
			 	e1.printStackTrace();
			} catch (Foo e1) {}
		}
	}
}
class Foo extends Exception {}
class SonOfFoo extends Foo {}
class DaughterOfFoo extends Foo {}

The problem stems from the line of code:

if (argumentEffectivelyFinal == true && traversedContext instanceof ExceptionHandlingFlowContext) in flowContext.java. By inserting an
artificial while loop in the test case, the if statement is short
circuited, resulting in the incorrect behavior.

BTW, why argumentEffectivelyFinal == true ? instead of simply argumentEffectivelyFinal ? (may be better renamed argumentIsEffectivelyFinal ?)
Comment 1 Srikanth Sankaran CLA 2011-03-19 06:16:37 EDT
Another related problem:

The following code fails to compile with source level 1.6 and
compliance level 1.7. I think precise rethrow semantics should
be keyed off of (i.e trigger with) the source level and not 
compliance level.

public class X {
	public static void main(String[] args) {
		try {
			throw new DaughterOfFoo();
		} catch(Foo e) {
			try { 
					throw e; 
			} catch (SonOfFoo e1) {
			 	e1.printStackTrace();
			} catch (Foo e1) {}
		}
	}
}
class Foo extends Exception {}
class SonOfFoo extends Foo {}
class DaughterOfFoo extends Foo {}
Comment 2 Srikanth Sankaran CLA 2011-03-20 02:58:23 EDT
Patch posted at https://bugs.eclipse.org/bugs/show_bug.cgi?id=340022#c5
fixes this issue and has a junit also.
Comment 3 Srikanth Sankaran CLA 2011-03-21 05:04:13 EDT
> 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 4 Olivier Thomann CLA 2011-06-28 09:35:37 EDT
Verified.