有没有办法转储堆栈跟踪,而不会在java中抛出异常? [英] Is there a way to dump a stack trace without throwing an exception in java?

查看:97
本文介绍了有没有办法转储堆栈跟踪,而不会在java中抛出异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑为我的Java应用程序创建调试工具。



我想知道是否可以获得堆栈跟踪,就像 Exception.printStackTrace()但实际上没有抛出异常?



我的目标是在任何给定的方法中将堆栈转储查看方法调用者是谁。

解决方案

您还可以尝试 Thread.getAllStackTraces()来获取所有活着的线程的堆栈跟踪图。


I am thinking of creating a debug tool for my Java application.

I am wondering if it is possible to get a stack trace, just like Exception.printStackTrace() but without actually throwing an exception?

My goal is to, in any given method, dump a stack to see who the method caller is.

解决方案

You can also try Thread.getAllStackTraces() to get a map of stack traces for all the threads that are alive.​​​​​​

这篇关于有没有办法转储堆栈跟踪,而不会在java中抛出异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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