1 /* 2 * @test /nodynamiccopyright/ 3 * @bug 6911256 6964740 4 * @author Joseph D. Darcy 5 * @summary Test exception analysis of ARM blocks 6 * @compile/fail -source 6 ArmFlow.java 7 * @compile/fail/ref=ArmFlow.out -XDrawDiagnostics ArmFlow.java 8 */ 9 10 import java.io.IOException; 11 public class ArmFlow implements AutoCloseable { 12 public static void main(String... args) { 13 try(ArmFlow armflow = new ArmFlow()) { 14 System.out.println(armflow.toString()); 15 } catch (IOException ioe) { // Not reachable 16 throw new AssertionError("Shouldn't reach here", ioe); 17 } 18 // CustomCloseException should be caught or added to throws clause 19 20 // Also check behavior on a resource expression rather than a 21 // declaration. 22 ArmFlow armflowexpr = new ArmFlow(); 23 try(armflowexpr) { 24 System.out.println(armflowexpr.toString()); 25 } catch (IOException ioe) { // Not reachable 26 throw new AssertionError("Shouldn't reach here", ioe); 27 } 28 // CustomCloseException should be caught or added to throws clause 29 } 30 31 /* 32 * A close method, but the class is <em>not</em> Closeable or 33 * AutoCloseable. 34 */ 35 public void close() throws CustomCloseException { 36 throw new CustomCloseException(); 37 } 38 } 39 40 class CustomCloseException extends Exception {}