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

查看:268
本文介绍了如何生成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,然后打开调用堆栈视图/面板。它具有调用堆栈:)

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)如果要在某个地方打印此堆栈跟踪,请使用Exception:

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.

配置应用程序

(感谢回答过的人

Eclipse TPTP提供了概要分析:

Eclipse TPTP provides profiling:

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

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

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