0

I wanna collect the methods invoked by a specific method both explicitly and implicitly.For example:

Class A {
@Autowired 
C c;

foo() {
    B b = new B();
    b.print("abc");
    if (somecondition) {
        c.anotherPrint("def");
    }
}

Class B {
    print(String arg) {
    }
}

Class C {
    @Autowired
    B b;
    anotherPrint(String arg) {
        b.print(arg);
    }
}

From the code above I wanna collect the information that Class A's method foo invoke B's print() method with the argument "abc" and "def".Something like a call graph

A::foo 
    -->  B::print("abc")
    -->  C::anotherPrint("def")
            --> B::print("def")
  • Too broad as a question I'm afraid, you should probably start out by studying some of the existing solutions, like https://github.com/gousiosg/java-callgraph . Also see https://stackoverflow.com/questions/4951517/static-analysis-of-java-call-graph – fvu Oct 21 '17 at 14:15

1 Answers1

0

I don't see how to use different method for this purpose, but you can just add some markers that will indicate that method was invoked. For example it might be logger or simply some field countOfInvokes which you will increase inside the method.

Russiancold
  • 952
  • 1
  • 7
  • 20