Program: 12064
Project: 12064
Buggy source:
public PDGSubTreeMapper(PDG pdg1,PDG pdg2,ICompilationUnit iCompilationUnit1,ICompilationUnit iCompilationUnit2,ControlDependenceTreeNode controlDependenceSubTreePDG1,ControlDependenceTreeNode controlDependenceSubTreePDG2,boolean fullTreeMatch,IProgressMonitor monitor){
  super(pdg1,pdg2,iCompilationUnit1,iCompilationUnit2,controlDependenceSubTreePDG1,controlDependenceSubTreePDG2,fullTreeMatch,monitor);
  this.pdg1=pdg1;
  this.pdg2=pdg2;
  this.iCompilationUnit1=iCompilationUnit1;
  this.iCompilationUnit2=iCompilationUnit2;
  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.directlyAccessedLocalFieldsG1=new LinkedHashSet<AbstractVariable>();
  this.directlyAccessedLocalFieldsG2=new LinkedHashSet<AbstractVariable>();
  this.indirectlyAccessedLocalFieldsG1=new LinkedHashSet<AbstractVariable>();
  this.indirectlyAccessedLocalFieldsG2=new LinkedHashSet<AbstractVariable>();
  this.accessedLocalMethodsG1=new LinkedHashSet<MethodObject>();
  this.accessedLocalMethodsG2=new LinkedHashSet<MethodObject>();
  this.declaredVariablesInMappedNodesUsedByNonMappedNodesG1=new LinkedHashSet<AbstractVariable>();
  this.declaredVariablesInMappedNodesUsedByNonMappedNodesG2=new LinkedHashSet<AbstractVariable>();
  this.preconditionViolations=new ArrayList<PreconditionViolation>();
  this.renamedVariables=new LinkedHashSet<BindingSignaturePair>();
  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();
  if (getMaximumStateWithMinimumDifferences() != null) {
    this.mappedNodesG1=getMaximumStateWithMinimumDifferences().getMappedNodesG1();
    this.mappedNodesG2=getMaximumStateWithMinimumDifferences().getMappedNodesG2();
    findNonMappedNodes(pdg1,getAllNodesInSubTreePDG1(),mappedNodesG1,nonMappedNodesG1);
    findNonMappedNodes(pdg2,getAllNodesInSubTreePDG2(),mappedNodesG2,nonMappedNodesG2);
    Set<PDGNode> additionallyMatchedNodesG1=new LinkedHashSet<PDGNode>();
    for (    PDGNode nodeG1 : nonMappedNodesG1) {
      boolean advancedMatch=getCloneStructureRoot().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=getCloneStructureRoot().findNodeG1(tryNode);
        if (cloneStructureTry != null) {
          node.setParent(cloneStructureTry);
        }
      }
 else {
        getCloneStructureRoot().addGapChild(node);
      }
    }
    nonMappedNodesG1.removeAll(additionallyMatchedNodesG1);
    Set<PDGNode> additionallyMatchedNodesG2=new LinkedHashSet<PDGNode>();
    for (    PDGNode nodeG2 : nonMappedNodesG2) {
      boolean advancedMatch=getCloneStructureRoot().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=getCloneStructureRoot().findNodeG2(tryNode);
        if (cloneStructureTry != null) {
          node.setParent(cloneStructureTry);
        }
      }
 else {
        getCloneStructureRoot().addGapChild(node);
      }
    }
    nonMappedNodesG2.removeAll(additionallyMatchedNodesG2);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg1,mappedNodesG1,nonMappedNodesG1,declaredVariablesInMappedNodesUsedByNonMappedNodesG1);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg2,mappedNodesG2,nonMappedNodesG2,declaredVariablesInMappedNodesUsedByNonMappedNodesG2);
    this.renamedVariables=findRenamedVariables();
    findPassedParameters();
    List<AbstractExpression> expressions1=new ArrayList<AbstractExpression>();
    List<AbstractExpression> expressions2=new ArrayList<AbstractExpression>();
    List<AbstractExpression> fieldAccessReplacedWithGetterExpressions1=new ArrayList<AbstractExpression>();
    List<AbstractExpression> fieldAccessReplacedWithGetterExpressions2=new ArrayList<AbstractExpression>();
    for (    ASTNodeDifference nodeDifference : getNodeDifferences()) {
      if (!nodeDifference.containsDifferenceType(DifferenceType.FIELD_ACCESS_REPLACED_WITH_GETTER)) {
        expressions1.add(nodeDifference.getExpression1());
        expressions2.add(nodeDifference.getExpression2());
      }
 else {
        fieldAccessReplacedWithGetterExpressions1.add(nodeDifference.getExpression1());
        fieldAccessReplacedWithGetterExpressions2.add(nodeDifference.getExpression2());
      }
    }
    ITypeBinding commonSuperclass=ASTNodeMatcher.commonSuperType(pdg1.getMethod().getMethodDeclaration().resolveBinding().getDeclaringClass(),pdg2.getMethod().getMethodDeclaration().resolveBinding().getDeclaringClass());
    findLocallyAccessedFields(pdg1,mappedNodesG1,commonSuperclass,directlyAccessedLocalFieldsG1,indirectlyAccessedLocalFieldsG1,accessedLocalMethodsG1,expressions1,fieldAccessReplacedWithGetterExpressions1);
    findLocallyAccessedFields(pdg2,mappedNodesG2,commonSuperclass,directlyAccessedLocalFieldsG2,indirectlyAccessedLocalFieldsG2,accessedLocalMethodsG2,expressions2,fieldAccessReplacedWithGetterExpressions2);
    this.variablesToBeReturnedG1=variablesToBeReturned(pdg1,getRemovableNodesG1());
    this.variablesToBeReturnedG2=variablesToBeReturned(pdg2,getRemovableNodesG2());
    checkCloneStructureNodeForPreconditions(getCloneStructureRoot());
    processNonMappedNodesMovableBeforeAndAfter();
    checkPreconditionsAboutReturnedVariables();
    checkIfAllPossibleExecutionFlowsEndInReturn();
  }
}

