1 /*
   2  * @test /nodynamiccopyright/
   3  * @bug 6911256 6964740
   4  * @author Joseph D. Darcy
   5  * @summary Strange TWRs
   6  * @compile WeirdTwr.java
   7  * @run main WeirdTwr
   8  */
   9 
  10 public class WeirdTwr implements AutoCloseable {
  11     private static int closeCount = 0;
  12     public static void main(String... args) {
  13         try(WeirdTwr r1 = new WeirdTwr(); WeirdTwr r2 = r1) {
  14             if (r1 != r2)
  15                 throw new RuntimeException("Unexpected inequality.");
  16         }
  17         if (closeCount != 2)
  18             throw new RuntimeException("bad closeCount" + closeCount);
  19     }
  20 
  21     public void close() {
  22         closeCount++;
  23     }
  24 }