I am writing a messaging component and for certain reasons I need to find out which methods of a class are qualified to be called by the messaging component. Among other criteria, these methods need to be implementing a particular interface. How do I find out exactly these methods via reflection? I do have access to th class but I must not rely on the method names. There could be similar methods in the class that have the same name but not implement the desired (or any) interface. Example:
interface A
{
long set(Object object)
}
class B implements A
{
public long set(Object object)
{
System.out.println("I am the method they are looking for!");
}
public void set(int i, int j)
{
System.out.println("I am not the qualifying method!");
}
}
So, in short words, I want to find the first method through reflection but not the second one. Is this possible in Java?
Aucun commentaire:
Enregistrer un commentaire