如何生成 Java 调用图,基于 Eclipse 的解决方案

编程入门 行业动态 更新时间:2024-10-26 13:23:55
本文介绍了如何生成 Java 调用图,基于 Eclipse 的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我想分析和理解某个 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/tptp/home/project_info/general/whatisTPTP.php

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

更多推荐

[db:关键词]

本文发布于:2023-04-01 09:39:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/826488.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决方案   Java   Eclipse

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!