public Map<PluginClassLoaderDef, ClassLoader> create(Map<PluginClassLoaderDef, ClassLoader> previouslyCreatedClassloaders,
    Collection<PluginClassLoaderDef> newDefs) {
    ClassLoader baseClassLoader = baseClassLoader();

    Collection<PluginClassLoaderDef> allDefs = new HashSet<>();
    allDefs.addAll(newDefs);
    allDefs.addAll(previouslyCreatedClassloaders.keySet());

    ClassloaderBuilder builder = new ClassloaderBuilder(previouslyCreatedClassloaders.values());
    builder.newClassloader(API_CLASSLOADER_KEY, baseClassLoader);
    builder.setMask(API_CLASSLOADER_KEY, apiMask());

    for (PluginClassLoaderDef def : newDefs) {
      builder.newClassloader(def.getBasePluginKey());
      builder.setParent(def.getBasePluginKey(), API_CLASSLOADER_KEY, Mask.ALL);
      builder.setLoadingOrder(def.getBasePluginKey(), def.isSelfFirstStrategy() ? SELF_FIRST : PARENT_FIRST);
      for (File jar : def.getFiles()) {
        builder.addURL(def.getBasePluginKey(), fileToUrl(jar));
      }
      exportResources(def, builder, allDefs);
    }

    return build(newDefs, builder);
  }
@Test
  public void classloader_exposes_license_api_from_main_classloader() {
    PluginClassLoaderDef def = basePluginDef();
    Map<PluginClassLoaderDef, ClassLoader> map = factory.create(emptyMap(), asList(def));

    assertThat(map).containsOnlyKeys(def);
    ClassLoader classLoader = map.get(def);

    assertThat(canLoadClass(classLoader, FooBar.class.getCanonicalName())).isTrue();
  }