The following code:
class Parent {
public void method(List parameter){
}
}
class Child extends Parent {
public void method(List<String> parameter) {
}
}
fails to compile with the following error:
Parent.java:12: error: name clash: method(List<String>) in Child and method(List) in Parent have the same erasure, yet neither overrides the other
public void method(List<String> parameter) {
^
1 error
But I'm checking that JLS8 in §8.4.8.1 says:
An instance method mC declared in or inherited by class C, overrides from C another method mA declared in class A, iff all of the following are true:
...
The signature of mC is a subsignature (§8.4.2) of the signature of mA.
...
And in §8.4.2 it says:
The signature of a method m1 is a subsignature of the signature of a method m2 if either:
...
the signature of m1 is the same as the erasure (§4.6) of the signature of m2.
And in this case both the original and the overriding method declarations have the same erasure, so why the compilation fails?