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