Program: 12068
Project: 12068
Buggy source:
public PDGSubTreeMapper(PDG pdg1,PDG pdg2,ICompilationUnit iCompilationUnit1,ICompilationUnit iCompilationUnit2,ControlDependenceTreeNode controlDependenceSubTreePDG1,ControlDependenceTreeNode controlDependenceSubTreePDG2,boolean fullTreeMatch,IProgressMonitor monitor){
  this.pdg1=pdg1;
  this.pdg2=pdg2;
  this.iCompilationUnit1=iCompilationUnit1;
  this.iCompilationUnit2=iCompilationUnit2;
  this.fullTreeMatch=fullTreeMatch;
  this.nonMappedNodesG1=new TreeSet<PDGNode>();
  this.nonMappedNodesG2=new TreeSet<PDGNode>();
  this.commonPassedParameters=new LinkedHashMap<String,ArrayList<AbstractVariable>>();
  this.declaredLocalVariablesInMappedNodes=new LinkedHashMap<String,ArrayList<AbstractVariable>>();
  this.passedParametersG1=new LinkedHashSet<AbstractVariable>();
  this.passedParametersG2=new LinkedHashSet<AbstractVariable>();
  this.accessedLocalFieldsG1=new LinkedHashSet<AbstractVariable>();
  this.accessedLocalFieldsG2=new LinkedHashSet<AbstractVariable>();
  this.accessedLocalMethodsG1=new LinkedHashSet<MethodInvocationObject>();
  this.accessedLocalMethodsG2=new LinkedHashSet<MethodInvocationObject>();
  this.declaredVariablesInMappedNodesUsedByNonMappedNodesG1=new LinkedHashSet<AbstractVariable>();
  this.declaredVariablesInMappedNodesUsedByNonMappedNodesG2=new LinkedHashSet<AbstractVariable>();
  this.monitor=monitor;
  this.allNodesInSubTreePDG1=new TreeSet<PDGNode>();
  this.allNodesInSubTreePDG2=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG1MovableBefore=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG1MovableAfter=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG1MovableBeforeAndAfter=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG2MovableBefore=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG2MovableAfter=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG2MovableBeforeAndAfter=new TreeSet<PDGNode>();
  matchBasedOnControlDependenceTreeStructure(controlDependenceSubTreePDG1,controlDependenceSubTreePDG2);
  if (maximumStateWithMinimumDifferences != null) {
    this.mappedNodesG1=maximumStateWithMinimumDifferences.getMappedNodesG1();
    this.mappedNodesG2=maximumStateWithMinimumDifferences.getMappedNodesG2();
    findNonMappedNodes(pdg1,allNodesInSubTreePDG1,mappedNodesG1,nonMappedNodesG1);
    findNonMappedNodes(pdg2,allNodesInSubTreePDG2,mappedNodesG2,nonMappedNodesG2);
    Set<PDGNode> additionallyMatchedNodesG1=new LinkedHashSet<PDGNode>();
    for (    PDGNode nodeG1 : nonMappedNodesG1) {
      boolean advancedMatch=cloneStructureRoot.isGapNodeG1InAdditionalMatches(nodeG1);
      if (advancedMatch) {
        additionallyMatchedNodesG1.add(nodeG1);
      }
      PDGNodeGap nodeGap=new PDGNodeGap(nodeG1,null,advancedMatch);
      CloneStructureNode node=new CloneStructureNode(nodeGap);
      PDGBlockNode tryNode=pdg1.isDirectlyNestedWithinBlockNode(nodeG1);
      if (tryNode != null) {
        CloneStructureNode cloneStructureTry=cloneStructureRoot.findNodeG1(tryNode);
        if (cloneStructureTry != null) {
          node.setParent(cloneStructureTry);
        }
      }
 else {
        cloneStructureRoot.addGapChild(node);
      }
    }
    nonMappedNodesG1.removeAll(additionallyMatchedNodesG1);
    Set<PDGNode> additionallyMatchedNodesG2=new LinkedHashSet<PDGNode>();
    for (    PDGNode nodeG2 : nonMappedNodesG2) {
      boolean advancedMatch=cloneStructureRoot.isGapNodeG2InAdditionalMatches(nodeG2);
      if (advancedMatch) {
        additionallyMatchedNodesG2.add(nodeG2);
      }
      PDGNodeGap nodeGap=new PDGNodeGap(null,nodeG2,advancedMatch);
      CloneStructureNode node=new CloneStructureNode(nodeGap);
      PDGBlockNode tryNode=pdg2.isDirectlyNestedWithinBlockNode(nodeG2);
      if (tryNode != null) {
        CloneStructureNode cloneStructureTry=cloneStructureRoot.findNodeG2(tryNode);
        if (cloneStructureTry != null) {
          node.setParent(cloneStructureTry);
        }
      }
 else {
        cloneStructureRoot.addGapChild(node);
      }
    }
    nonMappedNodesG2.removeAll(additionallyMatchedNodesG2);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg1,mappedNodesG1,declaredVariablesInMappedNodesUsedByNonMappedNodesG1);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg2,mappedNodesG2,declaredVariablesInMappedNodesUsedByNonMappedNodesG2);
    findPassedParameters();
    findLocallyAccessedFields(pdg1,mappedNodesG1,accessedLocalFieldsG1,accessedLocalMethodsG1);
    findLocallyAccessedFields(pdg2,mappedNodesG2,accessedLocalFieldsG2,accessedLocalMethodsG2);
    this.preconditionViolations=new ArrayList<PreconditionViolation>();
    this.variablesToBeReturnedG1=variablesToBeReturned(pdg1,getRemovableNodesG1());
    this.variablesToBeReturnedG2=variablesToBeReturned(pdg2,getRemovableNodesG2());
    checkCloneStructureNodeForPreconditions(cloneStructureRoot);
    processNonMappedNodesMovableBeforeAndAfter();
    checkPreconditionsAboutReturnedVariables();
  }
}

