Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interface I cannot be implemented more than once with different arguments: I<String> and I<String>

I have a problem in eclipse with the following four lines spread over the respective four files:

public interface I<T> {}

public interface ISpecial<T> extends I<T> {}

public class Base implements I<String> {}

public class Special extends Base implements ISpecial<String> {}

Eclipse tells me (and only me and none of the other few people having the same, slightly more complex project imported into their workspace)

The interface I cannot be implemented more than once with different arguments: I<String> and I<String>

This occurs since a few days ago I checked for, and installed, Eclipse updates (which I had not done for months), and changed a few of the "Errors/Warnings" settings in the "Java Compiler" settings dialog (so I do not know whether either of those changes is to blame, but I have since switched everything that could be an "Error" to "Warning" and the problem persists.)

I would like to tactfully submit to Eclipse that <String> is not a different argument from <String>, but do not know how or whether I am missing something here.

Update: After setting the JDK compiler compliance level to 1.5 (from 1.7) the problem went away in the test project I created (with the code above), but not in the more complex project where it originally occurred. In the former, the problem did not come back after setting the compliance level to 1.6 or 1.7 again, so now I myself can no longer reproduce the problem with a minimal example, without having solved the original problem itself.

like image 536
arne.b Avatar asked Feb 21 '12 10:02

arne.b


1 Answers

Usually, the problem is that such warnings/errors do not mention the fully qualified names of the conflicting classes. It is possible to have two "String" classes on your class path, and that "Base.java" imports the first one and "Special.java" the second one. Check your imports: one would probably be java.lang.String, and the other from a different implementation.

like image 59
Alexis Drogoul Avatar answered Oct 05 '22 23:10

Alexis Drogoul