--- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/test/tools/javac/AutomaticResourceManagement/NestedArm.java 2010-06-30 14:15:24.000000000 -0700 @@ -0,0 +1,37 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6911256 6964740 6965277 + * @author Joseph D. Darcy + * @summary Verify nested ARM blocks have proper semantics + * @compile/fail -source 6 NestedArm.java + * @compile NestedArm.java + * @run main NestedArm + */ + +import java.io.IOException; +public class NestedArm implements AutoCloseable { + private final Class exceptionOnClose; + public NestedArm(Class exception) { + exceptionOnClose = exception; + } + + public static void main(String... args) throws Exception { + try(NestedArm armflow = new NestedArm(AnotherCustomCloseException.class)) { + try(NestedArm armflow2 = new NestedArm(YetAnotherCustomCloseException.class)) { + ; + } + } catch (AnotherCustomCloseException e) { + e.printStackTrace(); + } + } + + /* + * A close method. + */ + public void close() throws Exception { + throw exceptionOnClose.newInstance(); + } +} + +class AnotherCustomCloseException extends Exception {} +class YetAnotherCustomCloseException extends Exception {}