Community
Participate
Working Groups
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"); }
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 ***