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

Bug 348867

Summary: [1.7] Quick fix on unhandled exceptions raised during auto close of a resource
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Ayushman Jain CLA 2011-06-09 07:12:27 EDT
BETA_JAVA7.

Bug 348705 introduces a new error message for unhandled exceptions raised during auto close of a resource. It will be good to have a quick fix for it, which does effectively the same thing as the quick fix on "unhandled exception type..."

 void foo(String name, boolean b) throws FileNotFoundException{ 
     ff = new FileInputStream(name);
     try (FileInputStream fis = ff) {     // see here
           throw new IllegalArgumentException();
     } catch (IllegalArgumentException e) {
        e.printStackTrace();
     }

      System.out.println("SUCCESS");

  }
Comment 1 Markus Keller CLA 2011-06-09 13:48:50 EDT
The snippet is not self-contained. When I change it to the following, it's about the same as bug 348708.


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Snippet2 {
	private FileInputStream ff;

	void foo(String name, boolean b) throws FileNotFoundException {
		ff = new FileInputStream(name);
		try (FileInputStream fis = ff) { // see here
			if (b)
				throw new IllegalArgumentException();
			else
				throw new IOException();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		}

		System.out.println("SUCCESS");

	}
}

*** This bug has been marked as a duplicate of bug 348708 ***