test/tools/javac/TryWithResources/ResDeclOutsideTry.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/TryWithResources/ResDeclOutsideTry.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,18 @@
     1.4 +/*
     1.5 + * @test  /nodynamiccopyright/
     1.6 + * @bug 8025113
     1.7 + * @author sogoel
     1.8 + * @summary Resources cannot be declared outside t-w-r block
     1.9 + * @compile/fail/ref=ResDeclOutsideTry.out -XDrawDiagnostics ResDeclOutsideTry.java
    1.10 + */
    1.11 +
    1.12 +public class ResDeclOutsideTry implements AutoCloseable {
    1.13 +    ResDeclOutsideTry tr1;
    1.14 +    ResDeclOutsideTry tr2 = new ResDeclOutsideTry();
    1.15 +
    1.16 +    String test1() {
    1.17 +        try (tr1 = new ResDeclOutsideTry(); tr2;) {
    1.18 +        }
    1.19 +    }
    1.20 +}
    1.21 +

mercurial