nus-yam/ex-repair huggingface dataset:
Program: 110744
Project: 110744
Buggy source:
/** 
 * Uses a rule name to fetch the corresponding Rule from the external package. 
 */
@Nullable public static Rule getRuleByName(final String ruleName,Environment env) throws ExternalPackageException, InterruptedException {
  Set<Rule> rules=getRules(env,true,new Function<Package,Iterable<Rule>>(){
    @Nullable @Override public Iterable<Rule> apply(    Package externalPackage){
      Rule rule=externalPackage.getRule(ruleName);
      if (rule == null) {
        return null;
      }
      return ImmutableList.of(rule);
    }
  }
);
  if (env.valuesMissing()) {
    return null;
  }
  if (rules == null || rules.isEmpty()) {
    throw new ExternalRuleNotFoundException(ruleName);
  }
  return Iterables.getFirst(rules,null);
}

Fixed version (ground truth):
/** 
 * Uses a rule name to fetch the corresponding Rule from the external package. 
 */
@Nullable public static Rule getRuleByName(final String ruleName,Environment env) throws ExternalPackageException, InterruptedException {
  List<Rule> rules=getRules(env,true,new Function<Package,Iterable<Rule>>(){
    @Nullable @Override public Iterable<Rule> apply(    Package externalPackage){
      Rule rule=externalPackage.getRule(ruleName);
      if (rule == null) {
        return null;
      }
      return ImmutableList.of(rule);
    }
  }
);
  if (env.valuesMissing()) {
    return null;
  }
  if (rules == null || rules.isEmpty()) {
    throw new ExternalRuleNotFoundException(ruleName);
  }
  return Iterables.getFirst(rules,null);
}
Program: 110746
Project: 110746
Buggy source:
/** 
 * Returns a copy of this container with filtered resources, or the original if no resources should be filtered. The original container is unchanged.
 */
public ResourceContainer filter(RuleContext ruleContext,ResourceFilter filter){
  ImmutableList<Artifact> filteredResources=filter.filter(ruleContext,getResources());
  if (filteredResources.size() == getResources().size()) {
    return this;
  }
  ImmutableList.Builder<PathFragment> filteredResourcesRootsBuilder=ImmutableList.builder();
  for (  PathFragment resourceRoot : getResourcesRoots()) {
    for (    Artifact resource : filteredResources) {
      if (resource.getRootRelativePath().startsWith(resourceRoot)) {
        filteredResourcesRootsBuilder.add(resourceRoot);
        break;
      }
    }
  }
  return toBuilder().setResources(filteredResources).setResourcesRoots(filteredResourcesRootsBuilder.build()).build();
}

Fixed version (ground truth):
/** 
 * Returns a copy of this container with filtered resources, or the original if no resources should be filtered. The original container is unchanged.
 */
public ResourceContainer filter(RuleErrorConsumer ruleErrorConsumer,ResourceFilter filter){
  ImmutableList<Artifact> filteredResources=filter.filter(ruleErrorConsumer,getResources());
  if (filteredResources.size() == getResources().size()) {
    return this;
  }
  ImmutableList.Builder<PathFragment> filteredResourcesRootsBuilder=ImmutableList.builder();
  for (  PathFragment resourceRoot : getResourcesRoots()) {
    for (    Artifact resource : filteredResources) {
      if (resource.getRootRelativePath().startsWith(resourceRoot)) {
        filteredResourcesRootsBuilder.add(resourceRoot);
        break;
      }
    }
  }
  return toBuilder().setResources(filteredResources).setResourcesRoots(filteredResourcesRootsBuilder.build()).build();
}
Program: 110747
Project: 110747
Buggy source:
/** 
 * Constructor.
 * @param configFilters the resource configuration filters, as a list of strings.
 * @param densities the density filters, as a list of strings.
 * @param filterBehavior the behavior of this filter.
 */
