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

19 lines
517 B
Java

/*
* @test /nodynamiccopyright/
* @bug 4949303
* @summary A method returning a raw type cannot override a method returning a generic type
* @author gafter
*
* @compile UncheckedCovariance.java
* @compile/fail/ref=UncheckedCovariance.out -XDrawDiagnostics -Xlint:unchecked -Werror UncheckedCovariance.java
*/
class UncheckedCovariance {
static class Box<T> { }
static class A {
Box<Integer> f() { return null; }
}
static class B extends A {
Box f() { return null; }
}
}