aoqi@0: /* aoqi@0: * @test /nodynamiccopyright/ aoqi@0: * @bug 6911256 6964740 7013420 aoqi@0: * @author Joseph D. Darcy aoqi@0: * @summary Test exception analysis of try-with-resources blocks aoqi@0: * @compile/fail/ref=TwrFlow.out -XDrawDiagnostics TwrFlow.java aoqi@0: */ aoqi@0: aoqi@0: import java.io.IOException; aoqi@0: public class TwrFlow implements AutoCloseable { aoqi@0: public static void main(String... args) { aoqi@0: try(TwrFlow twrFlow = new TwrFlow()) { aoqi@0: System.out.println(twrFlow.toString()); aoqi@0: } catch (IOException ioe) { // Not reachable aoqi@0: throw new AssertionError("Shouldn't reach here", ioe); aoqi@0: } aoqi@0: // CustomCloseException should be caught or added to throws clause aoqi@0: } aoqi@0: aoqi@0: /* aoqi@0: * A close method, but the class is not Closeable or aoqi@0: * AutoCloseable. aoqi@0: */ aoqi@0: public void close() throws CustomCloseException { aoqi@0: throw new CustomCloseException(); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: class CustomCloseException extends Exception {}