jvmkill is a JVMTI agent written in Rust and built using header files provided by the JDK.
jvmkill has the following dependencies:
- Rust for compilation and linking
- JDK for JVMTI and JNI header files
Development was undertaken on macOS 10.12 using Rust 1.19.0 and Apple JDK 1.8.0_66.
The jvmkill ci pipeline builds the agent for various platforms. The pipeline definition is stored in the Java Experience Concourse git repo (a private repository).
The code is rooted in the Agent_OnLoad
function in lib.rs. This function is called when the JVM loads the agent.
The agent registers a resource_exhausted
function with the JVM which is called whenever the JVM encounters a resource exhausted event.
The resource_exhausted
function enters a mutex, calls the AgentController
struct which delegates to various Action
trait objects to act on the resource exhaustion, and then exits the mutex before returning. One of the actions which may be driven is to kill the JVM, in which case the JVM process is killed, including the current thread, and there will be no return to the AgentController
class.
The following sequence diagram shows some typical interactions between the JVM and the jvmkill agent:
jvmkill has unit and other tests. See the [Testing][] section of the README for how to run the tests.
Please refer to the Contributors' Guide.
Others involved in jvmkill development use the #java-buildpack
channel of the Cloud Foundry slack organisation for discussion.