1 /* 2 * @test /nodynamiccopyright/ 3 * @bug 6911256 6964740 6965277 4 * @author Joseph D. Darcy 5 * @summary Verify nested ARM blocks have proper semantics 6 * @compile/fail -source 6 NestedArm.java 7 * @compile NestedArm.java 8 * @run main NestedArm 9 */ 10 11 import java.io.IOException; 12 public class NestedArm implements AutoCloseable { 13 private final Class<? extends Exception> exceptionOnClose; 14 public NestedArm(Class<? extends Exception> exception) { 15 exceptionOnClose = exception; 16 } 17 18 public static void main(String... args) throws Exception { 19 try(NestedArm armflow = new NestedArm(AnotherCustomCloseException.class)) { 20 try(NestedArm armflow2 = new NestedArm(YetAnotherCustomCloseException.class)) { 21 ; 22 } 23 } catch (AnotherCustomCloseException e) { 24 e.printStackTrace(); 25 } 26 } 27 28 /* 29 * A close method. 30 */ 31 public void close() throws Exception { 32 throw exceptionOnClose.newInstance(); 33 } 34 } 35 36 class AnotherCustomCloseException extends Exception {} 37 class YetAnotherCustomCloseException extends Exception {}