langtools/test/tools/javac/TryWithResources/ResDeclOutsideTry.java
author sogoel
Wed, 13 Nov 2013 16:36:08 -0800
changeset 21714 f5b7edec4304
child 27844 8b5d79870a2f
permissions -rw-r--r--
8025113: Convert 7 tools TryWithResources tests to jtreg format Reviewed-by: darcy, jjg

/*
 * @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;) {
        }
    }
}