So I eventually took the JMX option and later ran into this issue:
https://blakboard.wordpress.com/2011/02/22/effects-of-java-rmi-on-jvm-shutdown
I'm starting a JMX server + exporting a remote object from the premain of my java agent.
I can communicate with it which is great, however when the application should normally end, it hangs. This is because there is a non-daemon thread called "RMI Reaper" that is still running.
"RMI Reaper" dies when all remote objects are unexported. So I should unexport the remote object I exported. The problem is that I don't know when to do it because my java agent is attached to applications I don't know anything about: I don't know when they end.
I know it's not related to Byte Buddy but I just wanted to know if you ever ran into this issue?
If I can't find a solution, I'll have to stop using JMX and instead use a TCP server like Netty.
Thanks,
Yoann