--- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/test/tools/javac/AutomaticResourceManagement/ArmIntersection02.java 2010-07-07 20:26:53.000000000 -0700 @@ -0,0 +1,37 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6911256 6964740 6965277 + * @author Maurizio Cimadamore + * @summary Check that resources of an intersection type forces union of exception types + * to be caught outside arm block + * @compile/fail/ref=ArmIntersection02.out -XDrawDiagnostics ArmIntersection02.java + */ + +class ArmIntersection02 { + + static class Exception1 extends Exception {} + static class Exception2 extends Exception {} + + + interface MyResource1 extends AutoCloseable { + void close() throws Exception1; + } + + interface MyResource2 extends AutoCloseable { + void close() throws Exception2; + } + + public void test1() throws Exception1 { + try(getX()) { + //do something + } + } + + public void test2() throws Exception2 { + try(getX()) { + //do something + } + } + + X getX() { return null; } +}