We have a command-line tool that uses pf4j to load plugins. We have a script that automatically downloads plugins into plugins directory, then launches our Java JAR, which loads the plugins with pf4j.
The script by default launches the latest version of the tool, but users can specify a specific version of the JAR if they want.
Our issue is that if a new version of the JAR introduces a new interface that a plugin implements, then a user goes back to an older version, we then we get a ClassNotFoundException.
v1 of JAR has interface Foo, and plugin Bar that implements Foo
v2 of JAR has interface Foo2, and plugin Bar2 that implements Foo2
When we run v1, plugin Bar gets copied to plugins directory
We run v2, plugin Bar2 gets copied to plugins directory
When user then goes back to v1, it tries to load all plugins in the plugins directory, and fails with a ClassNotFoundException, because Bar2 implements the Foo2 interface, but v1 does not have that class.
One solution I've thought is to have v2 plugins installed into a separate directory, and then v1 doesn't try to load them. But that's a bit of work to implement, so I was hoping for an easier solution. Is there any way
to have pf4j just ignore ClassNotFoundException? It didn't look like it in the code.