This question goes from my previous post in here.. Before I post my question, I am pasting the contents from oracle docs;
8.4.8.1. Overriding (by Instance Methods)
An instance method m1, declared in class C, overrides another instance method m2, declared in class A iff all of the following are true:
C is a subclass of A.
The signature of m1 is a subsignature (§8.4.2) of the signature of m2.
8.4.2. Method Signature
The signature of a method m1 is a subsignature of the signature of a method m2 if either:
m2 has the same signature as m1, or
the signature of m1 is the same as the erasure (§4.6) of the signature of m2.
My understanding of type erasure
when overriding
is involved is as follows:
if after erasure
, the signature of m1 and m2
are same, then then they are considered overridden
.
so in my previous post above, I tried to override
a parent class method
that takes
List<String>
by a subclass method
that takes List<Integer>
assuming after type erasure
what is left is just List<Object>
. but that is wrong. so my understanding of the above definition
of method overriding
when erasure
is involved is totally wrong. can some give a simple
example to explain the above point.
Thanks. btw the above points come from here.