IDEA does not compile code from Eclipse

the following code compiles within Eclipse, but not within IDEA:

    public Vector<SomeOtherType> getChildren()

where the superclass has just:
   public Vector getChildren()

IDEA reports a compilation error:
Error:Error:line (1.621)getChildren() in ... cannot override getChildren() in ...; attempting to use incompatible return type
found   : java.util.Vector<SomeOtherType>

does anybody know if Eclipse does compile something illegal here, or if IDEA fails to compile something legal?


Comment actions Permalink

an additional remark: IDEA does not mark this code as error in the editor...

Comment actions Permalink

IIRC, IDEA does not compile anything, but instead uses javac. BTW, we have
the opposite case: javac compiles fine, but Eclipse doesn't.

Comment actions Permalink

yes, javac does not compile this code. Note that IDEA does not highlight it as error.

I found that the original method comes from an interface where it is defined like this
java.util.Vector<ParentNode> getChildren()

and the non-compiling implementation tried to use SomeType instead of ParentNode,
which seems to be not allowed (in javac) even if SomeType extens ParentNode.

So my conclusion is that Eclipse uses some compiler which compiles something it shouldn't.

Comment actions Permalink

By default eclipse uses its own compiler and not javac
You can get IDEA to use the eclipse compiler if you want by Settings -> Compiler -> Java Compiler ->Use Compiler


Please sign in to leave a comment.