Attach to another JVM and listen to events? Possible?

I am trying to write a small internal tool to use for debugging focus tasks in Swing applications. Right now, the debugger tool is built into the application and enabled using the debug command line argument.

I would like for me to have a separate standalone Java application that can connect to another JVM and listen for certain events (in this case PropertyChangeEvents on KeyboardFocusManager).

Ideally, it should be able to do this without any changes to the debugged application, so it can be used β€œon demand” to debug focus problems in any Swing application. It looks like VisualVM can connect to any running virtual machine.

Is it possible? What are some starting points? Jmx? Any other IPC mechanism?

+2
source share
2 answers

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

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

You can connect the debugger to a remote process using Eclipse.

+2
source

You can use java platform debugger architecture (JPDA)

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

+4
source

Source: https://habr.com/ru/post/916407/


All Articles