Community
Participate
Working Groups
Build ID: M20080911-1700 Steps To Reproduce: The following two program variants produce different error messages, where I would expect similar messages: Variant A: public interface I1 { Object m(); } public abstract class C1 { public abstract String m(); } public class C2 extends C1 implements I1 { } => The type C2 must implement the inherited abstract method C1.m() Variant B: public interface I1 { String m(); } public abstract class C1 { public abstract Object m(); } public class C2 extends C1 implements I1 { } => The return type is incompatible with I1.m(), C1.m() This difference is funny since both problems can be mended with the same fix: insert into C2: public String m() { return null; }
In the first case, the only issue is the missing implementor in C2 of the abstract method C1.m(). The return type of this method must be String which is a subtype of Object from I1.m() In the second case, we're not comparing the 2 inherited methods properly. The error in the second case should never be reported, in which case we'll report the same missing implementation error as case 1. Philippe - we should likely fix this in 3.4.2 - ok ?
Created attachment 114126 [details] Proposed patch with testcase Includes patch for bug 243820 which touches MethodVerifier15 but hasn't been released yet
Looks good. +1 for 3.4.2. BTW - is the problem that specific to classes ? interface I1 { Object m(); } interface I2 { String m(); } public class X implements I1, I2 { } Here we do complain about missing impl for I1.m(), but shouldn't it complain instead about I2.m() ? (since most specific return type). Note: javac 6 doesn't do better...
I agree that we could find the most specific inherited method, but its not a very common case & definitely not something we would need to do for 3.4.2 If you want it, then we should open a new bug for 3.5
Created attachment 114348 [details] Proposed patch with testcase for 3.4.2
Fix and test released for 3.4.2
Fix and test released for 3.5M3
Verified for 3.5M3 using I20081026-2000 build.
Verified for 3.4.2 using M20090121-1700 build.