Fixed version (ground truth):
public PDGSubTreeMapper(PDG pdg1,PDG pdg2,ICompilationUnit iCompilationUnit1,ICompilationUnit iCompilationUnit2,ControlDependenceTreeNode controlDependenceSubTreePDG1,ControlDependenceTreeNode controlDependenceSubTreePDG2,boolean fullTreeMatch,IProgressMonitor monitor){
  super(pdg1,pdg2,iCompilationUnit1,iCompilationUnit2,controlDependenceSubTreePDG1,controlDependenceSubTreePDG2,fullTreeMatch,monitor);
  this.pdg1=pdg1;
  this.pdg2=pdg2;
  this.iCompilationUnit1=iCompilationUnit1;
  this.iCompilationUnit2=iCompilationUnit2;
  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.directlyAccessedLocalFieldsG1=new LinkedHashSet<AbstractVariable>();
  this.directlyAccessedLocalFieldsG2=new LinkedHashSet<AbstractVariable>();
  this.indirectlyAccessedLocalFieldsG1=new LinkedHashSet<AbstractVariable>();
  this.indirectlyAccessedLocalFieldsG2=new LinkedHashSet<AbstractVariable>();
  this.accessedLocalMethodsG1=new LinkedHashSet<MethodObject>();
  this.accessedLocalMethodsG2=new LinkedHashSet<MethodObject>();
  this.declaredVariablesInMappedNodesUsedByNonMappedNodesG1=new LinkedHashSet<AbstractVariable>();
  this.declaredVariablesInMappedNodesUsedByNonMappedNodesG2=new LinkedHashSet<AbstractVariable>();
  this.preconditionViolations=new ArrayList<PreconditionViolation>();
  this.renamedVariables=new LinkedHashSet<BindingSignaturePair>();
  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();
  if (getMaximumStateWithMinimumDifferences() != null) {
    this.mappedNodesG1=getMaximumStateWithMinimumDifferences().getMappedNodesG1();
    this.mappedNodesG2=getMaximumStateWithMinimumDifferences().getMappedNodesG2();
    findNonMappedNodes(pdg1,getAllNodesInSubTreePDG1(),mappedNodesG1,nonMappedNodesG1);
    findNonMappedNodes(pdg2,getAllNodesInSubTreePDG2(),mappedNodesG2,nonMappedNodesG2);
    Set<PDGNode> additionallyMatchedNodesG1=new LinkedHashSet<PDGNode>();
    for (    PDGNode nodeG1 : nonMappedNodesG1) {
      boolean advancedMatch=getCloneStructureRoot().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=getCloneStructureRoot().findNodeG1(tryNode);
        if (cloneStructureTry != null) {
          node.setParent(cloneStructureTry);
        }
      }
 else {
        getCloneStructureRoot().addGapChild(node);
      }
    }
    nonMappedNodesG1.removeAll(additionallyMatchedNodesG1);
    Set<PDGNode> additionallyMatchedNodesG2=new LinkedHashSet<PDGNode>();
    for (    PDGNode nodeG2 : nonMappedNodesG2) {
      boolean advancedMatch=getCloneStructureRoot().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=getCloneStructureRoot().findNodeG2(tryNode);
        if (cloneStructureTry != null) {
          node.setParent(cloneStructureTry);
        }
      }
 else {
        getCloneStructureRoot().addGapChild(node);
      }
    }
    nonMappedNodesG2.removeAll(additionallyMatchedNodesG2);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg1,mappedNodesG1,nonMappedNodesG1,declaredVariablesInMappedNodesUsedByNonMappedNodesG1);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg2,mappedNodesG2,nonMappedNodesG2,declaredVariablesInMappedNodesUsedByNonMappedNodesG2);
    this.renamedVariables=findRenamedVariables();
    findPassedParameters();
    List<Expression> expressions1=new ArrayList<Expression>();
    List<Expression> expressions2=new ArrayList<Expression>();
    List<AbstractExpression> fieldAccessReplacedWithGetterExpressions1=new ArrayList<AbstractExpression>();
    List<AbstractExpression> fieldAccessReplacedWithGetterExpressions2=new ArrayList<AbstractExpression>();
    for (    ASTNodeDifference nodeDifference : getNodeDifferences()) {
      if (!nodeDifference.containsDifferenceType(DifferenceType.FIELD_ACCESS_REPLACED_WITH_GETTER)) {
        Expression expression1=nodeDifference.getExpression1().getExpression();
        Expression expr1=ASTNodeDifference.getParentExpressionOfMethodNameOrTypeName(expression1);
        if (expression1.equals(expr1)) {
          expressions1.add(expression1);
        }
 else {
          expressions1.add(expr1);
        }
        Expression expression2=nodeDifference.getExpression2().getExpression();
        Expression expr2=ASTNodeDifference.getParentExpressionOfMethodNameOrTypeName(expression2);
        if (expression2.equals(expr2)) {
          expressions2.add(expression2);
        }
 else {
          expressions2.add(expr2);
        }
      }
 else {
        fieldAccessReplacedWithGetterExpressions1.add(nodeDifference.getExpression1());
        fieldAccessReplacedWithGetterExpressions2.add(nodeDifference.getExpression2());
      }
    }
    ITypeBinding commonSuperclass=ASTNodeMatcher.commonSuperType(pdg1.getMethod().getMethodDeclaration().resolveBinding().getDeclaringClass(),pdg2.getMethod().getMethodDeclaration().resolveBinding().getDeclaringClass());
    findLocallyAccessedFields(pdg1,mappedNodesG1,commonSuperclass,directlyAccessedLocalFieldsG1,indirectlyAccessedLocalFieldsG1,accessedLocalMethodsG1,expressions1,fieldAccessReplacedWithGetterExpressions1);
    findLocallyAccessedFields(pdg2,mappedNodesG2,commonSuperclass,directlyAccessedLocalFieldsG2,indirectlyAccessedLocalFieldsG2,accessedLocalMethodsG2,expressions2,fieldAccessReplacedWithGetterExpressions2);
    this.variablesToBeReturnedG1=variablesToBeReturned(pdg1,getRemovableNodesG1());
    this.variablesToBeReturnedG2=variablesToBeReturned(pdg2,getRemovableNodesG2());
    checkCloneStructureNodeForPreconditions(getCloneStructureRoot());
    processNonMappedNodesMovableBeforeAndAfter();
    checkPreconditionsAboutReturnedVariables();
    checkIfAllPossibleExecutionFlowsEndInReturn();
  }
}