When comes to bridge method, i do know that java compiler will add them if there's a need so that overriding can be done properly by the subclass (after reading SCJP by mughal and angelikalanger website). But this is a bit confusing as per below:
Before erasure:
class x <T> {
void set(T t){}
}
class y <E> extends x {
void set(E e) {} // name clash here
}
class z<E> extends x {
void set(Object y) {} // no name clash here
}
class z1<E> extends x<T> {
void set(Object y) {} // name clash here
}
after erasure:
class x {
void set (Object t) {}
}
I understand the name clash for class y but why there is no name clash for class z?
Also there is a name clash for class z1? Puzzling
Copyright Notice:Content Author:「yapkm01」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/6557586/java-generics-bridge-method