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

Bug 340626

Summary: [1.7][compiler] Inconsistent source pinpointing in multi-catch blocks
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Satyam Kandula <satyam.kandula>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Srikanth Sankaran CLA 2011-03-22 01:40:11 EDT
The following program shows two nearly identical error
messages, but see that the source range highlighted is
inconsistent.
// --------------- 8<----------------------
import java.io.*;
public class X {
	public static void main(String[] args) {
		try {
			System.out.println();
			Reader r = new FileReader(args[0]);
			r.read();
		} catch(RuntimeException | Exception e) {
			e.printStackTrace();
		} catch(FileNotFoundException | IOException e) {
			e.printStackTrace();
		}
	}
}

class Y {
	public static void main(String[] args) {
		try {
			throw new DaughterOfFoo();
		} catch(SonOfFoo | DaughterOfFoo e) {
			e.printStackTrace();
		}
	} 
}

class Foo extends Exception {}
class SonOfFoo extends Foo {}
class DaughterOfFoo extends Foo {}
// -----------------------------8<----------------------

Junits already exist :)
org.eclipse.jdt.core.tests.compiler.regression.TryStatement17Test.test010()
shows the preferred behavior while 
org.eclipse.jdt.core.tests.compiler.regression.TryStatement17Test.test003()
shows the less desirable behavior.
Comment 1 Satyam Kandula CLA 2011-03-23 01:27:52 EDT
Created attachment 191721 [details]
Proposed patch

Made changes as to pinpoint the error like the preferred behavior.
Comment 2 Satyam Kandula CLA 2011-03-23 01:45:43 EDT
Released in BETA_JAVA7 branch
Comment 3 Ayushman Jain CLA 2011-06-30 01:58:14 EDT
Verified using Eclipse Java 7 Support(Beta) feature patch v20110623-0900.