Program: 71287
Project: 71287
Buggy source:
/** 
 * Creates a new layer by defining the modules in the given   {@code Configuration} to the Java virtual machine. Each module is defined toits own  {@link ClassLoader} created by this method. The {@link ClassLoader#getParent() parent} of each class loader is the given parentclass loader. <p> The class loaders created by this method implement <em>direct delegation</em> when loading types from modules. When  {@link ClassLoader#loadClass(String,boolean) loadClass} method is invoked toload a class then it uses the package name of the class to map it to a module. The package may be in the module defined to the class loader. The package may be exported by another module in this layer to the module defined to the class loader. It may be in a package exported by a module in a parent layer. The class loader delegates to the class loader of the module, throwing  {@code ClassNotFoundException} if not found bythat class loader. When  {@code loadClass} is invoked to load classes that do not map to amodule then it delegates to the parent class loader. </p> <p> If there is a security manager then the class loaders created by this method will load classes and resources with privileges that are restricted by the calling context of this method. </p>
 * @param cf The configuration for the layer
 * @param parentLayers The list parent layers in search order
 * @param parentLoader The parent class loader for each of the class loaders created by this method; may be  {@code null} for the bootstrap class loader
 * @return A controller that controls the newly created layer
 * @throws IllegalArgumentException If the parent configurations do not match the configuration of the parent layers, including order
 * @throws LayerInstantiationException If the layer cannot be created because the configuration contains a module named " {@code java.base}" or a module with a package name starting with "  {@code java.}"
 * @throws SecurityException If  {@code RuntimePermission("createClassLoader")} or{@code RuntimePermission("getClassLoader")} is denied bythe security manager
 * @see #findLoader
 */
public static Controller defineModulesWithManyLoaders(Configuration cf,List<Layer> parentLayers,ClassLoader parentLoader){
  List<Layer> parents=new ArrayList<>(parentLayers);
  checkConfiguration(cf,parents);
  checkCreateClassLoaderPermission();
  checkGetClassLoaderPermission();
  LoaderPool pool=new LoaderPool(cf,parents,parentLoader);
  try {
    Layer layer=new Layer(cf,parents,pool::loaderFor);
    return new Controller(layer);
  }
 catch (  IllegalArgumentException e) {
    throw new LayerInstantiationException(e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Creates a new layer by defining the modules in the given   {@code Configuration} to the Java virtual machine. Each module is defined toits own  {@link ClassLoader} created by this method. The {@link ClassLoader#getParent() parent} of each class loader is the given parentclass loader. <p> The class loaders created by this method implement <em>direct delegation</em> when loading types from modules. When  {@link ClassLoader#loadClass(String,boolean) loadClass} method is invoked toload a class then it uses the package name of the class to map it to a module. The package may be in the module defined to the class loader. The package may be exported by another module in this layer to the module defined to the class loader. It may be in a package exported by a module in a parent layer. The class loader delegates to the class loader of the module, throwing  {@code ClassNotFoundException} if not found bythat class loader. When  {@code loadClass} is invoked to load classes that do not map to amodule then it delegates to the parent class loader. </p> <p> If there is a security manager then the class loaders created by this method will load classes and resources with privileges that are restricted by the calling context of this method. </p>
 * @param cf The configuration for the layer
 * @param parentLayers The list parent layers in search order
 * @param parentLoader The parent class loader for each of the class loaders created by this method; may be  {@code null} for the bootstrap class loader
 * @return A controller that controls the newly created layer
 * @throws IllegalArgumentException If the parent configurations do not match the configuration of the parent layers, including order
 * @throws LayerInstantiationException If the layer cannot be created because the configuration contains a module named " {@code java.base}" or a module with a package name starting with "  {@code java.}"
 * @throws SecurityException If  {@code RuntimePermission("createClassLoader")} or{@code RuntimePermission("getClassLoader")} is denied bythe security manager
 * @see #findLoader
 */
public static Controller defineModulesWithManyLoaders(Configuration cf,List<Layer> parentLayers,ClassLoader parentLoader){
  List<Layer> parents=new ArrayList<>(parentLayers);
  checkConfiguration(cf,parents);
  checkCreateClassLoaderPermission();
  checkGetClassLoaderPermission();
  LoaderPool pool=new LoaderPool(cf,parents,parentLoader);
  try {
    Layer layer=new Layer(cf,parents,pool::loaderFor);
    return new Controller(layer);
  }
 catch (  IllegalArgumentException|IllegalStateException e) {
    throw new LayerInstantiationException(e.getMessage());
  }
}