Bug 91355 - Overriding method in base class with covariant return type fails with AbstractMethodError
Summary: Overriding method in base class with covariant return type fails with Abstrac...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-13 18:38 EDT by Daniel R Somerfield CLA
Modified: 2005-06-24 13:21 EDT (History)
0 users

See Also:


Attachments
Test Case for bug 91355 (3.55 KB, application/zip)
2005-04-13 18:40 EDT, Daniel R Somerfield CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel R Somerfield CLA 2005-04-13 18:38:59 EDT
"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.
Comment 1 Daniel R Somerfield CLA 2005-04-13 18:40:06 EDT
Created attachment 19889 [details]
Test Case for bug 91355
Comment 2 Kent Johnson CLA 2005-04-14 11:23:40 EDT
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()
Comment 3 Daniel R Somerfield CLA 2005-04-14 12:59:54 EDT
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"

Comment 4 Kent Johnson CLA 2005-04-14 13:18:56 EDT
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.
Comment 5 Daniel R Somerfield CLA 2005-04-14 20:10:47 EDT
I was running on M4. It appears to be ok in M6. Sorry for the bother.