throw new IllegalStateException("Item not resolved: " + item);
// Dynamic requirement, create it lazily
if (requirement.isDynamic())
{
DelegateLoader delegate = createLazyDelegateLoader(checkDomain(), item);
dynamic.add(delegate);
continue;
}
String name = (String) item.getIDependOn();
if (name == null)
{
// Optional requirement, just ignore
if (requirement.isOptional())
continue;
// Something has gone wrong
throw new IllegalStateException("No iDependOn for item: " + item);
}
Module iDependOnModule = checkDomain().getModule(name);
if (iDependOnModule == null)
throw new IllegalStateException("Module not found with name: " + name);
// Determine the delegate loader for the module
DelegateLoader delegate = iDependOnModule.getDelegateLoader(module, requirement);
if (delegate == null)
throw new IllegalStateException("Cannot obtain delegate for: " + requirement);
// Check for re-export by the module
if (requirement.wantReExports())
addDelegates(iDependOnModule, delegates, dynamic, visited, true);
// Only add a the delegate if this is not a self-dependency
if (iDependOnModule != module)
{
// If we are connecting to another module we collect the imported package names per delegate
if (requirement instanceof PackageRequirement)
{
ClassLoaderPolicy policy = delegate.getPolicy();
List<String> packageNames = delegateToRequiredPackages.get(policy);
if (packageNames == null)
{
packageNames = new ArrayList<String>();
delegateToRequiredPackages.put(policy, packageNames);