langtools/test/tools/javac/TryWithResources/ResDeclOutsideTry.java
author duke
Wed, 05 Jul 2017 23:01:50 +0200
changeset 44228 e46434c65a2b
parent 27844 8b5d79870a2f
permissions -rw-r--r--
Merge

/*
 * @test  /nodynamiccopyright/
 * @bug 8025113
 * @author sogoel
 * @summary Resources cannot be declared outside t-w-r block
 * @compile/fail/ref=ResDeclOutsideTry.out -XDrawDiagnostics ResDeclOutsideTry.java
 */

public class ResDeclOutsideTry implements AutoCloseable {
    ResDeclOutsideTry tr1;
    ResDeclOutsideTry tr2 = new ResDeclOutsideTry();

    String test1() {
        try (tr1 = new ResDeclOutsideTry(); tr2;) {
        }
        return null;
    }

    @Override
    public void close() throws Exception {
    }
}