Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird Erasure in Java Generics
    primarykey
    data
    text
    <p>I have the following interface:</p> <pre><code>public interface Translator { public &lt;T, F&gt; T translate(F from, T to, Class&lt;T&gt; clazz); } </code></pre> <p>and the following implementation:</p> <pre><code>class TranslatorImpl implements Translator { @Override public &lt;T, F&gt; T translate(F from, T to, Class&lt;T&gt; clazz) { //some code } } </code></pre> <p>But for the <code>translate()</code> method in the <code>TranslatorImpl</code> class, Eclipse complains as follows:</p> <blockquote> <p>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</p> </blockquote> <p>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</p> <p>How do I overcome this?</p> <p>Update 2:</p> <p>Compliance level settings: <img src="https://i.stack.imgur.com/MCIec.png" alt="enter image description here"></p> <p>Installed JRE: <img src="https://i.stack.imgur.com/zDiMW.png" alt="enter image description here"></p> <p>Update 3: Contents of my <code>.classpath</code> file:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;classpath&gt; &lt;classpathentry kind="src" output="target/classes" path="src/main/java"/&gt; &lt;classpathentry kind="src" output="target/test-classes" path="src/test/java"/&gt; &lt;classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/&gt; &lt;classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/&gt; &lt;classpathentry combineaccessrules="false" kind="src" path="/dbmodel"/&gt; &lt;classpathentry combineaccessrules="false" kind="src" path="/uimodel"/&gt; &lt;classpathentry combineaccessrules="false" kind="src" path="/common"/&gt; &lt;classpathentry kind="var" path="MAXIMUS_DEV_DIR/resources/dependencies/java/log4j/log4j-1.2.16/log4j-1.2.16.jar"/&gt; &lt;classpathentry kind="output" path="target/classes"/&gt; &lt;/classpath&gt; </code></pre> <p>Update 4: project specific compiler compliance level settings: <img src="https://i.stack.imgur.com/QuX8f.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload