Community
Participate
Working Groups
Consider the following interface that employs the generic type T: public interface MyInterface<T> { public void method1(T t); public void method2(T t); } And now consider the following implementation of this iterface, which also employs the generic type T: public class MyClass<T> implements MyInterface<T> { public void method1(T t) { //... } public void method2(T t) { //... } } This all compiles fine. But, introducing a bug into MyInterface<T>, results in very confusing compilation errors in both MyInterface<T> and, strangely enough, MyClass<T>. Changing MyInterface<T> to: public interface MyInterface<T> { public void method1(T t); public void method2(T t); public void method2(T t); // DOES NOT COMPILE: Duplicate method } results in the following error against both duplicate method2(T) methods: "Method method2(T) has the same erasure method2(Object) as another method in type MyInterface<T>" This, of course is correct, be it rather cryptic. I'd rather see the error: "Duplicate method method2(T) in type MyInterface<T>" But that's not the worst of it. Look at the class MyClass<T> you'll see the following errors, both of which are COMPLETELY UNRELATED to the duplicate method2(T) method: "Name clash: The method method1(T) of type MyClass<T> has the same erasure as method1(Object) of type MyInterface<T> but does not override it" "The type MyClass<T> must implement the inherited abstract method MyInterface<T>.method1(Object)" This makes for some seriously difficult problems to resolve.
With the latest I build & the 3.3 build, I do get the problems mentioned on method1. I do get the 2 errors on method2() : "Method method2(T) has the same erasure method2(Object) as another method in type MyInterface<T>" But we have no plans to change it - with generics, users are aware of erasures.
The method1 name clash error was the most troubling, so it is good that it's gone. I appreciate the argument for the erasure error message. Thanks.
Verified for 3.4M2