Generally such a thing. I need to connect to a completely left JVM process and replace at least the bodies of the f-th one of its classes. The wonderful f-Ia of many IDE "Hot Swap" immediately comes to mind. I tried to search Google for documentation about this, but it’s not strange how the tops were occupied with articles about using Hot Swap, and not about its implementation. Poke, please, nose where you want to look.
PS I was able to connect JDI, but I didn’t find something necessary there.