mercredi 14 décembre 2016

Java, Reflection, and method invocation

I am having issue with reflection and calling only specific methods. In my case I want to call the method getMyStuff() which may defined in more than one Class.

My classes look similar to this. MainClass will always be the parent. I have a LOT of classes and not all the classes have the getMyStuff() method. I want to be able to call that method and access the return value. I have tried many incarnations of code to get access but nothing seems to work.

Any ideas, Thanks

class MainClass
{
    public ClassA member1;
    public String getMyStuff() {}
}


class ClassA
{
    public ClassB member1;
    public String getMyStuff() {}
}


class ClassB
{
    public String getMyStuff() {}
}





Aucun commentaire:

Enregistrer un commentaire