如何为java项目生成调用图
是否可以生成应用程序的全局调用图?
基本上我试图找到应用程序中最重要的类。
我正在寻找 Java 的选项。
我尝试过 Doxy Gen,但它只生成继承图。
我当前的脚本:
#! /bin/bash
echo "digraph G
{"
find $1 -name \*.class |
sed s/\\.class$// |
while read x
do
javap -v $x | grep " = class" | sed "s%.*// *%\"$x\" -> %" | sed "s/$1\///" | sed "s/-> \(.*\)$/-> \"\1\"/"
done
echo "}"
Is it possible to generate a global call graph of an application?
Basically I am trying to find the most important class of an application.
I am looking for options for Java.
I have tried Doxy Gen, but it only generates inheritance graphs.
My current script:
#! /bin/bash
echo "digraph G
{"
find $1 -name \*.class |
sed s/\\.class$// |
while read x
do
javap -v $x | grep " = class" | sed "s%.*// *%\"$x\" -> %" | sed "s/$1\///" | sed "s/-> \(.*\)$/-> \"\1\"/"
done
echo "}"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
javap -v
和一些 Perl 将为您提供类之间的依赖关系。您可以使解析器稍微复杂一些并获取方法之间的依赖关系。更新:或者如果您有 *nix 或 cygwin,您可以通过添加页眉和页脚获取依赖项列表
,然后可以将其传递给 dot 以呈现图形。如果您只想知道大多数其他类使用哪些类,正如您的问题所暗示的那样,那么
javap -v
and a bit of perl will get you dependencies between classes. You can make your parser slightly more sophisticated and get dependencies between methods.Update: or if you have either a *nix or cygwin you can get a list of dependencies as
Add a header and a footer and you can pass it to dot to render a graph. If you just want to know which classes are used by the most other classes, as your question implies, then
对于高级代码分析,您可能需要查看 http://www.moosetechnology.org/
干杯< br>
托马斯
(编辑:根据一般要求移至此处,请参阅:如何生成 Java 调用图)
For advanced code analysis you might wanna have a look at http://www.moosetechnology.org/
Cheers
Thomas
(edit: moved down here by general request, See: How to generate a Java call graph)