mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
fix classloading, if the class was not found at the first plugin
This commit is contained in:
@@ -73,43 +73,39 @@ public final class UberClassLoader extends ClassLoader
|
|||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*
|
|
||||||
* @throws ClassNotFoundException
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException
|
protected Class<?> findClass(String name) throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
Class<?> clazz = getFromCache(name);
|
Class<?> clazz = getFromCache(name);
|
||||||
|
|
||||||
if (clazz == null)
|
if (clazz == null) {
|
||||||
{
|
clazz = findClassInPlugins(name);
|
||||||
for (PluginWrapper plugin : plugins)
|
cache.put(name, new WeakReference<>(clazz));
|
||||||
{
|
|
||||||
ClassLoader cl = plugin.getClassLoader();
|
|
||||||
|
|
||||||
// load class could be slow, perhaps we should call
|
|
||||||
// find class via reflection ???
|
|
||||||
clazz = cl.loadClass(name);
|
|
||||||
|
|
||||||
if (clazz != null)
|
|
||||||
{
|
|
||||||
cache.put(name, new WeakReference<Class<?>>(clazz));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return clazz;
|
return clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Class<?> findClassInPlugins(String name) throws ClassNotFoundException {
|
||||||
|
for (PluginWrapper plugin : plugins) {
|
||||||
|
Class<?> clazz = findClass(plugin.getClassLoader(), name);
|
||||||
|
if (clazz != null) {
|
||||||
|
return clazz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ClassNotFoundException("could not find class " + name + " in any of the installed plugins");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Class<?> findClass(ClassLoader classLoader, String name) {
|
||||||
|
try {
|
||||||
|
// load class could be slow, perhaps we should call
|
||||||
|
// find class via reflection ???
|
||||||
|
return classLoader.loadClass(name);
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user