问题描述
我想要做的是扫描一组Java类,并从Abstract Class的特定方法跟踪所有方法调用,并在该上下文中,构建执行某些操作的所有代码的列表(在此case,实例化某个类的实例)。我想知道,行号和提供的参数。
What I'd like to do is scan a set of Java classes, and trace all method calls from a specific method of an Abstract Class, and within that context, build a list of all code which performs some operation (in this case, instantiates an instance of a certain class). I want to know, the line number, and the arguments supplied.
我已经开始关注BCEL,但它似乎没有内置调用图跟踪?我很犹豫要自己编写,因为获得重载,类型签名和多态调度权限可能会很棘手。
I've begun looking at BCEL, but it doesn't seem to have call graph tracing built in? I'm hesitant to write my own because getting the overloading, type signatures and polymorphic dispatch right might be be tricky.
我有一半期望工具或示例代码存在,但我还没有找到任何东西。我真的觉得我要重新发明一个轮子。但是,如果我这样做将是一个开源轮,可在GitHub上使用; - )
I half expected a tool or example code to exist, but I haven't found anything yet. It really feels like I'm about to reinvent a wheel. But if I do it will be an open source wheel and available on GitHub ;-)
PS:你会发现现有的问题,因为它听起来完全相同,但它根本不是我需要的。
PS: You will find the existing question "How to Generator a Java Call Graph", because it sounds identical, but it's not at all what I need.
推荐答案
您可以使用工具套件,为Java创建足够准确的静态和动态调用图。
You can use the java-callgraph tool suite to create accurate enough static and dynamic callgraphs for Java.
这篇关于Java调用图的静态分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!