There are already some discussions here on stackoverflow about Java generics, but I am too stupid to solve this specific question. I have defined an interface in a project, and its implementation in another one. They are in different packages. Instead of implementing the method, the compiler complains in some workspaces:
Name clash: The method highlight(EnumSet, int, int) of type SuperDuperHighlightable has the same erasure as highlight(EnumSet, int, int) of type IHighlightable but does not override it
The same code does not complain in other workspaces, and I cannot find the relevant differences. All projects and workspaces use JRE SE 1.5.
HighlightingStyle.java
package org.my.api;
public enum HighlightingStyle {
NONE, FIELD, SELECTION, TEST
}
IHighlightable.java
package org.my.api;
import java.util.EnumSet;
import javax.swing.text.BadLocationException;
public interface IHighlightable {
void highlight(EnumSet<HighlightingStyle> style, int start, int length)
throws BadLocationException, IllegalArgumentException;
}
Implementation:
package org.my.impl;
import java.util.EnumSet;
import javax.swing.text.BadLocationException;
import org.my.api.HighlightingStyle;
import org.my.api.IHighlightable;
public class SuperDuperHighlightable implements IHighlightable {
public void highlight(EnumSet<HighlightingStyle> styleSet, int start, int length)
throws BadLocationException, IllegalArgumentException {
for (HighlightingStyle style : styleSet) {
DoSomething(style, start, length);
}
}
private void DoSomething(HighlightingStyle style, int start, int length) {
// TODO Auto-generated method stub
}
}
Do you have any insights if this is a source-code problem, a workspace problem, or some problem with Eclipse?