java-topology/test/langtools/tools/javac/cast/8141343/T8141343.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
614 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8141343
* @summary Subtle semantics changes for union types in cast conversion
* @compile/fail/ref=T8141343.out -XDrawDiagnostics T8141343.java
*/
class T8141343 {
interface Foo<X> { }
static class A extends Exception implements Foo<A> { }
static class B extends Exception implements Foo<B> { }
void test(boolean cond) {
try {
if (cond) {
throw new A();
} else {
throw new B();
}
} catch (A | B ex) {
Foo<Integer> fa = (Foo<Integer>)ex;
}
}
}