附加到另一个JVM并收听事件?可能? [英] Attach to another JVM and listen for events? Possible?

查看:108
本文介绍了附加到另一个JVM并收听事件?可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个小内部工具来用于调试Swing应用程序中的焦点问题。现在,调试器工具内置于应用程序中,并通过调试命令行参数启用。

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.

我想做的是单独的独立Java应用程序可以连接到另一个JVM并侦听某些事件(在本例中为KeyboardFocusManager上的PropertyChangeEvents)。

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).

理想情况下,应该能够做到这一点,无需任何更改对于被调试的应用程序,所以可以使用按需来调试任何Swing应用程序中的焦点问题。类似VisualVM可以如何连接到任何正在运行的虚拟机。

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.

这可能吗?有什么起点? JMX?一些其他IPC机制?

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

推荐答案

不知道是否覆盖了它,但是..假设应用程序是以这些标志开始的: / p>

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

您可以使用Eclipse将调试器附加到远程进程。

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

这篇关于附加到另一个JVM并收听事件?可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