JVM堆栈内省(JVM stack introspection)

编程入门 行业动态 更新时间:2024-10-24 08:30:08
JVM堆栈内省(JVM stack introspection)

有没有办法在JVM上以编程方式检查堆栈的内容(包括值和值的类型以及当前指令点)(即使它是特定于供应商的)?

例如,我想检查当前的激活框架并提取它所属的方法名称,以及堆栈变量。 此外,我希望能够以这种方式迭代激活帧。

这可能吗? 乍一看, JVMTI似乎允许这样做,但它意味着用作本机接口。 它已被用于实现一个可以做这些事情的Java库 - 显然 - 但这似乎有点过时了。 我想知道是否有一个集成到JVM api中的解决方案,或者是否允许这样的其他跨平台JVM库。

Is there a way to inspect the contents of the stack (both in terms of the values and the type of the values, and the current instruction point) programmatically on the JVM (even if it's vendor-specific)?

For example, I would like to inspect the current activation frame and extract the method name it belongs to, as well as stack variables. Furthermore, I would like to be able to iterate activation frames in this way.

Is this possible? At a first glance, the JVMTI seems to allow this, but its meant to be used as a native interface. It has been used to implement a Java library that can do these things, apparently - but this seems to be a bit dated. I was wondering if there is a solution integrated into the JVM api, or some other cross-platform JVM library that allows this.

最满意答案

我相信Java平台调试器架构(JPDA)正是您所需要的。

I believe Java Platform Debugger Architecture (JPDA) is what you are looking for.

更多推荐

本文发布于:2023-07-04 10:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023536.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:堆栈   JVM   introspection   stack

发布评论

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

>www.elefans.com

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