Name clash: The method BLAH has the same erasure as type BLAH but does not override it
I was getting the following error in Eclipse IDE 3.1 and Java 1.5 (or 5.0 as some like to call it):
Name clash: The method removeEldestEntry(Map.Entry<K ,V>) of type LRUMap<K ,V> has the
same erasure as removeEldestEntry(Map.Entry<K , V>) of type LinkedHashMap<K , V> but does not
override it
The class in question looked like this:
class LRUMap <K , V> extends LinkedHashMap {
public LRUMap(){
super(10000, .75f, true);
}
protected boolean removeEldestEntry (Entry <K , V> eldest) {
return this.size() > 262144;
}
}
The problem is that I was extending LinkedHashMap without type parameters, not LinkedHashMap >K ,V<. Changing the code to:
class LRUMap <K , V> extends LinkedHashMap <K , V> {
public LRUMap(){
super(10000, .75f, true);
}
protected boolean removeEldestEntry (Entry <K , V> eldest) {
return this.size() > 262144;
}
}
completely fixed the problem! Type erasure is sure a pain, no? I should probably spend more time at home reading the Java Generics Tutorial.
| This entry was posted on Sunday, December 24th, 2006 at 11:27 am and is tagged with eclipse ide, type parameters, java generics, time at home, boolean, blah, clash, lt, erasure, map. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback. |
20 Responses to “Name clash: The method BLAH has the same erasure as type BLAH but does not override it”
Leave a Reply

Thanx for the post. Google + you saved me a lot of trouble.
Generics are PITA
Karma & kudos, saved me time & pain as well.
Wow. i spend 30 minutes staring at 20 lines of code trying to figure it out before finally swallowing my pride and googling the problem. and this hit the nail on the head.
thank you you saved my life
Like all the above..thanks!
thanks a bunch!
You are my hero!! I spent way too long trying to figure this one out.
Thank God
FTW!
Thanks for posting this.
Thanks for posting this. It saved me tons of trouble!
Hi,
Unfortunately, I still have a problem.
I get the error if I try to override the following:
abstract String method(List s);
with:
@Override
public String method(List) {
}
Where is the error?
THANK YOU!!!
Thank you so much, this definitely saved me a lot of time.
Same problem. 3 hours later, I found your post and that's it: You made my day!
Is it me or a variable name is missing after your parameter type (List) ???
Thanks so much. That saved me a ton of time!
You saved my life. Thx
Thanks man, I couldn’t figure out what was going on for the life of me.
Thanks, saved me some time