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

Bug 348708

Summary: [1.7][quick fix] Adding unhandled exceptions on resource declarations performs wrong action
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: UIAssignee: Deepak Azad <deepakazad>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: deepakazad, markus.kell.r, Michael_Rennie
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
fix + tests none

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