【发布时间】:2017-10-21 14:12:33
【问题描述】:
我想收集特定方法显式和隐式调用的方法。例如:
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);
}
}
从上面的代码中,我想收集 A 类的方法 foo 使用参数“abc”和“def”调用 B 的 print() 方法的信息。类似于调用图的东西
A::foo
--> B::print("abc")
--> C::anotherPrint("def")
--> B::print("def")
【问题讨论】:
-
恐怕这个问题太宽泛了,你应该从研究一些现有的解决方案开始,比如github.com/gousiosg/java-callgraph。另见stackoverflow.com/questions/4951517/…
标签: java code-analysis call-graph