Program: 12051
Project: 12051
Buggy source:
public PreconditionExaminer(PDG pdg1,PDG pdg2,ICompilationUnit iCompilationUnit1,ICompilationUnit iCompilationUnit2,CloneStructureNode cloneStructureRoot,MappingState finalState,TreeSet<PDGNode> allNodesInSubTreePDG1,TreeSet<PDGNode> allNodesInSubTreePDG2){
  this.pdg1=pdg1;
  this.pdg2=pdg2;
  this.iCompilationUnit1=iCompilationUnit1;
  this.iCompilationUnit2=iCompilationUnit2;
  this.cloneStructureRoot=cloneStructureRoot;
  this.finalState=finalState;
  this.allNodesInSubTreePDG1=allNodesInSubTreePDG1;
  this.allNodesInSubTreePDG2=allNodesInSubTreePDG2;
  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.renamedFields=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>();
  this.mappedNodesG1=new TreeSet<PDGNode>();
  this.mappedNodesG2=new TreeSet<PDGNode>();
  this.additionallyMatchedNodesG1=new TreeSet<PDGNode>();
  this.additionallyMatchedNodesG2=new TreeSet<PDGNode>();
  this.declaredLocalVariablesInAdditionallyMatchedNodesG1=new LinkedHashSet<AbstractVariable>();
  this.declaredLocalVariablesInAdditionallyMatchedNodesG2=new LinkedHashSet<AbstractVariable>();
  if (getMaximumStateWithMinimumDifferences() != null) {
    this.mappedNodesG1=getMaximumStateWithMinimumDifferences().getMappedNodesG1();
    this.mappedNodesG2=getMaximumStateWithMinimumDifferences().getMappedNodesG2();
    findNonMappedNodes(getAllNodesInSubTreePDG1(),mappedNodesG1,nonMappedNodesG1);
    findNonMappedNodes(getAllNodesInSubTreePDG2(),mappedNodesG2,nonMappedNodesG2);
    for (    PDGNode nodeG1 : nonMappedNodesG1) {
      boolean advancedMatch=getCloneStructureRoot().isGapNodeG1InAdditionalMatches(nodeG1);
      List<ASTNodeDifference> differencesForAdvancedMatch=new ArrayList<ASTNodeDifference>();
      if (advancedMatch) {
        additionallyMatchedNodesG1.add(nodeG1);
        for (        ASTNodeDifference difference : getNodeDifferences()) {
          if (isExpressionUnderStatement(difference.getExpression1().getExpression(),nodeG1.getASTStatement())) {
            differencesForAdvancedMatch.add(difference);
          }
        }
        List<AbstractVariable> nonAnonymousDeclaredVariablesG1=new ArrayList<AbstractVariable>();
        Iterator<AbstractVariable> declaredVariableIteratorG1=nodeG1.getDeclaredVariableIterator();
        while (declaredVariableIteratorG1.hasNext()) {
          AbstractVariable declaredVariableG1=declaredVariableIteratorG1.next();
          String key1=declaredVariableG1.getVariableBindingKey();
          String declaringType1=key1.substring(0,key1.indexOf("String_Node_Str"));
          if (!declaringType1.contains("String_Node_Str")) {
            nonAnonymousDeclaredVariablesG1.add(declaredVariableG1);
          }
        }
        declaredLocalVariablesInAdditionallyMatchedNodesG1.addAll(nonAnonymousDeclaredVariablesG1);
      }
      PDGNodeGap nodeGap=new PDGNodeGap(nodeG1,null,advancedMatch,differencesForAdvancedMatch);
      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);
    mappedNodesG1.addAll(additionallyMatchedNodesG1);
    for (    PDGNode nodeG2 : nonMappedNodesG2) {
      boolean advancedMatch=getCloneStructureRoot().isGapNodeG2InAdditionalMatches(nodeG2);
      List<ASTNodeDifference> differencesForAdvancedMatch=new ArrayList<ASTNodeDifference>();
      if (advancedMatch) {
        additionallyMatchedNodesG2.add(nodeG2);
        for (        ASTNodeDifference difference : getNodeDifferences()) {
          if (isExpressionUnderStatement(difference.getExpression2().getExpression(),nodeG2.getASTStatement())) {
            differencesForAdvancedMatch.add(difference);
          }
        }
        List<AbstractVariable> nonAnonymousDeclaredVariablesG2=new ArrayList<AbstractVariable>();
        Iterator<AbstractVariable> declaredVariableIteratorG2=nodeG2.getDeclaredVariableIterator();
        while (declaredVariableIteratorG2.hasNext()) {
          AbstractVariable declaredVariableG2=declaredVariableIteratorG2.next();
          String key2=declaredVariableG2.getVariableBindingKey();
          String declaringType2=key2.substring(0,key2.indexOf("String_Node_Str"));
          if (!declaringType2.contains("String_Node_Str")) {
            nonAnonymousDeclaredVariablesG2.add(declaredVariableG2);
          }
        }
        declaredLocalVariablesInAdditionallyMatchedNodesG2.addAll(nonAnonymousDeclaredVariablesG2);
      }
      PDGNodeGap nodeGap=new PDGNodeGap(null,nodeG2,advancedMatch,differencesForAdvancedMatch);
      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);
    mappedNodesG2.addAll(additionallyMatchedNodesG2);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg1,mappedNodesG1,nonMappedNodesG1,declaredVariablesInMappedNodesUsedByNonMappedNodesG1);
    findDeclaredVariablesInMappedNodesUsedByNonMappedNodes(pdg2,mappedNodesG2,nonMappedNodesG2,declaredVariablesInMappedNodesUsedByNonMappedNodesG2);
    findRenamedVariables(renamedVariables,renamedFields);
    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,this.iCompilationUnit1);
    findLocallyAccessedFields(pdg2,mappedNodesG2,commonSuperclass,directlyAccessedLocalFieldsG2,indirectlyAccessedLocalFieldsG2,accessedLocalMethodsG2,expressions2,fieldAccessReplacedWithGetterExpressions2,this.iCompilationUnit2);
    this.variablesToBeReturnedG1=variablesToBeReturned(pdg1,getRemovableNodesG1());
    this.variablesToBeReturnedG2=variablesToBeReturned(pdg2,getRemovableNodesG2());
    checkCloneStructureNodeForPreconditions(getCloneStructureRoot());
    processNonMappedNodesMovableBeforeAndAfter();
    checkPreconditionsAboutReturnedVariables();
    checkIfAllPossibleExecutionFlowsEndInReturn();
  }
}

