Breakpoint set with IntelliJ not working in premain of remote custom java agent

。_饼干妹妹 提交于 2020-01-14 12:19:25

问题


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 use IntelliJ and Maven( to generate the .jar agent).

So my question:Is there any trick to remote debug a simple java agent?


回答1:


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

Sample run/debug configuration from 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.



来源:https://stackoverflow.com/questions/16105615/breakpoint-set-with-intellij-not-working-in-premain-of-remote-custom-java-agent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!