aoqi@0: /* aoqi@0: * @test /nodynamiccopyright/ aoqi@0: * @bug 6911256 6964740 6965277 aoqi@0: * @author Maurizio Cimadamore aoqi@0: * @summary Check that resource variable is not accessible from catch/finally clause aoqi@0: * @compile/fail/ref=ResourceOutsideTry.out -XDrawDiagnostics ResourceOutsideTry.java aoqi@0: */ aoqi@0: aoqi@0: class ResourceOutsideTry { aoqi@0: void test() { aoqi@0: try(MyResource c = new MyResource()) { aoqi@0: //do something aoqi@0: } catch (Exception e) { aoqi@0: c.test(); aoqi@0: } finally { aoqi@0: c.test(); aoqi@0: } aoqi@0: } aoqi@0: static class MyResource implements AutoCloseable { aoqi@0: public void close() throws Exception {} aoqi@0: void test() {} aoqi@0: } aoqi@0: }