Program: 12024
Project: 12024
Buggy source:
public PDGObjectSliceUnion(PDG pdg,BasicBlock boundaryBlock,Set<PDGNode> allNodeCriteria,PlainVariable objectReference){
  this.pdg=pdg;
  this.subgraph=new PDGSlice(pdg,boundaryBlock);
  this.sliceNodes=new TreeSet<PDGNode>();
  for (  PDGNode nodeCriterion : allNodeCriteria) {
    sliceNodes.addAll(subgraph.computeSlice(nodeCriterion));
  }
  this.method=pdg.getMethod();
  this.iFile=pdg.getIFile();
  this.methodSize=pdg.getTotalNumberOfStatements();
  this.boundaryBlock=boundaryBlock;
  this.allNodeCriteria=allNodeCriteria;
  this.objectReference=objectReference;
  Set<PDGNode> nodesToBeAddedToSliceDueToDependenceOnObjectStateSlices=new TreeSet<PDGNode>();
  Set<PlainVariable> alreadyExaminedObjectReferences=new LinkedHashSet<PlainVariable>();
  for (  PDGNode sliceNode : sliceNodes) {
    Set<AbstractVariable> usedVariables=sliceNode.usedVariables;
    for (    AbstractVariable usedVariable : usedVariables) {
      if (usedVariable instanceof PlainVariable) {
        PlainVariable plainVariable=(PlainVariable)usedVariable;
        if (!alreadyExaminedObjectReferences.contains(plainVariable) && !objectReference.equals(plainVariable)) {
          Map<CompositeVariable,LinkedHashSet<PDGNode>> definedAttributeNodeCriteriaMap=pdg.getDefinedAttributesOfReference(plainVariable);
          if (!definedAttributeNodeCriteriaMap.isEmpty()) {
            TreeSet<PDGNode> objectSlice=new TreeSet<PDGNode>();
            for (            CompositeVariable compositeVariable : definedAttributeNodeCriteriaMap.keySet()) {
              Set<PDGNode> nodeCriteria2=definedAttributeNodeCriteriaMap.get(compositeVariable);
              for (              PDGNode nodeCriterion : nodeCriteria2) {
                if (subgraph.nodeBelongsToBlockBasedRegion(nodeCriterion))                 objectSlice.addAll(subgraph.computeSlice(nodeCriterion));
              }
            }
            nodesToBeAddedToSliceDueToDependenceOnObjectStateSlices.addAll(objectSlice);
          }
          alreadyExaminedObjectReferences.add(plainVariable);
        }
      }
    }
  }
  sliceNodes.addAll(nodesToBeAddedToSliceDueToDependenceOnObjectStateSlices);
  Set<PDGNode> throwStatementNodes=getThrowStatementNodesWithinRegion();
  Set<PDGNode> nodesToBeAddedToSliceDueToThrowStatementNodes=new TreeSet<PDGNode>();
  for (  PDGNode throwNode : throwStatementNodes) {
    for (    PDGNode sliceNode : sliceNodes) {
      if (sliceNode instanceof PDGControlPredicateNode && isNestedInside(throwNode,sliceNode)) {
        Set<PDGNode> throwNodeSlice=subgraph.computeSlice(throwNode);
        nodesToBeAddedToSliceDueToThrowStatementNodes.addAll(throwNodeSlice);
        break;
      }
    }
  }
  sliceNodes.addAll(nodesToBeAddedToSliceDueToThrowStatementNodes);
  Set<PDGNode> remainingNodes=new TreeSet<PDGNode>();
  remainingNodes.add(pdg.getEntryNode());
  for (  GraphNode node : pdg.nodes) {
    PDGNode pdgNode=(PDGNode)node;
    if (!sliceNodes.contains(pdgNode))     remainingNodes.add(pdgNode);
  }
  Set<PDGNode> throwStatementNodesToBeAddedToDuplicatedNodesDueToRemainingNodes=new TreeSet<PDGNode>();
  for (  PDGNode throwNode : throwStatementNodes) {
    for (    PDGNode remainingNode : remainingNodes) {
      if (remainingNode.getId() != 0 && isNestedInside(throwNode,remainingNode)) {
        throwStatementNodesToBeAddedToDuplicatedNodesDueToRemainingNodes.add(throwNode);
        break;
      }
    }
  }
  this.passedParameters=new LinkedHashSet<AbstractVariable>();
  Set<PDGNode> nCD=new LinkedHashSet<PDGNode>();
  Set<PDGNode> nDD=new LinkedHashSet<PDGNode>();
  for (  GraphEdge edge : pdg.edges) {
    PDGDependence dependence=(PDGDependence)edge;
    PDGNode srcPDGNode=(PDGNode)dependence.src;
    PDGNode dstPDGNode=(PDGNode)dependence.dst;
    if (dependence instanceof PDGDataDependence) {
      PDGDataDependence dataDependence=(PDGDataDependence)dependence;
      if (remainingNodes.contains(srcPDGNode) && sliceNodes.contains(dstPDGNode))       passedParameters.add(dataDependence.getData());
      if (sliceNodes.contains(srcPDGNode) && remainingNodes.contains(dstPDGNode) && !dataDependence.getData().equals(objectReference))       nDD.add(srcPDGNode);
    }
 else     if (dependence instanceof PDGControlDependence) {
      if (sliceNodes.contains(srcPDGNode) && remainingNodes.contains(dstPDGNode))       nCD.add(srcPDGNode);
    }
  }
  Set<PDGNode> controlIndispensableNodes=new LinkedHashSet<PDGNode>();
  for (  PDGNode p : nCD) {
    for (    AbstractVariable usedVariable : p.usedVariables) {
      Set<PDGNode> pSliceNodes=subgraph.computeSlice(p,usedVariable);
      for (      GraphNode node : pdg.nodes) {
        PDGNode q=(PDGNode)node;
        if (pSliceNodes.contains(q) || q.equals(p))         controlIndispensableNodes.add(q);
      }
    }
    if (p.usedVariables.isEmpty()) {
      Set<PDGNode> pSliceNodes=subgraph.computeSlice(p);
      for (      GraphNode node : pdg.nodes) {
        PDGNode q=(PDGNode)node;
        if (pSliceNodes.contains(q) || q.equals(p))         controlIndispensableNodes.add(q);
      }
    }
  }
  Set<PDGNode> dataIndispensableNodes=new LinkedHashSet<PDGNode>();
  for (  PDGNode p : nDD) {
    for (    AbstractVariable definedVariable : p.definedVariables) {
      Set<PDGNode> pSliceNodes=subgraph.computeSlice(p,definedVariable);
      for (      GraphNode node : pdg.nodes) {
        PDGNode q=(PDGNode)node;
        if (pSliceNodes.contains(q))         dataIndispensableNodes.add(q);
      }
    }
  }
  this.indispensableNodes=new TreeSet<PDGNode>();
  indispensableNodes.addAll(controlIndispensableNodes);
  indispensableNodes.addAll(dataIndispensableNodes);
  Set<PDGNode> throwStatementNodesToBeAddedToDuplicatedNodesDueToIndispensableNodes=new TreeSet<PDGNode>();
  for (  PDGNode throwNode : throwStatementNodes) {
    for (    PDGNode indispensableNode : indispensableNodes) {
      if (isNestedInside(throwNode,indispensableNode)) {
        throwStatementNodesToBeAddedToDuplicatedNodesDueToIndispensableNodes.add(throwNode);
        break;
      }
    }
  }
  for (  PDGNode throwNode : throwStatementNodesToBeAddedToDuplicatedNodesDueToRemainingNodes) {
    indispensableNodes.addAll(subgraph.computeSlice(throwNode));
  }
  for (  PDGNode throwNode : throwStatementNodesToBeAddedToDuplicatedNodesDueToIndispensableNodes) {
    indispensableNodes.addAll(subgraph.computeSlice(throwNode));
  }
  this.removableNodes=new LinkedHashSet<PDGNode>();
  for (  GraphNode node : pdg.nodes) {
    PDGNode pdgNode=(PDGNode)node;
    if (!remainingNodes.contains(pdgNode) && !indispensableNodes.contains(pdgNode))     removableNodes.add(pdgNode);
  }
  for (  PDGNode node : sliceNodes) {
    if (!(node instanceof PDGTryNode)) {
      if (node.declaresLocalVariable(objectReference) || ((objectReference.isField() || objectReference.isParameter()) && node.instantiatesLocalVariable(objectReference) && node.definesLocalVariable(objectReference))) {
        removableNodes.add(node);
        indispensableNodes.remove(node);
        break;
      }
    }
  }
}

