java-topology/test/langtools/tools/javac/lvti/T8200199.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

25 lines
591 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8200199
* @summary javac suggests to use var even when var is used
* @compile/fail/ref=T8200199.out -Werror -XDfind=local -XDrawDiagnostics T8200199.java
*/
class T8200199 {
class Resource implements AutoCloseable {
public void close() {};
}
public void implicit() {
var i = 33;
for (var x = 0 ; x < 10 ; x++) { }
try (var r = new Resource()) { }
}
public void explicit() {
int i = 33;
for (int x = 0 ; x < 10 ; x++) { }
try (Resource r = new Resource()) { }
}
}