Community
Participate
Working Groups
Hi, I'v found the following problem with the eclipse compiler. If you have a abstract generic class with an inner class and a method that returns an instance of the inner type, such as: public abstract class Foo<T> { protected class SomeObject { } abstract SomeObject getSomeObject(); } And then you override it normally, implementing the abstract method: public class Bar extends Foo<Baz> { @Override SomeObject getSomeObject() { // TODO Auto-generated method stub return null; } } What you get is a compilation error that states that the return type of getSomeObject is incompatible with the superclass method. Earlier versions (at least up to M4) would report the error in the editor but run the code. Another thing to note is that when the method is autogenerated in a subclass, an import to SomeObject is created that automatically renders a compilation warning that states that SomeObject is never used even if it is. To solve the compilation error, you can qualify the return type of the method in the subclasses, so this: @Override Foo.SomeObject getSomeObject() { // TODO Auto-generated method stub return null; } would yield warnings but no errors. So it seems that there is a problem with qualification of the inner class. I might be wrong, but I think such a construct should be legal and it does run under a version 5 JRE. My apologies if a repeated a report, I searched and couldn't find anything simmilar. Cheers.
With the latest I do not see any problems with this case: public abstract class Foo<T> { protected class SomeObject {} abstract SomeObject getSomeObject(); } class Bar extends Foo<Baz> { @Override SomeObject getSomeObject() { return null; } } class Baz {} Please reopen if you still encounter the problem with a new build or if I extracted the testcase incorrectly.
(In reply to comment #1) > With the latest I do not see any problems with this case: > > public abstract class Foo<T> { > protected class SomeObject {} > abstract SomeObject getSomeObject(); > } > class Bar extends Foo<Baz> { > @Override SomeObject getSomeObject() { return null; } > } > class Baz {} > > Please reopen if you still encounter the problem with a new build or if I > extracted the testcase incorrectly. I tried with RC1. I'll wait until RC2 goes public and retest. Thanks a lot.