Fixed version (ground truth):
public PDGSubTreeMapper(PDG pdg1,PDG pdg2,ICompilationUnit iCompilationUnit1,ICompilationUnit iCompilationUnit2,ControlDependenceTreeNode controlDependenceSubTreePDG1,ControlDependenceTreeNode controlDependenceSubTreePDG2,boolean fullTreeMatch,IProgressMonitor monitor){
  this.pdg1=pdg1;
  this.pdg2=pdg2;
  this.iCompilationUnit1=iCompilationUnit1;
  this.iCompilationUnit2=iCompilationUnit2;
  this.fullTreeMatch=fullTreeMatch;
  this.nonMappedNodesG1=new TreeSet<PDGNode>();
  this.nonMappedNodesG2=new TreeSet<PDGNode>();
  this.commonPassedParameters=new LinkedHashMap<VariableBindingKeyPair,ArrayList<AbstractVariable>>();
  this.declaredLocalVariablesInMappedNodes=new LinkedHashMap<VariableBindingKeyPair,ArrayList<AbstractVariable>>();
  this.passedParametersG1=new LinkedHashSet<AbstractVariable>();
  this.passedParametersG2=new LinkedHashSet<AbstractVariable>();
  this.accessedLocalFieldsG1=new LinkedHashSet<AbstractVariable>();
  this.accessedLocalFieldsG2=new LinkedHashSet<AbstractVariable>();
  this.accessedLocalMethodsG1=new LinkedHashSet<MethodInvocationObject>();
  this.accessedLocalMethodsG2=new LinkedHashSet<MethodInvocationObject>();
  this.declaredVariablesInMappedNodesUsedByNonMappedNodesG1=new LinkedHashSet<AbstractVariable>();
  this.declaredVariablesInMappedNodesUsedByNonMappedNodesG2=new LinkedHashSet<AbstractVariable>();
  this.monitor=monitor;
  this.allNodesInSubTreePDG1=new TreeSet<PDGNode>();
  this.allNodesInSubTreePDG2=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG1MovableBefore=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG1MovableAfter=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG1MovableBeforeAndAfter=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG2MovableBefore=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG2MovableAfter=new TreeSet<PDGNode>();
  this.nonMappedPDGNodesG2MovableBeforeAndAfter=new TreeSet<PDGNode>();
  matchBasedOnControlDependenceTreeStructure(controlDependenceSubTreePDG1,controlDependenceSubTreePDG2);
  if (maximumStateWithMinimumDifferences != null) {
    this.mappedNodesG1=maximumStateWithMinimumDifferences.getMappedNodesG1();
    this.mappedNodesG2=maximumStateWithMinimumDifferences.getMappedNodesG2();
    findNonMappedNodes(pdg1,allNodesInSubTreePDG1,mappedNodesG1,nonMappedNodesG1);
    findNonMappedNodes(pdg2,allNodesInSubTreePDG2,mappedNodesG2,nonMappedNodesG2);
    Set<PDGNode> additionallyMatchedNodesG1=new LinkedHashSet<PDGNode>();
    for (    PDGNode nodeG1 : nonMappedNodesG1) {
      boolean advancedMatch=cloneStructureRoot.isGapNodeG1InAdditionalMatches(nodeG1);
      if (advancedMatch) {
        additionallyMatchedNodesG1.add(nodeG1);
      }
      PDGNodeGap nodeGap=new PDGNodeGap(nodeG1,null,advancedMatch);
      CloneStructureNode node=new CloneStructureNode(nodeGap);
      PDGBlockNode tryNode=pdg1.isDirectlyNestedWithinBlockNode(nodeG1);
      if (tryNode != null) {
        CloneStructureNode cloneStructureTry=cloneStructureRoot.findNodeG1(tryNode);
        if (cloneStructureTry != null) {
          node.setParent(cloneStructureTry);
        }
      }
 else {
        cloneStructureRoot.addGapChild(node);
      }
    }
    nonMappedNodesG1.removeAll(additionallyMatchedNodesG1);
    Set<PDGNode> additionallyMatchedNodesG2=new LinkedHashSet<PDGNode>();
    for (    PDGNode nodeG2 : nonMappedNodesG2) {
      boolean advancedMatch=cloneStructureRoot.isGapNodeG2InAdditionalMatches(nodeG2);
      if (advancedMatch) {
        additionallyMatchedNodesG2.add(nodeG2);
      }
      PDGNodeGap nodeGap=new PDGNodeGap(null,nodeG2,advancedMatch);
      CloneStructureNode node=new CloneStructureNode(nodeGap);
      PDGBlockNode tryNode=pdg2.isDirectlyNestedWithinBlockNode(nodeG2);
      if (tryNode != null) {
        CloneStructureNode cloneStructureTry=cloneStructureRoot.findNodeG2(tryNode);
        if (cloneStructureTry != null) {
          node.setParent(cloneStructureTry);
        }
      }
 else {
        cloneStructureRoot.addGapChild(node);
      }
    }
    nonMappedNodesG2.removeAll(additionallyMatchedNodesG2);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg1,mappedNodesG1,declaredVariablesInMappedNodesUsedByNonMappedNodesG1);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg2,mappedNodesG2,declaredVariablesInMappedNodesUsedByNonMappedNodesG2);
    findPassedParameters();
    findLocallyAccessedFields(pdg1,mappedNodesG1,accessedLocalFieldsG1,accessedLocalMethodsG1);
    findLocallyAccessedFields(pdg2,mappedNodesG2,accessedLocalFieldsG2,accessedLocalMethodsG2);
    this.preconditionViolations=new ArrayList<PreconditionViolation>();
    this.variablesToBeReturnedG1=variablesToBeReturned(pdg1,getRemovableNodesG1());
    this.variablesToBeReturnedG2=variablesToBeReturned(pdg2,getRemovableNodesG2());
    checkCloneStructureNodeForPreconditions(cloneStructureRoot);
    processNonMappedNodesMovableBeforeAndAfter();
    checkPreconditionsAboutReturnedVariables();
  }
}