Generics bring in a lot of goodness to java but they also mean trouble because of the introduction of bridge methods which mean its not easy to locate a method given a name and target because erasure and bridge methods mean clients actually use the bridge rather than the target.
Return types from methods have been omitted because they are not important for this quetion...
class Super{
}
class Sub extends Super{
}
interface Interface<T extends Super>{
method( T t ); // erased -> method( Super super );
}
interface Interface2 extends Interface<T extends Sub>{
method2( T t ); // erased -> method2( Sub sub );
}
class Concrete implements Interface2{
method( Sub sub ); // erased to method( Super super);
method2( Sub sub );
}
how can i programmatically determine that Concrete.method(Super) ends up calling Concrete.method(Sub) ? I would like to avoid calculations based on parameterised types and what not as this gets complicated fast...
I have looked at Springs BridgeMethodResolver but its quite complex and does a lot of stuff, surely theres an easier way.. perhaps theres not..