Update Java code during runtime

后端 未结 3 442
死守一世寂寞
死守一世寂寞 2021-01-04 23:08

about a year ago I stumbled across a nice feature in Java that I cannot for the life of me find again.

Through some magic interface it was apparently possible to dec

3条回答
  •  自闭症患者
    2021-01-05 00:04

    Various app containers can do this.

    Basically you'd need to reload the class in a new ClassLoader (unless you're talking about doing this under the debugger, in which case there are completely different APIs available).

    In my opinion, this kind of thing is rarely worth the hassle: designing everything so that it can be reloaded is considerably harder than designing it so it can be completely restarted in a new process. It's also easier to be sure exactly what code is running if there's only ever one version loaded in the process.

    It's a neat thing to be able to demo, but for most applications it's not worth it. All in my opinion, of course :)

    Note that one notable exception is the ability to reload web UI layers without restarting the container: that can make life much easier.

提交回复
热议问题