Program: 78528
Project: 78528
Buggy source:
private void completeModule(ModuleSymbol msym){
  if (inInitModules) {
    msym.completer=sym -> completeModule(msym);
    return;
  }
  if ((msym.flags_field & Flags.AUTOMATIC_MODULE) != 0) {
    completeAutomaticModule(msym);
  }
  Assert.checkNonNull(msym.requires);
  initAddReads();
  msym.requires=msym.requires.appendList(List.from(addReads.getOrDefault(msym,Collections.emptySet())));
  List<RequiresDirective> requires=msym.requires;
  List<RequiresDirective> previous=null;
  while (requires.nonEmpty()) {
    if (!allModules().contains(requires.head.module)) {
      Env<AttrContext> env=typeEnvs.get(msym);
      if (env != null) {
        JavaFileObject origSource=log.useSource(env.toplevel.sourcefile);
        try {
          log.error(env.tree,Errors.ModuleNotFound(requires.head.module));
        }
  finally {
          log.useSource(origSource);
        }
      }
 else {
        Assert.check((msym.flags() & Flags.AUTOMATIC_MODULE) == 0);
      }
      if (previous != null) {
        previous.tail=requires.tail;
      }
 else {
        msym.requires.tail=requires.tail;
      }
    }
 else {
      previous=requires;
    }
    requires=requires.tail;
  }
  Set<ModuleSymbol> readable=new LinkedHashSet<>();
  Set<ModuleSymbol> requiresTransitive=new HashSet<>();
  for (  RequiresDirective d : msym.requires) {
    d.module.complete();
    readable.add(d.module);
    Set<ModuleSymbol> s=retrieveRequiresTransitive(d.module);
    Assert.checkNonNull(s,() -> "String_Node_Str" + d.module);
    readable.addAll(s);
    if (d.flags.contains(RequiresFlag.TRANSITIVE)) {
      requiresTransitive.add(d.module);
      requiresTransitive.addAll(s);
    }
  }
  requiresTransitiveCache.put(msym,requiresTransitive);
  initVisiblePackages(msym,readable);
  for (  ExportsDirective d : msym.exports) {
    if (d.packge != null) {
      d.packge.modle=msym;
    }
  }
}

Fixed version (ground truth):
private void completeModule(ModuleSymbol msym){
  if (inInitModules) {
    msym.completer=sym -> completeModule(msym);
    return;
  }
  if ((msym.flags_field & Flags.AUTOMATIC_MODULE) != 0) {
    completeAutomaticModule(msym);
  }
  Assert.checkNonNull(msym.requires);
  initAddReads();
  msym.requires=msym.requires.appendList(List.from(addReads.getOrDefault(msym,Collections.emptySet())));
  List<RequiresDirective> requires=msym.requires;
  while (requires.nonEmpty()) {
    if (!allModules().contains(requires.head.module)) {
      Env<AttrContext> env=typeEnvs.get(msym);
      if (env != null) {
        JavaFileObject origSource=log.useSource(env.toplevel.sourcefile);
        try {
          log.error(env.tree,Errors.ModuleNotFound(requires.head.module));
        }
  finally {
          log.useSource(origSource);
        }
      }
 else {
        Assert.check((msym.flags() & Flags.AUTOMATIC_MODULE) == 0);
      }
      msym.requires=List.filter(msym.requires,requires.head);
    }
    requires=requires.tail;
  }
  Set<ModuleSymbol> readable=new LinkedHashSet<>();
  Set<ModuleSymbol> requiresTransitive=new HashSet<>();
  for (  RequiresDirective d : msym.requires) {
    d.module.complete();
    readable.add(d.module);
    Set<ModuleSymbol> s=retrieveRequiresTransitive(d.module);
    Assert.checkNonNull(s,() -> "String_Node_Str" + d.module);
    readable.addAll(s);
    if (d.flags.contains(RequiresFlag.TRANSITIVE)) {
      requiresTransitive.add(d.module);
      requiresTransitive.addAll(s);
    }
  }
  requiresTransitiveCache.put(msym,requiresTransitive);
  initVisiblePackages(msym,readable);
  for (  ExportsDirective d : msym.exports) {
    if (d.packge != null) {
      d.packge.modle=msym;
    }
  }
}