java-topology/test/langtools/tools/javac/generics/6227936/Orig.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

37 lines
935 B
Java

/*
* @test /nodynamiccopyright/
* @bug 6227936
* @summary Wrong type of inherited method using specialized type parameter
* @compile/fail/ref=Orig.out -XDrawDiagnostics Orig.java
*/
class GenericTest {
static class A<T extends B> {
T myB;
A(T myB) {this.myB = myB;}
T getB() {return myB;}
}
static class B<T extends C> {
T myC;
B(T myB) {this.myC = myC;}
T getC() {return myC;}
}
static class C {
C() {}
}
static class A1<T extends B1> extends A<T> {
A1(T myB) {super(myB);}
public void testMethod() {
// This next line fails, but should work
getB().getC().someMethod();
((C1)getB().getC()).someMethod();
}
}
static class B1<T extends C1> extends B<T> {
B1(T myC) {super(myC);}
}
static class C1 extends C {
public void someMethod() {}
}
}