4

I have the following interface:

public interface Translator { public <T, F> T translate(F from, T to, Class<T> clazz); } 

and the following implementation:

class TranslatorImpl implements Translator { @Override public <T, F> T translate(F from, T to, Class<T> clazz) { //some code } } 

But for the translate() method in the TranslatorImpl class, Eclipse complains as follows:

Name clash: The method translate(F, T, Class) of type TranslatorImpl has the same erasure as translate(F, T, Class) of type Translator but does not override it

Update: When I do a Maven build it builds properly. I use JDK 1.6 update 31. The JDK compliance level in Eclipse is 1.6

How do I overcome this?

Update 2:

Compliance level settings: enter image description here

Installed JRE: enter image description here

Update 3: Contents of my .classpath file:

<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" output="target/classes" path="src/main/java"/> <classpathentry kind="src" output="target/test-classes" path="src/test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/dbmodel"/> <classpathentry combineaccessrules="false" kind="src" path="/uimodel"/> <classpathentry combineaccessrules="false" kind="src" path="/common"/> <classpathentry kind="var" path="MAXIMUS_DEV_DIR/resources/dependencies/java/log4j/log4j-1.2.16/log4j-1.2.16.jar"/> <classpathentry kind="output" path="target/classes"/> </classpath> 

Update 4: project specific compiler compliance level settings: enter image description here

5
  • 2
    Works as it should for me. What compiler do you use? Commented Apr 14, 2012 at 9:28
  • You don't need the third parameter, unless you are planning to supply null as the second parameter. Commented Apr 14, 2012 at 9:30
  • It is Eclipse which is creating the problems. When I do a Maven build it builds properly. I use JDK 1.6 update 31. The JDK compliance level in Eclipse is 1.6 Commented Apr 14, 2012 at 9:33
  • Since this is Eclipse specific, can you try removing your implementation altogether? This way Eclipse will complain and suggest you what to do Commented Apr 14, 2012 at 10:22
  • Works for me no problem. Upgrade to the latest version of Eclipse and try again. Commented Apr 14, 2012 at 10:37

1 Answer 1

1

Prior Java 6 @Override annotation was not allowed for implementing interfaces, this is probably what is happenning. You can try removing the annotation and it should work. To fix properly check source level compliance in eclipse project properties.

Sign up to request clarification or add additional context in comments.

8 Comments

I am using JDK 1.6. Eclipse 3.7. Compiler compliance level: 1.6
Source or binary? On the project or eclipse wide? Please be very specific as to how you know that complience is 1.6.
@hgrey... see my update. Please tell me if I am missing anything.
You show eclipse wide default compliance, check project properties. You can access them via context menu
It is the same for both. I have not configured project specific settings.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.