Community
Participate
Working Groups
The following perfectly legal fragment compiles OK with javac (jdk1.5.0_04) from the command line, but is rejected by the internal compiler, with the error "The return type is incompatible with U.foo()" reported for V.foo(): class C<T> {} class A {} class U { public <T extends A> C<T> foo() { return null; } } class B extends A {} class V extends U { public C<B> foo() { return null; } }
Javac reports an unchecked warning: X.java:23: warning: foo() in V overrides <T>foo() in U; return type requires unchecked conversion found : C<B> required: C<T> class V extends U { public C<B> foo() { return null; } } ^ 1 warning
Need to check the spec closer since with this case, the return types are not compatible: class C<T> {} class A { C<A> foo() { return null; } } class B extends A { C<B> foo() { return super.foo(); } }
Could be a javac bug.
Is this related to bug 97693?
No its not. This is an issue with comparing a method with an inherited method, its not a cast issue.
Added MethodVerify test82 *** This bug has been marked as a duplicate of 125956 ***