I already posted about this in the platform dev Slack group and had a quick chat with one person there who has solved this for Clojure, and I've also already implemented a fully-working solution by dynamically adding jar URLs to the existing UrlClassLoader. However, I'm still not satisfied and hope there's a better, more encapsulated solution available.
Basically I've integrated a third-party Java-based tool into my custom plugin, but for a number of reasons I don't actually bundle that tool's jars. I do include them in the local plugin development environment as a "provided" library so that I get static, compile-time validation against the classes from those jars, but the code that works against those classes only comes into play if the end user has configured my plugin against a local distribution of the third-party tool from which I add the appropriate subset of jars to the runtime class path. As I said, right now I'm doing that to the existing IDE class loader via UrlClassLoader#addFiles, and if I see that the configured third-party tool has changed to another distribution, I tell the user that they'll need to restart the IDE to use the new distribution. Again, it works, and to be fair, it works really well...but it feels wrong.
I've tried to get this working with a completely distinct class loader so that it's fully-isolated from the IDE's own class loader, but so far I haven't figured out the right magic incantation to make it work. I've tried using a URLClassLoader with the IDE's class loader as its parent, overriding loadClass to apply a load-local-first strategy, but then I end up with conflicting versions of the same classes. And of course I've tried using ClassLoaderUtil#computeWithClassLoader so that the context class loader is set to my custom class loader during execution, but again, no go.
Obviously at some point I may have to decide that what I have works and I need to stop spinning my wheels on this, but before I do so, I wanted to check with one more resource--this community--first. Any insights you can share are greatly appreciated!