1 /* @test /nodynamiccopyright/
   2  * @bug 7196163
   3  * @summary Verify that improper expressions used as an operand to try-with-resources are rejected.
   4  * @compile/fail/ref=TwrForVariable3.out -XDrawDiagnostics -Xlint:-options TwrForVariable3.java
   5  */
   6 public class TwrForVariable3 implements AutoCloseable {
   7     public static void main(String... args) {
   8         TwrForVariable3 v1 = new TwrForVariable3();
   9         Object v2 = new Object();
  10 
  11         try (v2) {
  12             fail("no an AutoCloseable");
  13         }
  14         try (java.lang.Object) {
  15             fail("not a variable access");
  16         }
  17         try (java.lang) {
  18             fail("not a variable access");
  19         }
  20     }
  21 
  22     static void fail(String reason) {
  23         throw new RuntimeException(reason);
  24     }
  25 
  26     public void close() {
  27     }
  28 
  29 }