Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348867 - [1.7] Quick fix on unhandled exceptions raised during auto close of a resource
Summary: [1.7] Quick fix on unhandled exceptions raised during auto close of a resource
Status: CLOSED DUPLICATE of bug 348708
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-09 07:12 EDT by Ayushman Jain CLA
Modified: 2011-06-09 13:48 EDT (History)
1 user (show)

See Also:


Attachments

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