dimanche 21 août 2016

Simple way to find method 'parents' at runtime?

I'm trying to find a simple way to retrieve 'parents' of a method at runtime. (Possibly using reflection) By 'parents' of a method, I mean the 'super' methods of said method, the ones said method is overriding or implementing. This would ideally also work with Generics.

Example:

public interface Class1<O> {
    void doSomething(O s);
}

public interface Class2 {
    void doSomething(String s);
}

public class Class3 implements Class1<String>, Class2 {
    public void doSomething(String s) {
        // Something
    }
}

Here it should retrieve Class1#doSomething and Class2#doSomething if I wanted to get the 'parents' of Class3#doSomething. Does any such method exist in Java or is it even possible?





Aucun commentaire:

Enregistrer un commentaire