I am loading a plug-in dynamically. Both the plug-in and the software have been created by us.
I have an Interface lets call it Foo. There is also FooImpl that just implements that method But FooImpl is in the jar loaded dynamically
public interface Foo { void write(..someArgument..) throws Exception; }
I have also a PluginLoader class here is the method
public Object loadPlugin(final String jarPath, final Class pluginInterface) { try { final URI uri = new File(jarPath).toURI(); final URL url = uri.toURL(); final URLClassLoader ucl = new URLClassLoader(new URL[] { url }); try { final Class<?> pluginClass = Class.forName("FooImpl", true, ucl); // Verify if plugin implements plugin interface. if (pluginClass.getInterfaces()[0].getName().equals(pluginInterface.getName())) { // Instantiate plugin. return pluginClass.newInstance(); } }//[...] </code></pre>
This part is actually working well i think so because after doing some sysout on the pluginClass i notice:
the .getMethods() =
[public void FooImpl.write(..someArgumentType..) throws Exception, public abstract void some.package.Foo.write(..someArgumentType..) throws Exception]the .getGenericInterfaces() = [interface some.package.Foo]
But when i try to call the method write here is what i get
java.lang.AbstractMethodError: FooImpl.write(..SomeArgumentType..;)V
I dont know why there is a ";" and a "V"So basically i think that it try to call the interface method instead of the implemented one. So i'm wondering What is going on!
As usual, Thank you for your time and help