I've been thinking through what it would take to live update a feature in my Compose Desktop app. I've been looking into OSGi Bundles. It sounds like being started, stopped, updating and swapping out at runtime is what they were designed to do. The documentation isn't super clear about this though. Has anyone ever used OSGi by chance?
01/31/2023, 5:12 AM
Maybe look into how Intellij can update its plugins without a full restart. Sometimes it does require an app restart though. I think in general it's pretty acceptable to restart the app on any update.
01/31/2023, 8:18 AM
Try telling that to a web developer 😀
01/31/2023, 10:03 AM
The main question is whether you really need live updates or whether it is also OK to just restart your application when you want to add or remove some functionality. When the later is the case, then you could make your life a lot easier by just using Javas service loaders instead. Eclipse is fully built on OSGi but even after 20 years I still have to find a plugin which can be installed without having to restart Eclipse. Also OSGi has some additional requirements which make it often difficult to use existing libraries with it. My suggestion would be to stick to a more simple concept if possible.
01/31/2023, 1:47 PM
Seems like a nested class loader is all you need. If you have a decent architecture then your dependencies won't leak outside of the class loader and regular garbage collection can be relied upon to free old versions.
01/31/2023, 3:04 PM
@jw Do you have an example? 8 months ago, that was my impression as well, and I tested it out and couldn't get it to work.
01/31/2023, 3:38 PM
Not for Compose UI desktop, specifically. I've done it in the past on some things with the same requirements but I would have to search to see if any are public.
01/31/2023, 3:42 PM
I was able to get my classes to reload, but I ran into very clear issues with the Swing classes that I couldn't resolve.