java-topology/test/langtools/tools/javac/TryWithResources/WeirdTwr.java
russell@unturf.com 0a580b313d undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com

Patches, unit tests, benchmarks, whitepaper, and outreach briefs.
Public domain — no copyright claimed. Use freely.
2026-03-26 17:11:57 -04:00

23 lines
600 B
Java

/*
* @test /nodynamiccopyright/
* @bug 6911256 6964740
* @summary Strange TWRs
* @compile WeirdTwr.java
* @run main WeirdTwr
*/
public class WeirdTwr implements AutoCloseable {
private static int closeCount = 0;
public static void main(String... args) {
try(WeirdTwr r1 = new WeirdTwr(); WeirdTwr r2 = r1) {
if (r1 != r2)
throw new RuntimeException("Unexpected inequality.");
}
if (closeCount != 2)
throw new RuntimeException("bad closeCount" + closeCount);
}
public void close() {
closeCount++;
}
}