dimanche 8 décembre 2019

How do you find a parameterised overridden method with reflection?

Given a situation like the following:

interface A<T>{
    default void foo(T t){
        System.err.println(new Exception().getStackTrace()[0] + " " + t);
    }
}

interface B<T extends SomeConcreteType> extends A<T>{
    @Override
    default void foo(T t){
        System.err.println(new Exception().getStackTrace()[0] + " " + t);
    }
}

I'm trying to use reflection to go from a B's foo method to A's foo method. Given that the post erasure parameter types of the two methods are different, how can I do this?





Aucun commentaire:

Enregistrer un commentaire