Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Covariant Return Types
Covariant Return Types [message #250309] Mon, 07 June 2004 22:56 Go to next message
Eclipse UserFriend
Originally posted by: robert.elliot.dial.pipex.com

Hi all. I've met an issue with Eclipse 3 M9 (and also as it happens
WSAD5) which isn't really a bug as such. Basically, I've written an API
using Java 1.5 syntax, including covariant return types. Having compiled
it up using a 1.5 javac, I ran an excellent little utility called
Retroweaver over it which transforms 1.5 byte code to make it 1.2, 1.3 and
1.4 compatible. Then jarred it up, and imported the jar into an Eclipse
Java project; but Eclipse doesn't like it. The API contains 2 classes
effectively doing the following:

// Initial class
public abstract class Foo {
protected Object foo() {
return "Hi";
}
}

// Subclass that over-rides foo() with a covariant return type
public abstract class FooExt extends Foo {
protected String foo() {
return (String) super.foo();
}
}

The intention of the API is that clients subclass FooExt to provide public
methods. So having brought the API jar into a Java 1.3 Eclipse project, I
created a new java file subclassing FooExt as follows:

public class Bar extends FooExt {
public String getText() {
return foo();
}
}

Now that will compile fine from the command line using a 1.3 javac with a
-classpath pointing at my bytecode modified API jar, and the result will
run fine on a 1.3 JVM. However, both Eclipse & WSAD really don't like it
because of the covariant return types; I get a red X by the first line of
the class and doing mouse over displays the following error message:

- The return type is incompatible with Foo.foo(), FooExt.foo()

So my query is, do the Eclipse team think this is something worth "fixing"
in Eclipse, since 1.3 compilers and JVMs are happy with it? Or do they
consider that this is a (useful!) bug in the 1.3 compilers and JVMs since
they are not meant to support covariant return types, and so not something
Eclipse should be worried about?

Regards,
Rob
Re: Covariant Return Types [message #251132 is a reply to message #250309] Wed, 09 June 2004 18:31 Go to previous message
Eclipse UserFriend
Originally posted by: akiezun.cutthis.mit.this.edu.andthis

if you think this is a bug, please enter a report.
a.
Previous Topic:RC1 create IFolder in IProject help please
Next Topic:Please explain: MANIFEST.MF, OSGi, plugin.xml
Goto Forum:
  


Current Time: Fri Jul 19 14:22:21 GMT 2024

Powered by FUDForum. Page generated in 0.03484 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top