Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348708 - [1.7][quick fix] Adding unhandled exceptions on resource declarations performs wrong action
Summary: [1.7][quick fix] Adding unhandled exceptions on resource declarations perform...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 348867 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-06-08 07:51 EDT by Ayushman Jain CLA
Modified: 2011-08-02 05:45 EDT (History)
3 users (show)

See Also:


Attachments
fix + tests (30.16 KB, patch)
2011-06-16 05:30 EDT, Deepak Azad CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ayushman Jain CLA 2011-06-08 07:51:29 EDT
BETA_JAVA7

public class Snippet {
	static void m(int n) throws IllegalArgumentException, MyException {
		if (n == 1)
		        throw new IllegalArgumentException();
		else 
			throw new MyException();
	}

	 void foo(String name, boolean b) { 
	     try (FileInputStream fis = new FileInputStream(name)) {  // use quick fix here
	          m(1);
	     } 
	
	      System.out.println("SUCCESS");
	
	  } 
	
}
class MyException extends Exception{
	
}

Using quick fix at the location marked above i.e. for the error "unhandled exception type FileNotFoundException" adds the thrown exceptions from method 'm(int)' instead of adding FileNotFoundException. Since the exception still remains, again see the available quick fixes for correcting the error. This time, the "add throws declaration" quick fix is not even available. The latter also happens in case the call m(1) is removed.
Comment 1 Deepak Azad CLA 2011-06-08 08:23:54 EDT
I will take a look.
Comment 2 Markus Keller CLA 2011-06-09 13:48:50 EDT
*** Bug 348867 has been marked as a duplicate of this bug. ***
Comment 3 Deepak Azad CLA 2011-06-16 05:30:24 EDT
Created attachment 198074 [details]
fix + tests

Fixed in BETA_JAVA7
Comment 4 Deepak Azad CLA 2011-06-16 05:30:56 EDT
.
Comment 5 Michael Rennie CLA 2011-07-20 14:56:09 EDT
verified