diff -r 000000000000 -r 959103a6100f test/tools/javac/TryWithResources/ResDeclOutsideTry.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/TryWithResources/ResDeclOutsideTry.java Wed Apr 27 01:34:52 2016 +0800 @@ -0,0 +1,18 @@ +/* + * @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;) { + } + } +} +