private ResourceFilter(ImmutableList<String> configFilters,ImmutableList<String> densities,FilterBehavior filterBehavior){
  this.configFilters=configFilters;
  this.densities=densities;
  this.filterBehavior=filterBehavior;
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param configFilters the resource configuration filters, as a list of strings.
 * @param densities the density filters, as a list of strings.
 * @param filterBehavior the behavior of this filter.
 */
@VisibleForTesting ResourceFilter(ImmutableList<String> configFilters,ImmutableList<String> densities,FilterBehavior filterBehavior){
  this.configFilters=configFilters;
  this.densities=densities;
  this.filterBehavior=filterBehavior;
}
Program: 110748
Project: 110748
Buggy source:
/** 
 * Reports an attribute error if the given item is null, and otherwise adds it to the builder. 
 */
private static <T>void addIfNotNull(T item,String itemString,ImmutableList.Builder<T> builder,RuleContext ruleContext,String attrName){
  if (item == null) {
    ruleContext.attributeError(attrName,"String_Node_Str" + itemString + "String_Node_Str"+ attrName);
  }
 else {
    builder.add(item);
  }
}

Fixed version (ground truth):
/** 
 * Reports an attribute error if the given item is null, and otherwise adds it to the builder. 
 */
private static <T>void addIfNotNull(T item,String itemString,ImmutableList.Builder<T> builder,RuleErrorConsumer ruleErrorConsumer,String attrName){
  if (item == null) {
    ruleErrorConsumer.attributeError(attrName,"String_Node_Str" + itemString + "String_Node_Str"+ attrName);
  }
 else {
    builder.add(item);
  }
}
Program: 110749
Project: 110749
Buggy source:
private static FolderConfiguration getConfigForArtifact(RuleContext ruleContext,Artifact artifact){
  String containingFolder=getContainingFolder(artifact);
  FolderConfiguration config=FolderConfiguration.getConfigForFolder(containingFolder);
  if (config == null) {
    ruleContext.ruleError("String_Node_Str" + containingFolder + "String_Node_Str");
    return FolderConfiguration.getConfigForQualifierString("String_Node_Str");
  }
  config.setVersionQualifier(VersionQualifier.getQualifier("String_Node_Str"));
  return config;
}

Fixed version (ground truth):
private static FolderConfiguration getConfigForArtifact(RuleErrorConsumer ruleErrorConsumer,Artifact artifact){
  String containingFolder=getContainingFolder(artifact);
  FolderConfiguration config=FolderConfiguration.getConfigForFolder(containingFolder);
  if (config == null) {
    ruleErrorConsumer.ruleError("String_Node_Str" + containingFolder + "String_Node_Str");
    return FolderConfiguration.getConfigForQualifierString("String_Node_Str");
  }
  return config;
}
Program: 110750
Project: 110750
Buggy source:
/** 
 * @param artifact if this artifact is a better match for this object's desired density than anyother artifacts with the same name and non-density configuration, adds it to this object.
 */
public void maybeAddArtifact(Artifact artifact){
  FolderConfiguration config=getConfigForArtifact(ruleContext,artifact);
  config.setDensityQualifier(null);
  String nameAndConfiguration=config.getUniqueKey() + "String_Node_Str" + artifact.getFilename();
  Artifact currentBest=nameAndConfigurationToBestArtifact.get(nameAndConfiguration);
  if (currentBest == null || computeAffinity(artifact) < computeAffinity(currentBest)) {
    nameAndConfigurationToBestArtifact.put(nameAndConfiguration,artifact);
  }
}

Fixed version (ground truth):
/** 
 * @param artifact if this artifact is a better match for this object's desired density than anyother artifacts with the same name and non-density configuration, adds it to this object.
 */
public void maybeAddArtifact(Artifact artifact){
  FolderConfiguration config=getConfigForArtifact(ruleErrorConsumer,artifact);
  config.setDensityQualifier(null);
  String nameAndConfiguration=config.getUniqueKey() + "String_Node_Str" + artifact.getFilename();
  Artifact currentBest=nameAndConfigurationToBestArtifact.get(nameAndConfiguration);
  if (currentBest == null || computeAffinity(artifact) < computeAffinity(currentBest)) {
    nameAndConfigurationToBestArtifact.put(nameAndConfiguration,artifact);
  }
}
Program: 110751
Project: 110751
Buggy source:
private ImmutableList<FolderConfiguration> getConfigurationFilters(RuleContext ruleContext){
  ImmutableList.Builder<FolderConfiguration> filterBuilder=ImmutableList.builder();
  for (  String filter : configFilters) {
    addIfNotNull(getFolderConfiguration(filter),filter,filterBuilder,ruleContext,RESOURCE_CONFIGURATION_FILTERS_NAME);
  }
  return filterBuilder.build();
}

Fixed version (ground truth):
private ImmutableList<FolderConfiguration> getConfigurationFilters(RuleErrorConsumer ruleErrorConsumer){
  ImmutableList.Builder<FolderConfiguration> filterBuilder=ImmutableList.builder();
  for (  String filter : configFilters) {
    addIfNotNull(getFolderConfiguration(filter),filter,filterBuilder,ruleErrorConsumer,RESOURCE_CONFIGURATION_FILTERS_NAME);
  }
  return filterBuilder.build();
}
Program: 110752
Project: 110752
Buggy source:
/** 
 * Extracts filters from the current RuleContext, as a list of strings. <p>In BUILD files, string lists can be represented as a list of strings, a single comma-separated string, or a combination of both. This method outputs a single list of individual string values, which can then be passed directly to resource processing actions.
 * @return the values of this attribute contained in the {@link RuleContext}, as a list.
 */
private static ImmutableList<String> extractFilters(AttributeMap attrs,String attrName){
  if (!hasAttr(attrs,attrName)) {
    return ImmutableList.<String>of();
  }
  List<String> rawValues=attrs.get(attrName,Type.STRING_LIST);
  ImmutableList.Builder<String> builder=ImmutableList.builder();
  for (  String rawValue : rawValues) {
    if (rawValue.contains("String_Node_Str")) {
      for (      String token : rawValue.split("String_Node_Str")) {
        if (!token.trim().isEmpty()) {
          builder.add(token.trim());
        }
      }
    }
 else     if (!rawValue.isEmpty()) {
      builder.add(rawValue);
    }
  }
  return builder.build();
}

Fixed version (ground truth):
/** 
 * Extracts filters from an AttributeMap, as a list of strings. <p>In BUILD files, string lists can be represented as a list of strings, a single comma-separated string, or a combination of both. This method outputs a single list of individual string values, which can then be passed directly to resource processing actions.
 * @return the values of this attribute contained in the {@link AttributeMap}, as a list.
 */
private static ImmutableList<String> extractFilters(AttributeMap attrs,String attrName){
  if (!hasAttr(attrs,attrName)) {
    return ImmutableList.<String>of();
  }
  List<String> rawValues=attrs.get(attrName,Type.STRING_LIST);
  ImmutableList.Builder<String> builder=ImmutableList.builder();
  for (  String rawValue : rawValues) {
    if (rawValue.contains("String_Node_Str")) {
      for (      String token : rawValue.split("String_Node_Str")) {
        if (!token.trim().isEmpty()) {
          builder.add(token.trim());
        }
      }
    }
 else     if (!rawValue.isEmpty()) {
      builder.add(rawValue);
    }
  }
  return builder.build();
}
Program: 110753
Project: 110753
Buggy source:
/** 
 * Filters a NestedSet of resource containers that contain dependencies of the current rule. This may be a no-op if this filter is empty or if resource prefiltering is disabled.
 */
NestedSet<ResourceContainer> filterDependencies(RuleContext ruleContext,NestedSet<ResourceContainer> resources){
  if (!isPrefiltering()) {
    return resources;
  }
  NestedSetBuilder<ResourceContainer> builder=new NestedSetBuilder<>(resources.getOrder());
  for (  ResourceContainer resource : resources) {
    builder.add(resource.filter(ruleContext,this));
  }
  return builder.build();
}

Fixed version (ground truth):
/** 
 * Filters a NestedSet of resource containers that contain dependencies of the current rule. This may be a no-op if this filter is empty or if resource prefiltering is disabled.
 */
NestedSet<ResourceContainer> filterDependencies(RuleErrorConsumer ruleErrorConsumer,NestedSet<ResourceContainer> resources){
  if (!isPrefiltering()) {
    return resources;
  }
  NestedSetBuilder<ResourceContainer> builder=new NestedSetBuilder<>(resources.getOrder());
  for (  ResourceContainer resource : resources) {
    builder.add(resource.filter(ruleErrorConsumer,this));
  }
  return builder.build();
}
Program: 110754
Project: 110754
Buggy source:
ImmutableList<Artifact> filter(RuleContext ruleContext,ImmutableList<Artifact> artifacts){
  if (!isPrefiltering()) {
    return artifacts;
  }
  ImmutableSet.Builder<Artifact> builder=ImmutableSet.builder();
  List<BestArtifactsForDensity> bestArtifactsForAllDensities=new ArrayList<>();
  for (  Density density : getDensities(ruleContext)) {
    bestArtifactsForAllDensities.add(new BestArtifactsForDensity(ruleContext,density));
  }
  ImmutableList<FolderConfiguration> folderConfigs=getConfigurationFilters(ruleContext);
  for (  Artifact artifact : artifacts) {
    if (!matchesConfigurationFilters(folderConfigs,getConfigForArtifact(ruleContext,artifact))) {
      continue;
    }
    if (!shouldFilterByDensity(artifact)) {
      builder.add(artifact);
      continue;
    }
    for (    BestArtifactsForDensity bestArtifactsForDensity : bestArtifactsForAllDensities) {
      bestArtifactsForDensity.maybeAddArtifact(artifact);
    }
  }
  for (  BestArtifactsForDensity bestArtifactsForDensity : bestArtifactsForAllDensities) {
    builder.addAll(bestArtifactsForDensity.get());
  }
  ImmutableSet<Artifact> keptArtifacts=builder.build();
  for (  Artifact artifact : artifacts) {
    if (keptArtifacts.contains(artifact)) {
      continue;
    }
    String parentDir=artifact.getPath().getParentDirectory().getBaseName();
    filteredResources.add(parentDir + "String_Node_Str" + artifact.getFilename());
  }
  return keptArtifacts.asList();
}

Fixed version (ground truth):
ImmutableList<Artifact> filter(RuleErrorConsumer ruleErrorConsumer,ImmutableList<Artifact> artifacts){
  if (!isPrefiltering()) {
    return artifacts;
  }
  ImmutableSet.Builder<Artifact> builder=ImmutableSet.builder();
  List<BestArtifactsForDensity> bestArtifactsForAllDensities=new ArrayList<>();
  for (  Density density : getDensities(ruleErrorConsumer)) {
    bestArtifactsForAllDensities.add(new BestArtifactsForDensity(ruleErrorConsumer,density));
  }
  ImmutableList<FolderConfiguration> folderConfigs=getConfigurationFilters(ruleErrorConsumer);
  for (  Artifact artifact : artifacts) {
    FolderConfiguration config=getConfigForArtifact(ruleErrorConsumer,artifact);
    config.setVersionQualifier(VersionQualifier.getQualifier("String_Node_Str"));
    if (!matchesConfigurationFilters(folderConfigs,config)) {
      continue;
    }
    if (!shouldFilterByDensity(artifact)) {
      builder.add(artifact);
      continue;
    }
    for (    BestArtifactsForDensity bestArtifactsForDensity : bestArtifactsForAllDensities) {
      bestArtifactsForDensity.maybeAddArtifact(artifact);
    }
  }
  for (  BestArtifactsForDensity bestArtifactsForDensity : bestArtifactsForAllDensities) {
    builder.addAll(bestArtifactsForDensity.get());
  }
  ImmutableSet<Artifact> keptArtifacts=builder.build();
  for (  Artifact artifact : artifacts) {
    if (keptArtifacts.contains(artifact)) {
      continue;
    }
    String parentDir=artifact.getPath().getParentDirectory().getBaseName();
    filteredResources.add(parentDir + "String_Node_Str" + artifact.getFilename());
  }
  return keptArtifacts.asList();
}
Program: 110755
Project: 110755
Buggy source:
public BestArtifactsForDensity(RuleContext ruleContext,Density density){
  this.ruleContext=ruleContext;
  desiredDensity=density;
}

Fixed version (ground truth):
public BestArtifactsForDensity(RuleErrorConsumer ruleErrorConsumer,Density density){
  this.ruleErrorConsumer=ruleErrorConsumer;
  desiredDensity=density;
}
Program: 110757
Project: 110757
Buggy source:
@Override public void handle(Event e){
  hasErrors|=e.getKind() == EventKind.ERROR;
  super.handle(e);
}

Fixed version (ground truth):
@Override public void handle(Event e){
  if (e.getKind() == EventKind.ERROR) {
    hasErrors=true;
  }
  super.handle(e);
}
Program: 110758
Project: 110758
Buggy source:
@Override public void handleOptions(OptionsProvider optionsProvider){
  this.options=optionsProvider.getOptions(RemoteOptions.class);
}

Fixed version (ground truth):
@Override public void handleOptions(OptionsProvider optionsProvider){
  converter.options=optionsProvider.getOptions(RemoteOptions.class);
}
Program: 110759
Project: 110759
Buggy source:
@Override public void serverInit(OptionsProvider startupOptions,ServerBuilder builder) throws AbruptExitException {
  builder.addPathToUriConverter(new CasPathConverter());
}

Fixed version (ground truth):
@Override public void serverInit(OptionsProvider startupOptions,ServerBuilder builder) throws AbruptExitException {
  builder.addPathToUriConverter(converter);
}
Program: 110760
Project: 110760
Buggy source:
@Override public void flush() throws IOException {
  String line=buffer.toString(StandardCharsets.UTF_8.name());
  if (!line.startsWith(SHOW_INCLUDES_PREFIX) && !line.startsWith(sourceFileName)) {
    buffer.writeTo(out);
  }
  out.flush();
}

Fixed version (ground truth):
@Override public void flush() throws IOException {
  String line=buffer.toString(StandardCharsets.UTF_8.name());
  if (!line.startsWith(SHOW_INCLUDES_PREFIX) && !line.startsWith(sourceFileName) && !SHOW_INCLUDES_PREFIX.startsWith(line)&& !sourceFileName.startsWith(line)) {
    buffer.writeTo(out);
    buffer.reset();
  }
  out.flush();
}
Program: 110761
Project: 110761
Buggy source:
public Collection<Path> getDependencies(Path root){
  Collection<Path> dependenciesInPath=new ArrayList<>();
  if (filterShowIncludesOutputStream != null) {
    for (    String dep : filterShowIncludesOutputStream.getDependencies()) {
      dependenciesInPath.add(root.getRelative(dep));
    }
  }
  return Collections.unmodifiableCollection(dependenciesInPath);
}

Fixed version (ground truth):
@VisibleForTesting Collection<String> getDependencies(){
  return filterShowIncludesOutputStream.getDependencies();
}
Program: 110762
Project: 110762
Buggy source:
/** 
 * Waits for the task queue to drain. Then if   {@code ownExecutorService} is true, shuts down the{@link ExecutorService} and waits for it to terminate. Throws (the same) unchecked exception ifany worker thread failed unexpectedly.
 */
protected final void awaitTermination(boolean interruptWorkers) throws InterruptedException {
  Throwables.propagateIfPossible(catastrophe);
  try {
synchronized (zeroRemainingTasks) {
      while (remainingTasks.get() != 0 && !jobsMustBeStopped) {
        zeroRemainingTasks.wait();
      }
    }
  }
 catch (  InterruptedException e) {
    setInterrupted();
  }
  reallyAwaitTermination(interruptWorkers);
  if (isInterrupted()) {
    Thread.currentThread().interrupt();
  }
  Throwables.propagateIfPossible(unhandled);
  if (Thread.interrupted()) {
    throw new InterruptedException();
  }
}

Fixed version (ground truth):
/** 
 * Waits for the task queue to drain. Then if   {@code ownExecutorService} is true, shuts down the{@link ExecutorService} and waits for it to terminate. Throws (the same) unchecked exception ifany worker thread failed unexpectedly.
 */
protected final void awaitTermination(boolean interruptWorkers) throws InterruptedException {
  reallyAwaitTermination(interruptWorkers);
  if (isInterrupted()) {
    Thread.currentThread().interrupt();
  }
  Throwables.propagateIfPossible(unhandled);
  if (Thread.interrupted()) {
    throw new InterruptedException();
  }
}
Program: 110763
Project: 110763
Buggy source:
@Override public final void awaitQuiescence(boolean interruptWorkers) throws InterruptedException {
  awaitTermination(interruptWorkers);
}

Fixed version (ground truth):
@Override public final void awaitQuiescence(boolean interruptWorkers) throws InterruptedException {
  Throwables.propagateIfPossible(catastrophe);
  try {
synchronized (zeroRemainingTasks) {
      while (remainingTasks.get() != 0 && !jobsMustBeStopped) {
        zeroRemainingTasks.wait();
      }
    }
  }
 catch (  InterruptedException e) {
    setInterrupted();
  }
  awaitTermination(interruptWorkers);
}
Program: 110764
Project: 110764
Buggy source:
private void visitAndWaitForCompletion() throws QueryException, InterruptedException {
  while (!mustJobsBeStopped() && (!processingQueue.isEmpty() || getTaskCount() > 0)) {
    if (getTaskCount() < MIN_PENDING_TASKS || processingQueue.size() >= SkyQueryEnvironment.BATCH_CALLBACK_SIZE) {
      Collection<T> pendingKeysToVisit=new ArrayList<>(processingQueue.size());
      processingQueue.drainTo(pendingKeysToVisit);
      for (      Task task : getVisitTasks(pendingKeysToVisit)) {
        execute(task);
      }
    }
    try {
      Thread.sleep(SCHEDULING_INTERVAL_MILLISECONDS);
    }
 catch (    InterruptedException e) {
      setInterrupted();
      awaitTerminationAndPropagateErrorsIfAny();
      throw e;
    }
  }
  awaitTerminationAndPropagateErrorsIfAny();
}

Fixed version (ground truth):
private void visitAndWaitForCompletion() throws QueryException, InterruptedException {
  while (!mustJobsBeStopped() && (!processingQueue.isEmpty() || getTaskCount() > 0)) {
    if (getTaskCount() < MIN_PENDING_TASKS || processingQueue.size() >= SkyQueryEnvironment.BATCH_CALLBACK_SIZE) {
      Collection<T> pendingKeysToVisit=new ArrayList<>(processingQueue.size());
      processingQueue.drainTo(pendingKeysToVisit);
      for (      Task task : getVisitTasks(pendingKeysToVisit)) {
        execute(task);
      }
    }
    try {
      Thread.sleep(SCHEDULING_INTERVAL_MILLISECONDS);
    }
 catch (    InterruptedException e) {
      setInterrupted();
      awaitTerminationAndPropagateErrorsIfAny();
    }
  }
  awaitTerminationAndPropagateErrorsIfAny();
}
Program: 110765
Project: 110765
Buggy source:
public boolean isOverwritable(){
  return type.isOverwritable();
}

Fixed version (ground truth):
public boolean isOverwritable(){
  return type.isOverwritable(this);
}
Program: 110766
Project: 110766
Buggy source:
public boolean isCombining(){
  return type != AttributeType.UNCOMBINABLE;
}

Fixed version (ground truth):
public boolean isCombining(){
  return type.isCombining();
}
Program: 110767
Project: 110767
Buggy source:
/** 
 * Converts the given flag values into a string hash for use as an output directory fragment. 
 */
private static String hashFlags(SortedMap<Label,String> flagValues){
  Hasher hasher=Hashing.murmur3_128().newHasher();
  for (  Map.Entry<Label,String> flag : flagValues.entrySet()) {
    hasher.putUnencodedChars(flag.getKey().toString());
    hasher.putUnencodedChars(flag.getValue());
  }
  return hasher.hash().toString();
}

Fixed version (ground truth):
/** 
 * Converts the given flag values into a string hash for use as an output directory fragment. 
 */
private static String hashFlags(SortedMap<Label,String> flagValues){
  Hasher hasher=Hashing.murmur3_128().newHasher();
  for (  Map.Entry<Label,String> flag : flagValues.entrySet()) {
    hasher.putUnencodedChars(flag.getKey().toString());
    hasher.putByte((byte)0);
    hasher.putUnencodedChars(flag.getValue());
    hasher.putByte((byte)0);
  }
  return hasher.hash().toString();
}
Program: 110768
Project: 110768
Buggy source:
private void stubMissingDefaultMethods(ImmutableList<String> interfaces){
  for (  String implemented : interfaces) {
    if (!seenInterfaces.add(implemented)) {
      continue;
    }
    ClassReader bytecode=classpath.readIfKnown(implemented);
    if (bytecode != null && !bootclasspath.isKnown(implemented)) {
      bytecode.accept(new DefaultMethodStubber(),ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG);
    }
  }
}

Fixed version (ground truth):
private void stubMissingDefaultMethods(String implemented){
  if (bootclasspath.isKnown(implemented)) {
    return;
  }
  ClassReader bytecode=checkNotNull(classpath.readIfKnown(implemented),"String_Node_Str",implemented,internalName);
  bytecode.accept(new DefaultMethodStubber(),ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG);
}
Program: 110769
Project: 110769
Buggy source:
public DefaultMethodClassFixer(ClassVisitor dest,ClassReaderFactory classpath,ClassReaderFactory bootclasspath){
  super(Opcodes.ASM5,dest);
  this.classpath=classpath;
  this.bootclasspath=bootclasspath;
}

Fixed version (ground truth):
public DefaultMethodClassFixer(ClassVisitor dest,ClassReaderFactory classpath,ClassReaderFactory bootclasspath,ClassLoader targetLoader){
  super(Opcodes.ASM5,dest);
  this.classpath=classpath;
  this.bootclasspath=bootclasspath;
  this.targetLoader=targetLoader;
}
Program: 110770
Project: 110770
Buggy source:
@Override public void visit(int version,int access,String name,String signature,String superName,String[] interfaces){
  checkArgument(BitFlags.noneSet(access,Opcodes.ACC_INTERFACE));
  for (  String inheritedInterface : interfaces) {
    seenInterfaces.add(inheritedInterface);
  }
  super.visit(version,access,name,signature,superName,interfaces);
}

Fixed version (ground truth):
@Override public void visit(int version,int access,String name,String signature,String superName,String[] interfaces){
  checkArgument(BitFlags.noneSet(access,Opcodes.ACC_INTERFACE));
  super.visit(version,access,name,signature,superName,interfaces);
}
Program: 110771
Project: 110771
Buggy source:
/** 
 * Create the class visitors for the lambda classes that are generated on the fly. If no new class visitors are not generated, then the passed-in   {@code writer} will be returned.
 */
private ClassVisitor createClassVisitorsForDumpedLambdaClasses(ClassLoader loader,@Nullable ClassReaderFactory classpathReader,ClassReaderFactory bootclasspathReader,ImmutableSet<String> interfaceLambdaMethods,@Nullable ClassReaderFactory bridgeMethodReader,LambdaInfo lambdaClass,UnprefixingClassWriter writer){
  ClassVisitor visitor=checkNotNull(writer);
  if (outputJava7) {
    visitor=new Java7Compatibility(visitor,(ClassReaderFactory)null);
    if (options.desugarTryWithResourcesIfNeeded) {
      visitor=new TryWithResourcesRewriter(visitor,loader,visitedExceptionTypes,numOfTryWithResourcesInvoked);
    }
    if (options.desugarInterfaceMethodBodiesIfNeeded) {
      visitor=new DefaultMethodClassFixer(visitor,classpathReader,bootclasspathReader);
      visitor=new InterfaceDesugaring(visitor,bootclasspathReader,store);
    }
  }
  visitor=new LambdaClassFixer(visitor,lambdaClass,bridgeMethodReader,interfaceLambdaMethods,allowDefaultMethods,outputJava7);
  visitor=new LambdaDesugaring(visitor,loader,lambdas,null,allowDefaultMethods);
  if (!allowCallsToObjectsNonNull) {
    visitor=new ObjectsRequireNonNullMethodRewriter(visitor);
  }
  if (options.enableRewritingOfLongCompare) {
    visitor=new LongCompareMethodRewriter(visitor);
  }
  return visitor;
}

Fixed version (ground truth):
/** 
 * Create the class visitors for the lambda classes that are generated on the fly. If no new class visitors are not generated, then the passed-in   {@code writer} will be returned.
 */
private ClassVisitor createClassVisitorsForDumpedLambdaClasses(ClassLoader loader,@Nullable ClassReaderFactory classpathReader,ClassReaderFactory bootclasspathReader,ImmutableSet<String> interfaceLambdaMethods,@Nullable ClassReaderFactory bridgeMethodReader,LambdaInfo lambdaClass,UnprefixingClassWriter writer){
  ClassVisitor visitor=checkNotNull(writer);
  if (outputJava7) {
    visitor=new Java7Compatibility(visitor,(ClassReaderFactory)null);
    if (options.desugarTryWithResourcesIfNeeded) {
      visitor=new TryWithResourcesRewriter(visitor,loader,visitedExceptionTypes,numOfTryWithResourcesInvoked);
    }
    if (options.desugarInterfaceMethodBodiesIfNeeded) {
      visitor=new DefaultMethodClassFixer(visitor,classpathReader,bootclasspathReader,loader);
      visitor=new InterfaceDesugaring(visitor,bootclasspathReader,store);
    }
  }
  visitor=new LambdaClassFixer(visitor,lambdaClass,bridgeMethodReader,interfaceLambdaMethods,allowDefaultMethods,outputJava7);
  visitor=new LambdaDesugaring(visitor,loader,lambdas,null,allowDefaultMethods);
  if (!allowCallsToObjectsNonNull) {
    visitor=new ObjectsRequireNonNullMethodRewriter(visitor);
  }
  if (options.enableRewritingOfLongCompare) {
    visitor=new LongCompareMethodRewriter(visitor);
  }
  return visitor;
}
Program: 110772
Project: 110772
Buggy source:
/** 
 * Create the class visitors for the classes which are in the inputs. If new visitors are created, then all these visitors and the passed-in writer will be chained together. If no new visitor is created, then the passed-in   {@code writer} will be returned.
 */
private ClassVisitor createClassVisitorsForClassesInInputs(ClassLoader loader,@Nullable ClassReaderFactory classpathReader,ClassReaderFactory bootclasspathReader,Builder<String> interfaceLambdaMethodCollector,UnprefixingClassWriter writer){
  ClassVisitor visitor=checkNotNull(writer);
  if (!options.onlyDesugarJavac9ForLint) {
    if (outputJava7) {
      visitor=new Java7Compatibility(visitor,classpathReader);
      if (options.desugarTryWithResourcesIfNeeded) {
        visitor=new TryWithResourcesRewriter(visitor,loader,visitedExceptionTypes,numOfTryWithResourcesInvoked);
      }
      if (options.desugarInterfaceMethodBodiesIfNeeded) {
        visitor=new DefaultMethodClassFixer(visitor,classpathReader,bootclasspathReader);
        visitor=new InterfaceDesugaring(visitor,bootclasspathReader,store);
      }
    }
    visitor=new LambdaDesugaring(visitor,loader,lambdas,interfaceLambdaMethodCollector,allowDefaultMethods);
  }
  if (!allowCallsToObjectsNonNull) {
    visitor=new ObjectsRequireNonNullMethodRewriter(visitor);
  }
  if (options.enableRewritingOfLongCompare) {
    visitor=new LongCompareMethodRewriter(visitor);
  }
  return visitor;
}

Fixed version (ground truth):
/** 
 * Create the class visitors for the classes which are in the inputs. If new visitors are created, then all these visitors and the passed-in writer will be chained together. If no new visitor is created, then the passed-in   {@code writer} will be returned.
 */
private ClassVisitor createClassVisitorsForClassesInInputs(ClassLoader loader,@Nullable ClassReaderFactory classpathReader,ClassReaderFactory bootclasspathReader,Builder<String> interfaceLambdaMethodCollector,UnprefixingClassWriter writer){
  ClassVisitor visitor=checkNotNull(writer);
  if (!options.onlyDesugarJavac9ForLint) {
    if (outputJava7) {
      visitor=new Java7Compatibility(visitor,classpathReader);
      if (options.desugarTryWithResourcesIfNeeded) {
        visitor=new TryWithResourcesRewriter(visitor,loader,visitedExceptionTypes,numOfTryWithResourcesInvoked);
      }
      if (options.desugarInterfaceMethodBodiesIfNeeded) {
        visitor=new DefaultMethodClassFixer(visitor,classpathReader,bootclasspathReader,loader);
        visitor=new InterfaceDesugaring(visitor,bootclasspathReader,store);
      }
    }
    visitor=new LambdaDesugaring(visitor,loader,lambdas,interfaceLambdaMethodCollector,allowDefaultMethods);
  }
  if (!allowCallsToObjectsNonNull) {
    visitor=new ObjectsRequireNonNullMethodRewriter(visitor);
  }
  if (options.enableRewritingOfLongCompare) {
    visitor=new LongCompareMethodRewriter(visitor);
  }
  return visitor;
}
Program: 110773
Project: 110773
Buggy source:
@Override public MethodVisitor visitMethod(int access,String name,String desc,String signature,String[] exceptions){
  MethodVisitor visitor=super.cv.visitMethod(access,name,desc,signature,exceptions);
  return visitor == null || THROWABLE_EXT_CLASS_INTERNAL_NAMES.contains(name) ? visitor : new TryWithResourceVisitor(visitor,classLoader);
}

Fixed version (ground truth):
@Override public MethodVisitor visitMethod(int access,String name,String desc,String signature,String[] exceptions){
  MethodVisitor visitor=super.cv.visitMethod(access,name,desc,signature,exceptions);
  return visitor == null || shouldCurrentClassBeIgnored ? visitor : new TryWithResourceVisitor(visitor,classLoader);
}
Program: 110775
Project: 110775
Buggy source:
@Override public void visitFrame(int type,int nLocal,Object[] local,int nStack,Object[] stack){
  if (isArrayNullOrEmpty(local)) {
    nLocal=0;
  }
  if (isArrayNullOrEmpty(stack)) {
    nStack=0;
  }
  super.visitFrame(type,nLocal,local,nStack,stack);
}

Fixed version (ground truth):
@Override public void visitFrame(int type,int nLocal,Object[] local,int nStack,Object[] stack){
  if (this.mv != null) {
    mv.visitFrame(type,nLocal,remapEntriesWithBugfix(nLocal,local),nStack,remapEntriesWithBugfix(nStack,stack));
  }
}
Program: 110776
Project: 110776
Buggy source:
@Override protected MethodVisitor createMethodRemapper(MethodVisitor mv){
  return new MethodRemapper(mv,this.remapper){
    private final boolean isArrayNullOrEmpty(    Object[] array){
      return array == null || array.length == 0;
    }
    @Override public void visitFrame(    int type,    int nLocal,    Object[] local,    int nStack,    Object[] stack){
      if (isArrayNullOrEmpty(local)) {
        nLocal=0;
      }
      if (isArrayNullOrEmpty(stack)) {
        nStack=0;
      }
      super.visitFrame(type,nLocal,local,nStack,stack);
    }
  }
;
}

Fixed version (ground truth):
@Override protected MethodVisitor createMethodRemapper(MethodVisitor mv){
  return new MethodRemapper(mv,this.remapper){
    @Override public void visitFrame(    int type,    int nLocal,    Object[] local,    int nStack,    Object[] stack){
      if (this.mv != null) {
        mv.visitFrame(type,nLocal,remapEntriesWithBugfix(nLocal,local),nStack,remapEntriesWithBugfix(nStack,stack));
      }
    }
    /** 
 * In   {@code FrameNode.accept(MethodVisitor)}, when the frame is Opcodes.F_CHOP, it is possible that nLocal is greater than 0, and local is null, which causes MethodRemapper to throw a NPE. So the patch is to make sure that the   {@code nLocal<=local.length} and{@code nStack<=stack.length}
 */
    private Object[] remapEntriesWithBugfix(    int n,    Object[] entries){
      if (entries == null || entries.length == 0) {
        return entries;
      }
      for (int i=0; i < n; i++) {
        if (entries[i] instanceof String) {
          Object[] newEntries=new Object[n];
          if (i > 0) {
            System.arraycopy(entries,0,newEntries,0,i);
          }
          do {
            Object t=entries[i];
            newEntries[i++]=t instanceof String ? remapper.mapType((String)t) : t;
          }
 while (i < n);
          return newEntries;
        }
      }
      return entries;
    }
  }
;
}
Program: 110777
Project: 110777
Buggy source:
static boolean isSupported(){
  String osxVersion=OS.getVersion();
  String[] parts=osxVersion.split("String_Node_Str");
  if (parts.length != 3) {
    return false;
  }
  try {
    int v0=Integer.parseInt(parts[0]);
    int v1=Integer.parseInt(parts[1]);
    if (v0 != 10 || v1 < 11) {
      return false;
    }
  }
 catch (  NumberFormatException e) {
    return false;
  }
  List<String> args=new ArrayList<>();
  args.add(SANDBOX_EXEC);
  args.add("String_Node_Str");
  args.add("String_Node_Str");
  args.add("String_Node_Str");
  ImmutableMap<String,String> env=ImmutableMap.of();
  File cwd=new File("String_Node_Str");
  Command cmd=new Command(args.toArray(new String[0]),env,cwd);
  try {
    cmd.execute(new byte[]{},Command.NO_OBSERVER,ByteStreams.nullOutputStream(),ByteStreams.nullOutputStream(),true);
  }
 catch (  CommandException e) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
static boolean isSupported(){
  String osxVersion=OS.getVersion();
  String[] parts=osxVersion.split("String_Node_Str");
  if (parts.length < 2 || parts.length > 3) {
    return false;
  }
  try {
    int v0=Integer.parseInt(parts[0]);
    int v1=Integer.parseInt(parts[1]);
    if (v0 != 10 || v1 < 11) {
      return false;
    }
  }
 catch (  NumberFormatException e) {
    return false;
  }
  List<String> args=new ArrayList<>();
  args.add(SANDBOX_EXEC);
  args.add("String_Node_Str");
  args.add("String_Node_Str");
  args.add("String_Node_Str");
  ImmutableMap<String,String> env=ImmutableMap.of();
  File cwd=new File("String_Node_Str");
  Command cmd=new Command(args.toArray(new String[0]),env,cwd);
  try {
    cmd.execute(new byte[]{},Command.NO_OBSERVER,ByteStreams.nullOutputStream(),ByteStreams.nullOutputStream(),true);
  }
 catch (  CommandException e) {
    return false;
  }
  return true;
}
Program: 110779
Project: 110779
Buggy source:
/** 
 * Tests if the resources need to be regenerated. <p>The resources should be regenerated (using aapt) if any of the following are true: <ul> <li>There is more than one resource container <li>There are densities to filter by. <li>There are resource configuration filters. <li>There are extensions that should be compressed. </ul>
 */
public static boolean shouldRegenerate(RuleContext ruleContext,ResourceDependencies resourceDeps){
  return Iterables.size(resourceDeps.getResources()) > 1 || ruleContext.attributes().isAttributeValueExplicitlySpecified("String_Node_Str") || ResourceConfigurationFilter.hasFilters(ruleContext) || ruleContext.attributes().isAttributeValueExplicitlySpecified("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Tests if the resources need to be regenerated. <p>The resources should be regenerated (using aapt) if any of the following are true: <ul> <li>There is more than one resource container <li>There are resource filters. <li>There are extensions that should be compressed. </ul>
 */
public static boolean shouldRegenerate(RuleContext ruleContext,ResourceDependencies resourceDeps){
  return Iterables.size(resourceDeps.getResources()) > 1 || ResourceFilter.hasFilters(ruleContext) || ruleContext.attributes().isAttributeValueExplicitlySpecified("String_Node_Str");
}
Program: 110781
Project: 110781
Buggy source:
@Override public RuleClass build(RuleClass.Builder builder,final RuleDefinitionEnvironment env){
  return builder.add(attr("String_Node_Str",STRING).allowedValues(new AllowedValueSet(AndroidManifestMerger.getAttributeValues())).value(AndroidManifestMerger.getRuleAttributeDefault())).add(attr("String_Node_Str",STRING_DICT)).add(attr("String_Node_Str",STRING_LIST)).add(attr("String_Node_Str",BOOLEAN).value(true)).add(attr(ResourceConfigurationFilter.ATTR_NAME,STRING_LIST)).add(attr("String_Node_Str",TRISTATE).value(TriState.AUTO)).add(attr("String_Node_Str",STRING_LIST)).add(attr("String_Node_Str",LABEL).cfg(HOST).exec().value(env.getToolsLabel(AndroidRuleClasses.MANIFEST_MERGE_TOOL_LABEL))).removeAttribute("String_Node_Str").build();
}

Fixed version (ground truth):
@Override public RuleClass build(RuleClass.Builder builder,final RuleDefinitionEnvironment env){
  return builder.add(attr("String_Node_Str",STRING).allowedValues(new AllowedValueSet(AndroidManifestMerger.getAttributeValues())).value(AndroidManifestMerger.getRuleAttributeDefault())).add(attr("String_Node_Str",STRING_DICT)).add(attr("String_Node_Str",STRING_LIST)).add(attr("String_Node_Str",BOOLEAN).value(true)).add(attr(ResourceFilter.RESOURCE_CONFIGURATION_FILTERS_NAME,STRING_LIST)).add(attr("String_Node_Str",TRISTATE).value(TriState.AUTO)).add(attr(ResourceFilter.DENSITIES_NAME,STRING_LIST)).add(attr("String_Node_Str",LABEL).cfg(HOST).exec().value(env.getToolsLabel(AndroidRuleClasses.MANIFEST_MERGE_TOOL_LABEL))).removeAttribute("String_Node_Str").build();
}
Program: 110783
Project: 110783
Buggy source:
/** 
 * @param ruleContext The RuleContext that was used to create the SpawnAction.Builder.
 */
public AndroidResourcesProcessorBuilder(RuleContext ruleContext){
  this.sdk=AndroidSdkProvider.fromRuleContext(ruleContext);
  this.ruleContext=ruleContext;
  this.spawnActionBuilder=new SpawnAction.Builder();
  this.resourceConfigs=ResourceConfigurationFilter.empty(ruleContext);
}

Fixed version (ground truth):
/** 
 * @param ruleContext The RuleContext that was used to create the SpawnAction.Builder.
 */
public AndroidResourcesProcessorBuilder(RuleContext ruleContext){
  this.sdk=AndroidSdkProvider.fromRuleContext(ruleContext);
  this.ruleContext=ruleContext;
  this.spawnActionBuilder=new SpawnAction.Builder();
  this.resourceFilter=ResourceFilter.empty(ruleContext);
}
Program: 110785
Project: 110785
Buggy source:
/** 
 * Packages up the manifest with resource and assets from the rule and dependent resources. 
 */
public ResourceApk packWithDataAndResources(@Nullable Artifact resourceApk,RuleContext ruleContext,boolean isLibrary,ResourceDependencies resourceDeps,Artifact rTxt,Artifact symbols,ResourceConfigurationFilter configurationFilters,List<String> uncompressedExtensions,boolean crunchPng,List<String> densities,boolean incremental,Artifact proguardCfg,@Nullable Artifact mainDexProguardCfg,Artifact manifestOut,Artifact mergedResources,Artifact dataBindingInfoZip,@Nullable Artifact featureOf,@Nullable Artifact featureAfter) throws InterruptedException {
  LocalResourceContainer data=new LocalResourceContainer.Builder(ruleContext).withAssets(AndroidCommon.getAssetDir(ruleContext),ruleContext.getPrerequisitesIf(ResourceType.ASSETS.getAttribute(),Mode.TARGET,FileProvider.class)).withResources(ruleContext.getPrerequisites("String_Node_Str",Mode.TARGET,FileProvider.class)).build();
  if (ruleContext.hasErrors()) {
    return null;
  }
  return createApk(ruleContext,isLibrary,resourceDeps,configurationFilters,uncompressedExtensions,crunchPng,densities,incremental,ResourceContainer.builderFromRule(ruleContext).setAssetsAndResourcesFrom(data).setManifest(getManifest()).setRTxt(rTxt).setSymbols(symbols).setApk(resourceApk).build(),data,proguardCfg,mainDexProguardCfg,manifestOut,mergedResources,dataBindingInfoZip,featureOf,featureAfter);
}

Fixed version (ground truth):
/** 
 * Packages up the manifest with resource and assets from the rule and dependent resources. 
 */
public ResourceApk packWithDataAndResources(@Nullable Artifact resourceApk,RuleContext ruleContext,boolean isLibrary,ResourceDependencies resourceDeps,Artifact rTxt,Artifact symbols,ResourceFilter resourceFilter,List<String> uncompressedExtensions,boolean crunchPng,boolean incremental,Artifact proguardCfg,@Nullable Artifact mainDexProguardCfg,Artifact manifestOut,Artifact mergedResources,Artifact dataBindingInfoZip,@Nullable Artifact featureOf,@Nullable Artifact featureAfter) throws InterruptedException {
  LocalResourceContainer data=new LocalResourceContainer.Builder(ruleContext).withAssets(AndroidCommon.getAssetDir(ruleContext),ruleContext.getPrerequisitesIf(ResourceType.ASSETS.getAttribute(),Mode.TARGET,FileProvider.class)).withResources(ruleContext.getPrerequisites("String_Node_Str",Mode.TARGET,FileProvider.class)).build();
  if (ruleContext.hasErrors()) {
    return null;
  }
  return createApk(ruleContext,isLibrary,resourceDeps,resourceFilter,uncompressedExtensions,crunchPng,incremental,ResourceContainer.builderFromRule(ruleContext).setAssetsAndResourcesFrom(data).setManifest(getManifest()).setRTxt(rTxt).setSymbols(symbols).setApk(resourceApk).build(),data,proguardCfg,mainDexProguardCfg,manifestOut,mergedResources,dataBindingInfoZip,featureOf,featureAfter);
}
Program: 110786
Project: 110786
Buggy source:
/** 
 * Packages up the manifest with assets from the rule and dependent resources.
 * @throws InterruptedException 
 */
public ResourceApk packWithAssets(Artifact resourceApk,RuleContext ruleContext,ResourceDependencies resourceDeps,Artifact rTxt,boolean incremental,Artifact proguardCfg) throws InterruptedException {
  LocalResourceContainer data=new LocalResourceContainer.Builder(ruleContext).withAssets(AndroidCommon.getAssetDir(ruleContext),ruleContext.getPrerequisitesIf(ResourceType.ASSETS.getAttribute(),Mode.TARGET,FileProvider.class)).build();
  return createApk(ruleContext,false,resourceDeps,ResourceConfigurationFilter.empty(ruleContext),ImmutableList.<String>of(),true,ImmutableList.<String>of(),incremental,ResourceContainer.builderFromRule(ruleContext).setAssetsAndResourcesFrom(data).setManifest(getManifest()).setRTxt(rTxt).setApk(resourceApk).build(),data,proguardCfg,null,null,null,null,null,null);
}

Fixed version (ground truth):
/** 
 * Packages up the manifest with assets from the rule and dependent resources.
 * @throws InterruptedException 
 */
public ResourceApk packWithAssets(Artifact resourceApk,RuleContext ruleContext,ResourceDependencies resourceDeps,Artifact rTxt,boolean incremental,Artifact proguardCfg) throws InterruptedException {
  LocalResourceContainer data=new LocalResourceContainer.Builder(ruleContext).withAssets(AndroidCommon.getAssetDir(ruleContext),ruleContext.getPrerequisitesIf(ResourceType.ASSETS.getAttribute(),Mode.TARGET,FileProvider.class)).build();
  return createApk(ruleContext,false,resourceDeps,ResourceFilter.empty(ruleContext),ImmutableList.<String>of(),true,incremental,ResourceContainer.builderFromRule(ruleContext).setAssetsAndResourcesFrom(data).setManifest(getManifest()).setRTxt(rTxt).setApk(resourceApk).build(),data,proguardCfg,null,null,null,null,null,null);
}
Program: 110789
Project: 110789
Buggy source:
private PathFragment checkForWorkspace(PathFragment path){
  sawWorkspaceName=sawWorkspaceName || path.getSegment(0).equals(workspaceName);
  return path;
}

Fixed version (ground truth):
private PathFragment checkForWorkspace(PathFragment path){
  sawWorkspaceName=sawWorkspaceName || path.getSegment(0).equals(workspaceName.getPathString());
  return path;
}
Program: 110790
Project: 110790
Buggy source:
@Override public BuildOptions apply(BuildOptions buildOptions){
  BuildOptions result=buildOptions.clone();
  if (!appleCrosstoolTransitionIsAppliedForAllObjc(buildOptions)) {
    return buildOptions;
  }
  String cpu=String.format("String_Node_Str",buildOptions.get(AppleCommandLineOptions.class).applePlatformType,buildOptions.get(AppleCommandLineOptions.class).getSingleArchitecture());
  setAppleCrosstoolTransitionConfiguration(buildOptions,result,cpu);
  return result;
}

Fixed version (ground truth):
@Override public BuildOptions apply(BuildOptions buildOptions){
  BuildOptions result=buildOptions.clone();
  if (!appleCrosstoolTransitionIsAppliedForAllObjc(buildOptions)) {
    return buildOptions;
  }
  String cpu=Platform.cpuStringForTarget(buildOptions.get(AppleCommandLineOptions.class).applePlatformType,buildOptions.get(AppleCommandLineOptions.class).getSingleArchitecture());
  setAppleCrosstoolTransitionConfiguration(buildOptions,result,cpu);
  return result;
}