Fixed version (ground truth):
public PreconditionExaminer(PDG pdg1,PDG pdg2,ICompilationUnit iCompilationUnit1,ICompilationUnit iCompilationUnit2,CloneStructureNode cloneStructureRoot,MappingState finalState,TreeSet<PDGNode> allNodesInSubTreePDG1,TreeSet<PDGNode> allNodesInSubTreePDG2){
  this.pdg1=pdg1;
  this.pdg2=pdg2;
  this.iCompilationUnit1=iCompilationUnit1;
  this.iCompilationUnit2=iCompilationUnit2;
  this.cloneStructureRoot=cloneStructureRoot;
  this.finalState=finalState;
  this.allNodesInSubTreePDG1=allNodesInSubTreePDG1;
  this.allNodesInSubTreePDG2=allNodesInSubTreePDG2;
  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.preconditionViolations=new ArrayList<PreconditionViolation>();
  this.renamedVariables=new LinkedHashSet<BindingSignaturePair>();
  this.renamedFields=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>();
  this.mappedNodesG1=new TreeSet<PDGNode>();
  this.mappedNodesG2=new TreeSet<PDGNode>();
  this.additionallyMatchedNodesG1=new TreeSet<PDGNode>();
  this.additionallyMatchedNodesG2=new TreeSet<PDGNode>();
  this.declaredLocalVariablesInAdditionallyMatchedNodesG1=new LinkedHashSet<AbstractVariable>();
  this.declaredLocalVariablesInAdditionallyMatchedNodesG2=new LinkedHashSet<AbstractVariable>();
  if (getMaximumStateWithMinimumDifferences() != null) {
    this.mappedNodesG1=getMaximumStateWithMinimumDifferences().getMappedNodesG1();
    this.mappedNodesG2=getMaximumStateWithMinimumDifferences().getMappedNodesG2();
    findNonMappedNodes(getAllNodesInSubTreePDG1(),mappedNodesG1,nonMappedNodesG1);
    findNonMappedNodes(getAllNodesInSubTreePDG2(),mappedNodesG2,nonMappedNodesG2);
    for (    PDGNode nodeG1 : nonMappedNodesG1) {
      boolean advancedMatch=getCloneStructureRoot().isGapNodeG1InAdditionalMatches(nodeG1);
      List<ASTNodeDifference> differencesForAdvancedMatch=new ArrayList<ASTNodeDifference>();
      if (advancedMatch) {
        additionallyMatchedNodesG1.add(nodeG1);
        for (        ASTNodeDifference difference : getNodeDifferences()) {
          if (isExpressionUnderStatement(difference.getExpression1().getExpression(),nodeG1.getASTStatement())) {
            differencesForAdvancedMatch.add(difference);
          }
        }
        List<AbstractVariable> nonAnonymousDeclaredVariablesG1=new ArrayList<AbstractVariable>();
        Iterator<AbstractVariable> declaredVariableIteratorG1=nodeG1.getDeclaredVariableIterator();
        while (declaredVariableIteratorG1.hasNext()) {
          AbstractVariable declaredVariableG1=declaredVariableIteratorG1.next();
          String key1=declaredVariableG1.getVariableBindingKey();
          String declaringType1=key1.substring(0,key1.indexOf("String_Node_Str"));
          if (!declaringType1.contains("String_Node_Str")) {
            nonAnonymousDeclaredVariablesG1.add(declaredVariableG1);
          }
        }
        declaredLocalVariablesInAdditionallyMatchedNodesG1.addAll(nonAnonymousDeclaredVariablesG1);
      }
      PDGNodeGap nodeGap=new PDGNodeGap(nodeG1,null,advancedMatch,differencesForAdvancedMatch);
      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);
    mappedNodesG1.addAll(additionallyMatchedNodesG1);
    for (    PDGNode nodeG2 : nonMappedNodesG2) {
      boolean advancedMatch=getCloneStructureRoot().isGapNodeG2InAdditionalMatches(nodeG2);
      List<ASTNodeDifference> differencesForAdvancedMatch=new ArrayList<ASTNodeDifference>();
      if (advancedMatch) {
        additionallyMatchedNodesG2.add(nodeG2);
        for (        ASTNodeDifference difference : getNodeDifferences()) {
          if (isExpressionUnderStatement(difference.getExpression2().getExpression(),nodeG2.getASTStatement())) {
            differencesForAdvancedMatch.add(difference);
          }
        }
        List<AbstractVariable> nonAnonymousDeclaredVariablesG2=new ArrayList<AbstractVariable>();
        Iterator<AbstractVariable> declaredVariableIteratorG2=nodeG2.getDeclaredVariableIterator();
        while (declaredVariableIteratorG2.hasNext()) {
          AbstractVariable declaredVariableG2=declaredVariableIteratorG2.next();
          String key2=declaredVariableG2.getVariableBindingKey();
          String declaringType2=key2.substring(0,key2.indexOf("String_Node_Str"));
          if (!declaringType2.contains("String_Node_Str")) {
            nonAnonymousDeclaredVariablesG2.add(declaredVariableG2);
          }
        }
        declaredLocalVariablesInAdditionallyMatchedNodesG2.addAll(nonAnonymousDeclaredVariablesG2);
      }
      PDGNodeGap nodeGap=new PDGNodeGap(null,nodeG2,advancedMatch,differencesForAdvancedMatch);
      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);
    mappedNodesG2.addAll(additionallyMatchedNodesG2);
    findRenamedVariables(renamedVariables,renamedFields);
    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,this.iCompilationUnit1);
    findLocallyAccessedFields(pdg2,mappedNodesG2,commonSuperclass,directlyAccessedLocalFieldsG2,indirectlyAccessedLocalFieldsG2,accessedLocalMethodsG2,expressions2,fieldAccessReplacedWithGetterExpressions2,this.iCompilationUnit2);
    this.variablesToBeReturnedG1=variablesToBeReturned(pdg1,getRemovableNodesG1());
    this.variablesToBeReturnedG2=variablesToBeReturned(pdg2,getRemovableNodesG2());
    checkCloneStructureNodeForPreconditions(getCloneStructureRoot());
    processNonMappedNodesMovableBeforeAndAfter();
    checkPreconditionsAboutReturnedVariables();
    checkIfAllPossibleExecutionFlowsEndInReturn();
  }
}