< prev index next >

test/tools/javac/TryWithResources/TwrForVariable2.java

Print this page

        

@@ -5,11 +5,12 @@
  * @compile/fail/ref=TwrForVariable2.out -XDrawDiagnostics -Xlint:-options TwrForVariable2.java
  */
 public class TwrForVariable2 implements AutoCloseable {
     public static void main(String... args) {
         TwrForVariable2 v = new TwrForVariable2();
-        TwrForVariable3[] v2 = new TwrForVariable3[1];
+        TwrForVariable2[] v2 = new TwrForVariable2[1];
+        TwrForVariable2[][] v3 = new TwrForVariable[1][1];
 
         try (final v) {
             fail("no modifiers before variables");
         }
         try (@Deprecated v) {

@@ -22,13 +23,19 @@
             fail("parentheses not allowed");
         }
         try (v2[0]) {
             fail("array access not allowed");
         }
+        try (v3[0][0]) {
+            fail("multidimentional array access not allowed");
+        }
         try (args.length == 0 ? v : v) {
             fail("general expressions not allowed");
         }
+        try ((TwrForVariable2)null) {
+            fail("null as variable is not allowed");
+        }
     }
 
     static void fail(String reason) {
         throw new RuntimeException(reason);
     }
< prev index next >