Suppose
public class A{
public void doSomethingInMethodA(){
int a =0;
System.out.println("value of a :"+a);
}
public static void main(String[] args) {
new A().doSomethingInMethodA();
new B().doSomethingInMethodB();
}
}
class B{
public void doSomethingInMethodB(){
int b =0;
System.out.println("value of b :"+b);
C c = new C();
c.doSomethingInMethodC();
}
}
class C{
public void doSomethingInMethodC(){
int c =0;
System.out.println("value of c :"+c);
}
}
Now how can I know the flow of the program programatically.
Like If I provide the name of class A(class with main method) to some parser class then the parser class should tell me the flow of the program like
Edit:
A(class with main)
-> doSomethingInMethodA()(Class A)
-> doSomethingInMethodB()(Class B) ->doSomethingInMethodC()(Class C)
program flow ends
where -> means it calls
I guess through reflection it is not possible because you can't ask a java.lang.reflect.Method which methods do you call?
Is it possible with StackTraceElement
? I even heard of AspectJ doing something like this
So how to achieve it?