如何生成 Java 调用图,基于 Eclipse 的解决方案 [英] How to generate a Java call graph, Eclipse based solutions

查看:55
本文介绍了如何生成 Java 调用图,基于 Eclipse 的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想分析和理解某个 Java 应用程序,我认为调用图会非常有用.我如何生成一个?我正在使用 Eclipse.

I'd like to analyze and understand a certain Java app and I think a call graph would be very useful. How do I generate one? I'm using Eclipse.

推荐答案

获取调用堆栈

1) 如果您可以调试,应用程序只需放置一个断点(双击代码的左边距)并等待它停止.如果您不在那里,请转到 Debug Perspective,然后打开 Call stack View/Panel.它有调用堆栈:)

1) If you can debug the application simply put a breakpoint (double click over the left margin of the code) and wait it to stop. Go to Debug Perspective if you're not there, and open the Call stack View/Panel. It has the call stack :)

2) 如果您想在某处打印此堆栈跟踪,请使用异常:

2) If you want to print this stack trace somewhere use an Exception:

Exception aux = new Exception("I'm here"); // not for throwing!
aux.printStackTrace(); // if you want it in stdout

Exception aux = new Exception("I'm here"); // not for throwing!
StringWriter sw = new StringWriter();
aux.printStackTrace(new PrintWriter(sw));
String result = sw.toString(); // if you want it in a string

获取方法引用

您可以通过右键单击引用"、工作区"来获取对方法的所有引用.它将搜索您当前打开的项目中的所有调用.非常非常有用.

You can obtain all references to a method by right-clicking, References, Workspace. It will search all callings in your current open projects. Very very useful.

分析应用

(感谢回答分析器选项的人)

(thanks those who had answered the profiler option)

Eclipse TPTP 提供分析:

Eclipse TPTP provides profiling:

http://www.eclipse.org/tptp/home/project_info/general/whatisTPTP.php

这篇关于如何生成 Java 调用图,基于 Eclipse 的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