Announcing a New Tool and Methodology: Java Surgery
kgibm 0600027VAP Comments (6) Visits (4568)
I'm proud to announce a new tool I've been cooking recently: IBM Runtime Diagnostic Code Injection for the Java™ Platform (RDCI). The tool is an extensible command line JAR that uses the Late Attach API to inject Java code into a running JVM, allowing both exploratory and invasive surgery on a Java process. It uses a custom classloader to minimize the "scar" left on the process. Example commands include: Run a full garbage collection, execute a static method, perform a javacore, heapdump or system dump on IBM JVMs, and install an OSGi bundle. Let me know what other commands you need.
The idea came up when a colleague wanted to run something like "kill -3" on Windows to get a thread dump. Windows doesn't have such a command (the Ctrl+Break handler needs a console attached which it usually isn't). There are various supported methods such as MBeans and Health Center, but they're not as easy to use as kill -3. There is a clever program called SendSignal.exe which uses some tricks (in some cases with assembler!) to get the address of the Ctrl+Break handler and then starts a remote thread in the process to emulate the Ctrl+Break command. It works in many cases, but it's unsupported and has had more issues as Windows security has continued to harden. RDCI was built to solve this and other similar problems:
RDCI is also an exploration of this new problem determination methodology of iteratively performing surgery on a Java process without restarting it. The initial use case is very simple but I suspect that as availability continues to be important, we will need to find creative ways to fix problems without killing and reviving the patient as we often do now with restarts.