Rust port of jattach
Important
This is a work in progress and is not yet ready for use.
VM | Windows | Linux | MacOS |
---|---|---|---|
Hotspot | ❌ | ✅ | ❌ |
OpenJ9 | ❌ | ❌ | ❌ |
use std::error::Error;
use jattach_rs::{posix::HotspotVirtualMachine, VirtualMachine};
fn main() -> Result<(), Box<dyn Error>> {
let pid = 244680;
let mut vm = match HotspotVirtualMachine::attach(pid) {
Ok(vm) => vm,
Err(e) => panic!("Couldn't attach to process: {}", e),
};
println!("{:#?}", vm.get_properties().unwrap());
match vm.load_agent("/absolute/path/to/javaagent.jar", "arguments_for_agent") {
Ok(_) => println!("JavaAgent loaded"),
Err(e) => println!("Couldn't load JavaAgent"),
}
}