darcy@609: /* darcy@609: * @test /nodynamiccopyright/ darcy@609: * @bug 6911256 6964740 6965277 darcy@609: * @author Maurizio Cimadamore darcy@609: * @summary Check that resources of an intersection type forces union of exception types darcy@609: * to be caught outside twr block darcy@609: * @compile/fail/ref=TwrIntersection02.out -XDrawDiagnostics TwrIntersection02.java darcy@609: */ darcy@609: darcy@609: class TwrIntersection02 { darcy@609: darcy@609: static class Exception1 extends Exception {} darcy@609: static class Exception2 extends Exception {} darcy@609: darcy@609: darcy@609: interface MyResource1 extends AutoCloseable { darcy@609: void close() throws Exception1; darcy@609: } darcy@609: darcy@609: interface MyResource2 extends AutoCloseable { darcy@609: void close() throws Exception2; darcy@609: } darcy@609: darcy@609: public void test1() throws Exception1 { darcy@609: try(getX()) { darcy@609: //do something darcy@609: } darcy@609: } darcy@609: darcy@609: public void test2() throws Exception2 { darcy@609: try(getX()) { darcy@609: //do something darcy@609: } darcy@609: } darcy@609: darcy@609: X getX() { return null; } darcy@609: }