/* * @test /nodynamiccopyright/ * @bug 6911256 6964740 * @author Joseph D. Darcy * @summary Test exception analysis of ARM blocks * @compile/fail -source 6 ArmFlow.java * @compile/fail/ref=ArmFlow.out -XDrawDiagnostics ArmFlow.java */ import java.io.IOException; public class ArmFlow implements AutoCloseable { public static void main(String... args) { try(ArmFlow armflow = new ArmFlow()) { System.out.println(armflow.toString()); } catch (IOException ioe) { // Not reachable throw new AssertionError("Shouldn't reach here", ioe); } // CustomCloseException should be caught or added to throws clause // Also check behavior on a resource expression rather than a // declaration. ArmFlow armflowexpr = new ArmFlow(); try(armflowexpr) { System.out.println(armflowexpr.toString()); } catch (IOException ioe) { // Not reachable throw new AssertionError("Shouldn't reach here", ioe); } // CustomCloseException should be caught or added to throws clause } /* * A close method, but the class is not Closeable or * AutoCloseable. */ public void close() throws CustomCloseException { throw new CustomCloseException(); } } class CustomCloseException extends Exception {}