langtools/test/tools/javac/TryWithResources/TwrForVariable2.java
changeset 34565 627464b87753
parent 27844 8b5d79870a2f
equal deleted inserted replaced
34564:ce1498f6591f 34565:627464b87753
     6  */
     6  */
     7 public class TwrForVariable2 implements AutoCloseable {
     7 public class TwrForVariable2 implements AutoCloseable {
     8     public static void main(String... args) {
     8     public static void main(String... args) {
     9         TwrForVariable2 v = new TwrForVariable2();
     9         TwrForVariable2 v = new TwrForVariable2();
    10         TwrForVariable3[] v2 = new TwrForVariable3[1];
    10         TwrForVariable3[] v2 = new TwrForVariable3[1];
       
    11         TwrForVariable3[][] v3 = new TwrForVariable3[1][1];
    11 
    12 
    12         try (final v) {
    13         try (final v) {
    13             fail("no modifiers before variables");
    14             fail("no modifiers before variables");
    14         }
    15         }
    15         try (@Deprecated v) {
    16         try (@Deprecated v) {
    22             fail("parentheses not allowed");
    23             fail("parentheses not allowed");
    23         }
    24         }
    24         try (v2[0]) {
    25         try (v2[0]) {
    25             fail("array access not allowed");
    26             fail("array access not allowed");
    26         }
    27         }
       
    28         try (v3[0][0]) {
       
    29             fail("array access not allowed");
       
    30         }
    27         try (args.length == 0 ? v : v) {
    31         try (args.length == 0 ? v : v) {
    28             fail("general expressions not allowed");
    32             fail("general expressions not allowed");
       
    33         }
       
    34         try ((TwrForVariable2)null) {
       
    35             fail("null as variable is not allowed");
    29         }
    36         }
    30     }
    37     }
    31 
    38 
    32     static void fail(String reason) {
    39     static void fail(String reason) {
    33         throw new RuntimeException(reason);
    40         throw new RuntimeException(reason);