Given the following hypothetical type hierarchy:
BaseElement
+ StringElement
+ ....
+ ....
+ BooleanElement
+ ....
+ ....
+ ...
I have a class interface in the form:
IBaseElementService createElementService(Class<? extends BaseElement> element);
IBooleanElementService createElementService(Class<? extends BooleanElement> element);
This compiles well in eclipse 3.4 but not anymore with eclipse 3.6, failing with the error:
Method ... has the same erasure createElementService(Class<T>) as another method in this type
I’m a little puzzled why this compiles under eclipse 3.4 since the type is removed by the java compiler. But anyways, is there an elegant way to change this without renaming the methods?
Thanks!
EDIT: As it was pointed out by multiple people, this seems to be an eclipse 3.4 – 3.5 bug. eclipse bug report (Thanks denis.solonenko for the link!)
If someone is interested about technical details of this bug, make sure to read the post from Paŭlo Ebermann, thx!
Renamed the methods. (but why do you have two methods? maybe the 1st one should be the only public one; it can check the class type and forward to the 2nd method for BooleanElement)
By current language spec, your two methods should compile. see here. I heard in Java 7 such 2 methods cannot coexist anymore. Not sure about the rationale.