in atomos/src/main/java/org/apache/felix/atomos/impl/modules/ModuleConnectLoader.java [274:314]
protected Class<?> loadClass(String className, boolean resolve)
throws ClassNotFoundException
{
Class<?> cls = null;
// synchronize on getClassLoadingLock(className)
synchronized (getClassLoadingLock(className))
{
// find if the class is already loaded and return it if so.
cls = findLoadedClass(className);
if (cls == null)
{
// otherwise; check ModuleDescriptor.pacakges to see if it contains the package for the requested class
// if so do the same thing as findClass(String, String)
String pkg = className.substring(0, className.lastIndexOf('.'));
if (module.get().getDescriptor().packages().contains(pkg))
{
cls = findClass(module.get().getName(), className);
}
else
{
// otherwise; check for packages this module can read from and if you have another loader for the package
// Then call the other loader.loadClass(className)
ClassLoader l = edges.get(pkg);
if (l != null)
{
cls = l.loadClass(className);
}
}
}
if (cls == null)
{
throw new ClassNotFoundException("Could not find class: " + className);
}
// if any class is found then call resolveClass on it if the resolve param is true
else if (resolve)
{
resolveClass(cls);
}
}
return cls;
}