Hacker News new | ask | show | jobs
by mike_hearn 549 days ago
1. There's no way to react to hot reload in the normal Java API, so you can't easily clear state.

2. The JDWP protocol lets debuggers redefine nearly anything, but HotSpot doesn't implement the full protocol. In practice many kinds of reload don't work.

3. To fix those issues app frameworks went with classloaders for partial app reloads instead, or reimplemented hotswap logic themselves (see JRebel).

There's no fundamental reason these can't be fixed, and in fact the Espresso JVM fixes both 1 and 2:

https://www.graalvm.org/latest/reference-manual/espresso/hot...

You can write JVM plugins that are invoked after redefinition occurs, allowing you (really your app framework) to do something sensible like partially reload state. And it implements the full protocol, so many more kinds of redefinition work.

Using it is easy. Just install Espresso as your JDK, point your build system at it, then debug your app. Recompiling what attached will cause hot reload.

1 comments

Interesting, I've never heard of Espresso, I've always just used Jetbrains Runtime[1] instead which is the successor of DCEVM[2] in a way. As for plugins I used HotswapAgent[3] at times however I found it to be rather clunky, does Espresso improve on this aspect?

1: https://github.com/JetBrains/JetBrainsRuntime

2: https://dcevm.github.io/

3: https://hotswapagent.org/