Hopefully properly load class depenending on classes from other plugins.

This commit is contained in:
md_5 2013-02-01 21:40:32 +11:00
parent 00e0e3c1a3
commit be4a764932

View File

@ -17,17 +17,31 @@ public class PluginClassloader extends URLClassLoader
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
{
for (PluginClassloader loader : allLoaders)
return loadClass0(name, resolve, true);
}
private Class<?> loadClass0(String name, boolean resolve, boolean checkOther) throws ClassNotFoundException
{
try
{
if (loader != this)
return super.loadClass(name, resolve);
} catch (ClassNotFoundException ex)
{
}
if (checkOther)
{
for (PluginClassloader loader : allLoaders)
{
try
{
return loader.loadClass(name);
} catch (ClassNotFoundException ex)
if (loader != this)
{
try
{
return loader.loadClass0(name, resolve, false);
} catch (ClassNotFoundException ex)
{
}
}
}
}