Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340626 - [1.7][compiler] Inconsistent source pinpointing in multi-catch blocks
Summary: [1.7][compiler] Inconsistent source pinpointing in multi-catch blocks
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: Satyam Kandula CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-22 01:40 EDT by Srikanth Sankaran CLA
Modified: 2011-08-05 02:54 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (4.31 KB, patch)
2011-03-23 01:27 EDT, Satyam Kandula CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.