Fixed version (ground truth):
public PDGObjectSliceUnion(PDG pdg,BasicBlock boundaryBlock,Set<PDGNode> allNodeCriteria,PlainVariable objectReference){
  this.pdg=pdg;
  this.subgraph=new PDGSlice(pdg,boundaryBlock);
  this.sliceNodes=new TreeSet<PDGNode>();
  for (  PDGNode nodeCriterion : allNodeCriteria) {
    sliceNodes.addAll(subgraph.computeSlice(nodeCriterion));
  }
  this.method=pdg.getMethod();
  this.iFile=pdg.getIFile();
  this.methodSize=pdg.getTotalNumberOfStatements();
  this.boundaryBlock=boundaryBlock;
  this.allNodeCriteria=allNodeCriteria;
  this.objectReference=objectReference;
  Set<PDGNode> nodesToBeAddedToSliceDueToDependenceOnObjectStateSlices=new TreeSet<PDGNode>();
  Set<PlainVariable> alreadyExaminedObjectReferences=new LinkedHashSet<PlainVariable>();
  for (  PDGNode sliceNode : sliceNodes) {
    Set<AbstractVariable> usedVariables=sliceNode.usedVariables;
    for (    AbstractVariable usedVariable : usedVariables) {
      if (usedVariable instanceof PlainVariable) {
        PlainVariable plainVariable=(PlainVariable)usedVariable;
        if (!alreadyExaminedObjectReferences.contains(plainVariable) && !objectReference.equals(plainVariable)) {
          Map<CompositeVariable,LinkedHashSet<PDGNode>> definedAttributeNodeCriteriaMap=pdg.getDefinedAttributesOfReference(plainVariable);
          if (!definedAttributeNodeCriteriaMap.isEmpty()) {
            TreeSet<PDGNode> objectSlice=new TreeSet<PDGNode>();
            for (            CompositeVariable compositeVariable : definedAttributeNodeCriteriaMap.keySet()) {
              Set<PDGNode> nodeCriteria2=definedAttributeNodeCriteriaMap.get(compositeVariable);
              for (              PDGNode nodeCriterion : nodeCriteria2) {
                if (subgraph.nodeBelongsToBlockBasedRegion(nodeCriterion))                 objectSlice.addAll(subgraph.computeSlice(nodeCriterion));
              }
            }
            nodesToBeAddedToSliceDueToDependenceOnObjectStateSlices.addAll(objectSlice);
          }
          alreadyExaminedObjectReferences.add(plainVariable);
        }
      }
    }
  }
  sliceNodes.addAll(nodesToBeAddedToSliceDueToDependenceOnObjectStateSlices);
  Set<PDGNode> throwStatementNodes=getThrowStatementNodesWithinRegion();
  Set<PDGNode> nodesToBeAddedToSliceDueToThrowStatementNodes=new TreeSet<PDGNode>();
  for (  PDGNode throwNode : throwStatementNodes) {
    for (    PDGNode sliceNode : sliceNodes) {
      if (sliceNode instanceof PDGControlPredicateNode && isNestedInside(throwNode,sliceNode)) {
        Set<PDGNode> throwNodeSlice=subgraph.computeSlice(throwNode);
        nodesToBeAddedToSliceDueToThrowStatementNodes.addAll(throwNodeSlice);
        break;
      }
    }
  }
  sliceNodes.addAll(nodesToBeAddedToSliceDueToThrowStatementNodes);
  Set<PDGNode> remainingNodes=new TreeSet<PDGNode>();
  remainingNodes.add(pdg.getEntryNode());
  for (  GraphNode node : pdg.nodes) {
    PDGNode pdgNode=(PDGNode)node;
    if (!sliceNodes.contains(pdgNode))     remainingNodes.add(pdgNode);
  }
  Set<PDGNode> throwStatementNodesToBeAddedToDuplicatedNodesDueToRemainingNodes=new TreeSet<PDGNode>();
  for (  PDGNode throwNode : throwStatementNodes) {
    for (    PDGNode remainingNode : remainingNodes) {
      if (remainingNode.getId() != 0 && isNestedInside(throwNode,remainingNode)) {
        throwStatementNodesToBeAddedToDuplicatedNodesDueToRemainingNodes.add(throwNode);
        break;
      }
    }
  }
  this.passedParameters=new LinkedHashSet<AbstractVariable>();
  Set<PDGNode> nCD=new LinkedHashSet<PDGNode>();
  Set<PDGNode> nDD=new LinkedHashSet<PDGNode>();
  for (  GraphEdge edge : pdg.edges) {
    PDGDependence dependence=(PDGDependence)edge;
    PDGNode srcPDGNode=(PDGNode)dependence.src;
    PDGNode dstPDGNode=(PDGNode)dependence.dst;
    if (dependence instanceof PDGDataDependence) {
      PDGDataDependence dataDependence=(PDGDataDependence)dependence;
      if (remainingNodes.contains(srcPDGNode) && sliceNodes.contains(dstPDGNode))       passedParameters.add(dataDependence.getData());
      if (sliceNodes.contains(srcPDGNode) && remainingNodes.contains(dstPDGNode) && !dataDependence.getData().equals(objectReference)&& !dataDependence.getData().isField())       nDD.add(srcPDGNode);
    }
 else     if (dependence instanceof PDGControlDependence) {
      if (sliceNodes.contains(srcPDGNode) && remainingNodes.contains(dstPDGNode))       nCD.add(srcPDGNode);
    }
  }
  Set<PDGNode> controlIndispensableNodes=new LinkedHashSet<PDGNode>();
  for (  PDGNode p : nCD) {
    for (    AbstractVariable usedVariable : p.usedVariables) {
      Set<PDGNode> pSliceNodes=subgraph.computeSlice(p,usedVariable);
      for (      GraphNode node : pdg.nodes) {
        PDGNode q=(PDGNode)node;
        if (pSliceNodes.contains(q) || q.equals(p))         controlIndispensableNodes.add(q);
      }
    }
    if (p.usedVariables.isEmpty()) {
      Set<PDGNode> pSliceNodes=subgraph.computeSlice(p);
      for (      GraphNode node : pdg.nodes) {
        PDGNode q=(PDGNode)node;
        if (pSliceNodes.contains(q) || q.equals(p))         controlIndispensableNodes.add(q);
      }
    }
  }
  Set<PDGNode> dataIndispensableNodes=new LinkedHashSet<PDGNode>();
  for (  PDGNode p : nDD) {
    for (    AbstractVariable definedVariable : p.definedVariables) {
      Set<PDGNode> pSliceNodes=subgraph.computeSlice(p,definedVariable);
      for (      GraphNode node : pdg.nodes) {
        PDGNode q=(PDGNode)node;
        if (pSliceNodes.contains(q))         dataIndispensableNodes.add(q);
      }
    }
  }
  this.indispensableNodes=new TreeSet<PDGNode>();
  indispensableNodes.addAll(controlIndispensableNodes);
  indispensableNodes.addAll(dataIndispensableNodes);
  Set<PDGNode> throwStatementNodesToBeAddedToDuplicatedNodesDueToIndispensableNodes=new TreeSet<PDGNode>();
  for (  PDGNode throwNode : throwStatementNodes) {
    for (    PDGNode indispensableNode : indispensableNodes) {
      if (isNestedInside(throwNode,indispensableNode)) {
        throwStatementNodesToBeAddedToDuplicatedNodesDueToIndispensableNodes.add(throwNode);
        break;
      }
    }
  }
  for (  PDGNode throwNode : throwStatementNodesToBeAddedToDuplicatedNodesDueToRemainingNodes) {
    indispensableNodes.addAll(subgraph.computeSlice(throwNode));
  }
  for (  PDGNode throwNode : throwStatementNodesToBeAddedToDuplicatedNodesDueToIndispensableNodes) {
    indispensableNodes.addAll(subgraph.computeSlice(throwNode));
  }
  this.removableNodes=new LinkedHashSet<PDGNode>();
  for (  GraphNode node : pdg.nodes) {
    PDGNode pdgNode=(PDGNode)node;
    if (!remainingNodes.contains(pdgNode) && !indispensableNodes.contains(pdgNode))     removableNodes.add(pdgNode);
  }
  for (  PDGNode node : sliceNodes) {
    if (!(node instanceof PDGTryNode)) {
      if (node.declaresLocalVariable(objectReference) || ((objectReference.isField() || objectReference.isParameter()) && node.instantiatesLocalVariable(objectReference) && node.definesLocalVariable(objectReference))) {
        removableNodes.add(node);
        indispensableNodes.remove(node);
        break;
      }
    }
  }
}