访问Java调用堆栈 [英] Accessing the Java call stack

查看:120
本文介绍了访问Java调用堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以从一个方法中访问调用堆栈,看看哪个方法在哪个包中调用了我们现在的方法?

I would like to know if it's possible to access the call stack from within a method to see which method in which package called the one we are in now?

或许还有另一种方法可以做到这一点?

Or perhaps there is another way of doing this?

谢谢,

ExtremeCoder

ExtremeCoder

PS这都是Java

P.S. This is all in Java

推荐答案

有一种方法:

Thread.currentThread().getStackTrace()

但是应该除了用于调试目的之外,不应该这样做。

But there should not be a reason to do this other than for debug purposes.

这篇关于访问Java调用堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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