使用IntelliJ设置的断点不在远程自定义java代理的premain中工作 [英] Breakpoint set with IntelliJ not working in premain of remote custom java agent
问题描述
我已经开始实现一个简单的Java代理,它在JVM加载类之前执行一些检测。问题是我需要对这个代理进行一些调试,但到目前为止我尝试的都失败了(我试图远程调试代理但它没有工作)
I've started to implement a simple Java agent that does some instrumentation before a class is loaded by JVM. The thing is I need to do some debugging on this agent, but what I tried so far had failed( I tried to remote debug the agent but it's not working)
I使用IntelliJ和Maven(生成.jar代理)。
I use IntelliJ and Maven( to generate the .jar agent).
所以我的问题:远程调试一个简单的java代理有什么技巧吗?
So my question:Is there any trick to remote debug a simple java agent?
推荐答案
事实证明我有一个演示Java工具的项目,我已经在IntelliJ中测试了调试。断点有效。您可以将其用作参考。
As it turns out I have a project that demos Java instrumentation, which I have tested out debugging in IntelliJ. Breakpoints work. You can use it as a reference.
https ://github.com/noahlz/weaver-demo
IntelliJ的示例运行/调试配置
Sample run/debug configuration from IntelliJ
,如果您正在远程调试,则可以在可以附加到调试器之前执行premain。尝试在您传递给运行代理程序代码的JVM的debug命令中将 suspend = n
更改为 suspend = y
。这样,它将一直等到你继续使用IntelliJ进行连接。
Also, if you are debugging remotely, the premain might be executing before you can attach to the debugger. Try changing suspend=n
to suspend=y
in the debug command you are passing to the JVM running the agent code. That way, it will wait until you connect with IntelliJ before proceeding.
这篇关于使用IntelliJ设置的断点不在远程自定义java代理的premain中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!