langtools/test/tools/javac/TryWithResources/ResDeclOutsideTry.java
changeset 21714 f5b7edec4304
child 27844 8b5d79870a2f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/TryWithResources/ResDeclOutsideTry.java	Wed Nov 13 16:36:08 2013 -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;) {
+        }
+    }
+}
+