Attach to another JVM and listen for events? Possible?

北战南征 提交于 2019-12-24 02:15:30

问题


I am trying to write a small internal tool to use for debugging focus problems in Swing applications. Right now the debugger tool is built in to the app and enabled via a debug command-line argument.

What I'd love to do is have a separate, standalone Java application that can connect to another JVM and listen for certain events (in this case, PropertyChangeEvents on the KeyboardFocusManager).

Ideally, it should be able to do this without any changes to the application being debugged, so it can be used "on-demand" to debug focus issues in any Swing app. Sort of like how VisualVM can attach to any running VM.

Is this possible? What are some starting points? JMX? Some other IPC mechanism?


回答1:


Not sure if this covers it, but.. Assuming the application is started with these flags:

-Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n

You can attach the debugger to the process remotely using Eclipse.




回答2:


You can use the java platform debugger architecture (JPDA)

http://download.oracle.com/javase/6/docs/technotes/guides/jpda/examples.html



来源:https://stackoverflow.com/questions/5410054/attach-to-another-jvm-and-listen-for-events-possible

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