所有运行时变量访问的 java 跟踪

发布于 2024-11-18 09:53:41 字数 312 浏览 9 评论 0原文

我需要记录对任何变量或对象的所有运行时访问 我当前的方向是用修改后的字节码标记类文件 性能目前不是问题

BCEL 看起来很不错,可以向字节码中的每个相关操作码添加一些跟踪指令

但是,我还想从源文件中添加一些语义信息 例如这个变量是一个for循环计数器 这需要一些 AST/解析树操作。

那么 ASM / JavaAssist 是更好的选择吗???

记录变量的使用是关键要求 - 因此字节码看起来是处理此问题的正确级别。 但最终我将不得不访问源解析树以获取更多语义信息

有什么想法吗?

PS这将是一个大型长期项目

I need to log all run-time access to any variable or object
My current direction is to markup the classfile with modified bytecode
Performance is not currently an issue

BCEL looks nice to add some trace instructions to each relevant opcode in the bytecode

However, i would also like to add some semantic information from the source file
e.g. this variable is a for-loop counter
This would require some AST / parsing tree manipulation.

So are ASM / JavaAssist better choices ???

Logging the variable-usage is the key requirement - so bytecode looks like the right level to handle this.
But eventually i will have to access the source parse tree to get more semantic information

Any thoughts ?

p.s. this will be a large prolonged project

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文