darcy@609: /* darcy@609: * @test /nodynamiccopyright/ darcy@609: * @bug 6911256 6964740 darcy@609: * @author Joseph D. Darcy darcy@609: * @summary Test exception analysis of ARM 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@609: try(TwrFlow armflow = new TwrFlow()) { darcy@609: System.out.println(armflow.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: // Also check behavior on a resource expression rather than a darcy@609: // declaration. darcy@609: TwrFlow armflowexpr = new TwrFlow(); darcy@609: try(armflowexpr) { darcy@609: System.out.println(armflowexpr.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 {}