I've found similar topics, but overly complicated and not quite the same. So the thing is. Here's the(minimal) code which is fine on 1.6, but doesn't compile with 1.7 javac.
public class Test {
private static class A<T>{};
private static class B{};
private static class C{};
B doSomething(A<B> arg){
return new B();
}
C doSomething(A<C> arg){
return new C();
}
}
On 1.7 the error is this:
java: name clash: doSomething(Test.A<Test.C>) and doSomething(Test.A<Test.B>) have the same erasure
I understand the type erasure and why it's a wrong code. I just don't understand why we can have this code in our project compiling and running in 1.6, when 1.7 have problems with it. What is wrong? Is it a bug in 1.6 compiler that it allows us to do so? Is it possible to make it work in 1.7 other than rewriting?
- JDK1.6 javac version: 1.6.0_43
- JDK1.7 javac version: 1.7.0_25