Static analysis of Java call graph

前端 未结 6 1582
無奈伤痛
無奈伤痛 2020-12-02 17:33

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

相关标签:
6条回答
  • 2020-12-02 17:49

    For a 'recent' Eclipse install (relative to the question), see Certiv CallGraph.

    CallGraph enables graphical analysis of program call relations and flow sequencing. Also enables exploration of extended class inheritance hierarchies.

    Call-path analysis and class hieararchy resolution are performed using the JDT platform Search and Call Hierarchy mechanisms.

    Sequence diagrams are generated from a static analysis of of the JDT platform AST for any selected class or method.

    Uses Zest as the graphics visualization engine.

    You can install it via the Eclipse marketplace. I am not involved in making this. You cannot zoom out which is not very practical but has support for Sequence Diagram which is nice and allows to open/close nodes on demand to dig further.

    Requirements:

    Eclipse 4.6 (Neon) on Java 8 VM
    Eclipse Zest Visualization Toolkit 1.7
    

    Eclipse Public License v1.0

    0 讨论(0)
  • 2020-12-02 17:50

    You can use the java-callgraph tool suite to create accurate enough static and dynamic callgraphs for Java.

    0 讨论(0)
  • 2020-12-02 17:51

    You can try JavaDepend , it gives many features needed for dependencies and metrics, it provides also a CQL like SQL to request your code base.

    Disclosure: it's a commercial software.

    0 讨论(0)
  • 2020-12-02 17:57

    Soot should allow you to easily achieve what you are looking for: http://www.sable.mcgill.ca/soot/

    It can construct precise call graphs fully automatically.

    You can find all necessary documentation here: http://www.sable.mcgill.ca/soot/tutorial/index.html

    Also, there's an active mailing list for Soot.

    0 讨论(0)
  • 2020-12-02 17:59

    It sounds like you want something that provides access to the abstract syntax and a complete symbol table. Then a custom scan of the ASTs of the functions in the call graph rooted in each implementing method (as indicated by the symbol tables) of an abstract method gives you a chance to locate a new operation whose type is the specific class of interest.

    The DMS Software Reengineering Toolkit is generalized compiler technology providing basic services of parsing, AST building/navigation, symbol table building/navigation, control flow, data flow and call graph construction. DMS has an optional Java Front End that provides a full Java parser, builds Java ASTs and symbol tables, and can construct a call graph. The Java Front End can also read .class files; you weren't clear as to whether you wanted to climb into class files, too, hunting for information.

    The answer you want isn't off the shelf. You need to build some custom code to implement the ideas in the first paragraph, but DMS can provide most of the raw material. It doesn't provide much detail from the .class files (these are used mostly to resolve types in source code).

    0 讨论(0)
  • You can use Doxygen with Graphviz. It is easy to install and use.

    0 讨论(0)
提交回复
热议问题