Eclipse complains about a name conflict if an interface is implemented with a method containing a common argument
There are already some discussions here on stackoverflow about Java generics, but I'm too stupid to solve this particular question. I have defined an interface in a project and its implementation in another. They are in different packages. Instead of implementing the method, the compiler complains about some work areas:
Name notation: the highlight (EnumSet, int, int) method of type SuperDuperHighlightable has the same erasure as the highlight (EnumSet, int, int) of type IHighlightable, but does not cancel it
The same code does not complain about other work areas and I cannot find any 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 idea if this is a source code issue, workspace issue, or Eclipse issue?
source to share
No solution, but some tips and tests:
- Clear all projects in workspace, sometimes it helps with eclipse based problems.
- Make sure you only have 'HighlightingStyle' in the classfile. Perhaps the implementation is getting the HighlightingStyle from another source / classloader. Maybe there is a library on the classpath that includes an enum and / or interface
- Rename the enum and check if the refactoring changes the name in both the interface and implementation.
Hope this helps solve your problem.
Edit
It didn't work out correctly that it works in some workspaces. So I'm pretty sure this is a workspace setup issue or even a bug. At this point, I personally will not continue to fix this issue, but simply zip all projects into one archive, move or rename the entire workspace, create a new one (one name, original location) and import all archived projects. If everything is ok, delete the moved or renamed workspace.
Of course you lose your workspace settings and I cannot tell if this is the problem in your case. I've done this before on some occasions (I had an ugly problem with subversion and mercury plugins ....) and it's pretty easy.
source to share