Community
Participate
Working Groups
"A" extends "B". "A" implements "I". "C" implements "I2". "I" has a method with the signature "public I2 doSomething()". B has a method with the signature "public C doSomething()". Due to the covariant return type, B should fulfill the contract for A. Indeed, the compiler thinks so, too. However, the following call will fail with an AbstractMethodError: I impl = new A(); impl.doSomething(); This is easier to show with sample code. Attached.
Created attachment 19889 [details] Test Case for bug 91355
Daniel, can you please double check the testcase. I do not get an AbstractMethodError, but the testcase also does not include any senders of the method doSomething()
The I.doSomething() below is just an explanation. In the example, the method of note is ISourceInterface.get(). If I run TestMain, compiled with javac, it exits normally. If I run it from eclipse, I get: Exception in thread "main" java.lang.AbstractMethodError: test.SourceImpl.get()Ltest/IReturnInterface; at test.TestMain.main(TestMain.java:19) If I look at the generated class files, the one compiled with javac includes two methods: "<init>" with the signature "()V" and "get" with the signature "()test/IReturnInterface;" with the JDT it only has this: "<init>" with the signature "()V"
What build are you running? I can run the testcase fine & if I change AbstractSource to: public abstract class AbstractSource { public ReturnImpl get() { System.out.println("AbstractSource.get()"); return new ReturnImpl(); } } I get "AbstractSource.get()" printed from both javac & Eclipse.
I was running on M4. It appears to be ok in M6. Sorry for the bother.