Here I get the methods from a Tree Class.
Class c = o.getClass();
Method m[] = c.getDeclaredMethods();
The methods are:
public Tree<T>[] getChildren(){
return children;
}
public T getValue(){
return value;
}
In my print function I want to invoke getChildren() until I get to the bottom of the tree.
There is no problem in getting the return value from getValue() or the FIRST getChildren()
System.out.println(m[0].invoke(o));
System.out.println(m[1].invoke(o));
The m[1].invoke returns a Tree. I want to access the getValue from that Tree now. But it has no methods.
Object tempObj = m[1].invoke(o);
Class tempClass = tempObj.getClass();
Method[] m2 = tempClass.getDeclaredMethods();
m2 is an array that should contain the same methods as the original Tree, but its empty.