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