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

24 lines
No EOL
634 B
Java

/**
* @test /nodynamiccopyright/
* @bug 8309054
* @summary Parsing of erroneous patterns succeeds
* @enablePreview
* @compile/fail/ref=T8309054.out -XDrawDiagnostics --should-stop=at=FLOW T8309054.java
*/
public class T8309054 {
public void test(Object obj) {
boolean t1 = switch (obj) {
case Long a[] -> true;
default -> false;
};
boolean t2 = switch (obj) {
case Double a[][][][] -> true;
default -> false;
};
if (obj instanceof Float a[][]) {
}
if (obj instanceof Integer a = Integer.valueOf(0)) {
}
}
}