public static Map<ModuleAdapter<?>, Object> loadModules(Loader loader,
      Object[] seedModulesOrClasses) {
    Map<ModuleAdapter<?>, Object> seedAdapters =
        new LinkedHashMap<ModuleAdapter<?>, Object>(seedModulesOrClasses.length);
    for (int i = 0; i < seedModulesOrClasses.length; i++) {
      if (seedModulesOrClasses[i] instanceof Class<?>) {
        ModuleAdapter<?> adapter = loader.getModuleAdapter((Class<?>) seedModulesOrClasses[i]);
        seedAdapters.put(adapter, adapter.newModule());
      } else {
        ModuleAdapter<?> adapter = loader.getModuleAdapter(seedModulesOrClasses[i].getClass());
        seedAdapters.put(adapter, seedModulesOrClasses[i]);
      }
    }

    // Add the adapters that we have module instances for. This way we won't
    // construct module objects when we have a user-supplied instance.
    Map<ModuleAdapter<?>, Object> result =
        new LinkedHashMap<ModuleAdapter<?>, Object>(seedAdapters);

    // Next collect included modules
    Map<Class<?>, ModuleAdapter<?>> transitiveInclusions =
        new LinkedHashMap<Class<?>, ModuleAdapter<?>>();
    for (ModuleAdapter<?> adapter : seedAdapters.keySet()) {
      collectIncludedModulesRecursively(loader, adapter, transitiveInclusions);
    }
    // and create them if necessary
    for (ModuleAdapter<?> dependency : transitiveInclusions.values()) {
      if (!result.containsKey(dependency)) {
        result.put(dependency, dependency.newModule());
      }
    }
    return result;
  }
public static Map < ModuleAdapter < ? > , Object > loadModules ( Loader loader , Object [ ] seedModulesOrClasses ) { Map < ModuleAdapter < ? > , Object > seedAdapters = new LinkedHashMap < ModuleAdapter < ? > , Object > ( seedModulesOrClasses . length ) ; for ( int i = 0 ; i < seedModulesOrClasses . length ; i ++ ) { if ( seedModulesOrClasses [ i ] instanceof Class < ? > ) { ModuleAdapter < ? > adapter = loader . getModuleAdapter ( ( Class < ? > ) seedModulesOrClasses [ i ] ) ; seedAdapters . put ( adapter , adapter . newModule ( ) ) ; } else { ModuleAdapter < ? > adapter = loader . getModuleAdapter ( seedModulesOrClasses [ i ] . getClass ( ) ) ; seedAdapters . put ( adapter , seedModulesOrClasses [ i ] ) ; } } Map < ModuleAdapter < ? > , Object > result = new LinkedHashMap < ModuleAdapter < ? > , Object > ( seedAdapters ) ; Map < Class < ? > , ModuleAdapter < ? > > transitiveInclusions = new LinkedHashMap < Class < ? > , ModuleAdapter < ? > > ( ) ; for ( ModuleAdapter < ? > adapter : seedAdapters . keySet ( ) ) { collectIncludedModulesRecursively ( loader , adapter , transitiveInclusions ) ; } for ( ModuleAdapter < ? > dependency : transitiveInclusions . values ( ) ) { if ( ! result . containsKey ( dependency ) ) { result . put ( dependency , dependency . newModule ( ) ) ; } } return result ; }
Returns a full set of module adapters, including module adapters for included
modules.