Program: 12202
Project: 12202
Buggy source:
private void processTypeCheckCodeFragment(){
  List<ArrayList<Statement>> typeCheckStatements=typeCheckElimination.getTypeCheckStatements();
  ArrayList<Statement> firstBlockOfStatements=typeCheckStatements.get(0);
  Statement firstStatementOfBlock=firstBlockOfStatements.get(0);
  if (firstStatementOfBlock.getParent() instanceof SwitchStatement) {
    SwitchStatement switchStatement=(SwitchStatement)firstStatementOfBlock.getParent();
    Expression switchStatementExpression=switchStatement.getExpression();
    SimpleName switchStatementExpressionName=extractOperandName(switchStatementExpression);
    if (switchStatementExpressionName != null) {
      IBinding switchStatementExpressionNameBinding=switchStatementExpressionName.resolveBinding();
      if (switchStatementExpressionNameBinding.getKind() == IBinding.VARIABLE) {
        IVariableBinding switchStatementExpressionNameVariableBinding=(IVariableBinding)switchStatementExpressionNameBinding;
        for (        InheritanceTree tree : inheritanceTreeList) {
          DefaultMutableTreeNode root=tree.getRootNode();
          String rootClassName=(String)root.getUserObject();
          ITypeBinding variableTypeBinding=switchStatementExpressionNameVariableBinding.getType();
          if (rootClassName.equals(variableTypeBinding.getQualifiedName())) {
            typeCheckElimination.setExistingInheritanceTree(tree);
            break;
          }
        }
        if (switchStatementExpressionNameVariableBinding.isField()) {
          for (          FieldDeclaration field : fields) {
            List<VariableDeclarationFragment> fragments=field.fragments();
            for (            VariableDeclarationFragment fragment : fragments) {
              IVariableBinding fragmentVariableBinding=fragment.resolveBinding();
              if (fragmentVariableBinding.isEqualTo(switchStatementExpressionNameVariableBinding)) {
                typeCheckElimination.setTypeField(fragment);
                for (                MethodDeclaration method : methods) {
                  SimpleName fieldInstruction=MethodDeclarationUtility.isSetter(method);
                  if (fieldInstruction != null && fragment.getName().getIdentifier().equals(fieldInstruction.getIdentifier())) {
                    typeCheckElimination.setTypeFieldSetterMethod(method);
                  }
                  fieldInstruction=MethodDeclarationUtility.isGetter(method);
                  if (fieldInstruction != null && fragment.getName().getIdentifier().equals(fieldInstruction.getIdentifier())) {
                    typeCheckElimination.setTypeFieldGetterMethod(method);
                  }
                }
                break;
              }
            }
          }
        }
 else {
          typeCheckElimination.setTypeLocalVariable(switchStatementExpressionName);
        }
      }
    }
  }
  Set<Expression> typeCheckExpressions=typeCheckElimination.getTypeCheckExpressions();
  for (  Expression typeCheckExpression : typeCheckExpressions) {
    if (typeCheckExpression.getParent() instanceof SwitchCase) {
      if (typeCheckExpression instanceof SimpleName) {
        SimpleName simpleName=(SimpleName)typeCheckExpression;
        IBinding binding=simpleName.resolveBinding();
        if (binding.getKind() == IBinding.VARIABLE) {
          IVariableBinding variableBinding=(IVariableBinding)binding;
          if (variableBinding.isField() && (variableBinding.getModifiers() & Modifier.STATIC) != 0) {
            typeCheckElimination.addStaticType(typeCheckExpression,simpleName);
          }
        }
      }
 else       if (typeCheckExpression instanceof QualifiedName) {
        QualifiedName qualifiedName=(QualifiedName)typeCheckExpression;
        IBinding binding=qualifiedName.resolveBinding();
        if (binding.getKind() == IBinding.VARIABLE) {
          IVariableBinding variableBinding=(IVariableBinding)binding;
          if (variableBinding.isField() && (variableBinding.getModifiers() & Modifier.STATIC) != 0) {
            typeCheckElimination.addStaticType(typeCheckExpression,qualifiedName.getName());
          }
        }
      }
 else       if (typeCheckExpression instanceof FieldAccess) {
        FieldAccess fieldAccess=(FieldAccess)typeCheckExpression;
        IVariableBinding variableBinding=fieldAccess.resolveFieldBinding();
        if (variableBinding.isField() && (variableBinding.getModifiers() & Modifier.STATIC) != 0) {
          typeCheckElimination.addStaticType(typeCheckExpression,fieldAccess.getName());
        }
      }
    }
 else     if (typeCheckExpression instanceof InstanceofExpression) {
      InstanceofExpression instanceofExpression=(InstanceofExpression)typeCheckExpression;
      SimpleName operandName=extractOperandName(instanceofExpression.getLeftOperand());
      if (operandName != null) {
        SimpleName keySimpleName=containsKey(operandName);
        if (keySimpleName != null) {
          typeVariableCounterMap.put(keySimpleName,typeVariableCounterMap.get(keySimpleName) + 1);
        }
 else {
          typeVariableCounterMap.put(operandName,1);
        }
        typeCheckElimination.addSubclassType(typeCheckExpression,instanceofExpression.getRightOperand());
      }
    }
 else     if (typeCheckExpression instanceof InfixExpression) {
      InfixExpression infixExpression=(InfixExpression)typeCheckExpression;
      IfStatementExpressionAnalyzer analyzer=new IfStatementExpressionAnalyzer(infixExpression);
      for (      InfixExpression leafInfixExpression : analyzer.getInfixExpressionsWithEqualsOperator()) {
        Expression leftOperand=leafInfixExpression.getLeftOperand();
        Expression rightOperand=leafInfixExpression.getRightOperand();
        infixExpressionHandler(leftOperand,leafInfixExpression,analyzer);
        infixExpressionHandler(rightOperand,leafInfixExpression,analyzer);
      }
      for (      InstanceofExpression leafInstanceofExpression : analyzer.getInstanceofExpressions()) {
        SimpleName operandName=extractOperandName(leafInstanceofExpression.getLeftOperand());
        if (operandName != null) {
          SimpleName keySimpleName=containsKey(operandName);
          if (keySimpleName != null && analyzer.allParentNodesAreConditionalAndOperators()) {
            typeVariableCounterMap.put(keySimpleName,typeVariableCounterMap.get(keySimpleName) + 1);
          }
 else {
            typeVariableCounterMap.put(operandName,1);
          }
          typeCheckElimination.addRemainingIfStatementExpression(analyzer.getCompleteExpression(),analyzer.getRemainingExpression(leafInstanceofExpression));
          typeCheckElimination.addSubclassType(typeCheckExpression,leafInstanceofExpression.getRightOperand());
        }
      }
    }
  }
  for (  SimpleName typeVariable : typeVariableCounterMap.keySet()) {
    if (typeVariableCounterMap.get(typeVariable) == typeCheckExpressions.size()) {
      IBinding binding=typeVariable.resolveBinding();
      if (binding.getKind() == IBinding.VARIABLE) {
        IVariableBinding variableBinding=(IVariableBinding)binding;
        for (        InheritanceTree tree : inheritanceTreeList) {
          DefaultMutableTreeNode root=tree.getRootNode();
          String rootClassName=(String)root.getUserObject();
          ITypeBinding variableTypeBinding=variableBinding.getType();
          if (rootClassName.equals(variableTypeBinding.getQualifiedName())) {
            typeCheckElimination.setExistingInheritanceTree(tree);
            break;
          }
        }
        if (variableBinding.isField()) {
          for (          FieldDeclaration field : fields) {
            List<VariableDeclarationFragment> fragments=field.fragments();
            for (            VariableDeclarationFragment fragment : fragments) {
              IVariableBinding fragmentVariableBinding=fragment.resolveBinding();
              if (fragmentVariableBinding.isEqualTo(variableBinding)) {
                typeCheckElimination.setTypeField(fragment);
                for (                MethodDeclaration method : methods) {
                  SimpleName fieldInstruction=MethodDeclarationUtility.isSetter(method);
                  if (fieldInstruction != null && fragment.getName().getIdentifier().equals(fieldInstruction.getIdentifier())) {
                    typeCheckElimination.setTypeFieldSetterMethod(method);
                  }
                  fieldInstruction=MethodDeclarationUtility.isGetter(method);
                  if (fieldInstruction != null && fragment.getName().getIdentifier().equals(fieldInstruction.getIdentifier())) {
                    typeCheckElimination.setTypeFieldGetterMethod(method);
                  }
                }
                break;
              }
            }
          }
        }
 else {
          typeCheckElimination.setTypeLocalVariable(typeVariable);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void processTypeCheckCodeFragment(){
  List<ArrayList<Statement>> typeCheckStatements=typeCheckElimination.getTypeCheckStatements();
  ArrayList<Statement> firstBlockOfStatements=typeCheckStatements.get(0);
  Statement firstStatementOfBlock=firstBlockOfStatements.get(0);
  if (firstStatementOfBlock.getParent() instanceof SwitchStatement) {
    SwitchStatement switchStatement=(SwitchStatement)firstStatementOfBlock.getParent();
    Expression switchStatementExpression=switchStatement.getExpression();
    SimpleName switchStatementExpressionName=extractOperandName(switchStatementExpression);
    if (switchStatementExpressionName != null) {
      IBinding switchStatementExpressionNameBinding=switchStatementExpressionName.resolveBinding();
      if (switchStatementExpressionNameBinding.getKind() == IBinding.VARIABLE) {
        IVariableBinding switchStatementExpressionNameVariableBinding=(IVariableBinding)switchStatementExpressionNameBinding;
        for (        InheritanceTree tree : inheritanceTreeList) {
          DefaultMutableTreeNode root=tree.getRootNode();
          String rootClassName=(String)root.getUserObject();
          ITypeBinding variableTypeBinding=switchStatementExpressionNameVariableBinding.getType();
          if (rootClassName.equals(variableTypeBinding.getQualifiedName())) {
            typeCheckElimination.setExistingInheritanceTree(tree);
            break;
          }
        }
        if (switchStatementExpressionNameVariableBinding.isField()) {
          for (          FieldDeclaration field : fields) {
            List<VariableDeclarationFragment> fragments=field.fragments();
            for (            VariableDeclarationFragment fragment : fragments) {
              IVariableBinding fragmentVariableBinding=fragment.resolveBinding();
              if (fragmentVariableBinding.isEqualTo(switchStatementExpressionNameVariableBinding)) {
                typeCheckElimination.setTypeField(fragment);
                for (                MethodDeclaration method : methods) {
                  SimpleName fieldInstruction=MethodDeclarationUtility.isSetter(method);
                  if (fieldInstruction != null && fragment.getName().getIdentifier().equals(fieldInstruction.getIdentifier())) {
                    typeCheckElimination.setTypeFieldSetterMethod(method);
                  }
                  fieldInstruction=MethodDeclarationUtility.isGetter(method);
                  if (fieldInstruction != null && fragment.getName().getIdentifier().equals(fieldInstruction.getIdentifier())) {
                    typeCheckElimination.setTypeFieldGetterMethod(method);
                  }
                }
                break;
              }
            }
          }
        }
 else {
          typeCheckElimination.setTypeLocalVariable(switchStatementExpressionName);
        }
      }
    }
  }
  Set<Expression> typeCheckExpressions=typeCheckElimination.getTypeCheckExpressions();
  for (  Expression typeCheckExpression : typeCheckExpressions) {
    if (typeCheckExpression.getParent() instanceof SwitchCase) {
      if (typeCheckExpression instanceof SimpleName) {
        SimpleName simpleName=(SimpleName)typeCheckExpression;
        IBinding binding=simpleName.resolveBinding();
        if (binding.getKind() == IBinding.VARIABLE) {
          IVariableBinding variableBinding=(IVariableBinding)binding;
          if (variableBinding.isField() && (variableBinding.getModifiers() & Modifier.STATIC) != 0) {
            typeCheckElimination.addStaticType(typeCheckExpression,simpleName);
          }
        }
      }
 else       if (typeCheckExpression instanceof QualifiedName) {
        QualifiedName qualifiedName=(QualifiedName)typeCheckExpression;
        IBinding binding=qualifiedName.resolveBinding();
        if (binding.getKind() == IBinding.VARIABLE) {
          IVariableBinding variableBinding=(IVariableBinding)binding;
          if (variableBinding.isField() && (variableBinding.getModifiers() & Modifier.STATIC) != 0) {
            typeCheckElimination.addStaticType(typeCheckExpression,qualifiedName.getName());
          }
        }
      }
 else       if (typeCheckExpression instanceof FieldAccess) {
        FieldAccess fieldAccess=(FieldAccess)typeCheckExpression;
        IVariableBinding variableBinding=fieldAccess.resolveFieldBinding();
        if (variableBinding.isField() && (variableBinding.getModifiers() & Modifier.STATIC) != 0) {
          typeCheckElimination.addStaticType(typeCheckExpression,fieldAccess.getName());
        }
      }
    }
 else     if (typeCheckExpression instanceof InstanceofExpression) {
      InstanceofExpression instanceofExpression=(InstanceofExpression)typeCheckExpression;
      SimpleName operandName=extractOperandName(instanceofExpression.getLeftOperand());
      if (operandName != null) {
        SimpleName keySimpleName=containsKey(operandName);
        if (keySimpleName != null) {
          typeVariableCounterMap.put(keySimpleName,typeVariableCounterMap.get(keySimpleName) + 1);
        }
 else {
          typeVariableCounterMap.put(operandName,1);
        }
        typeCheckElimination.addSubclassType(typeCheckExpression,instanceofExpression.getRightOperand());
      }
    }
 else     if (typeCheckExpression instanceof InfixExpression) {
      InfixExpression infixExpression=(InfixExpression)typeCheckExpression;
      IfStatementExpressionAnalyzer analyzer=new IfStatementExpressionAnalyzer(infixExpression);
      for (      InfixExpression leafInfixExpression : analyzer.getInfixExpressionsWithEqualsOperator()) {
        Expression leftOperand=leafInfixExpression.getLeftOperand();
        Expression rightOperand=leafInfixExpression.getRightOperand();
        SimpleName leftOperandName=extractOperandName(leftOperand);
        SimpleName rightOperandName=extractOperandName(rightOperand);
        SimpleName typeVariableName=null;
        SimpleName staticFieldName=null;
        if (leftOperandName != null && rightOperandName != null) {
          IBinding leftOperandNameBinding=leftOperandName.resolveBinding();
          if (leftOperandNameBinding.getKind() == IBinding.VARIABLE) {
            IVariableBinding leftOperandNameVariableBinding=(IVariableBinding)leftOperandNameBinding;
            if (leftOperandNameVariableBinding.isField() && (leftOperandNameVariableBinding.getModifiers() & Modifier.STATIC) != 0)             staticFieldName=leftOperandName;
          }
          IBinding rightOperandNameBinding=rightOperandName.resolveBinding();
          if (rightOperandNameBinding.getKind() == IBinding.VARIABLE) {
            IVariableBinding rightOperandNameVariableBinding=(IVariableBinding)rightOperandNameBinding;
            if (rightOperandNameVariableBinding.isField() && (rightOperandNameVariableBinding.getModifiers() & Modifier.STATIC) != 0)             staticFieldName=rightOperandName;
          }
          if (staticFieldName != null && staticFieldName.equals(leftOperandName))           typeVariableName=rightOperandName;
 else           if (staticFieldName != null && staticFieldName.equals(rightOperandName))           typeVariableName=leftOperandName;
        }
        if (typeVariableName != null && staticFieldName != null) {
          SimpleName keySimpleName=containsKey(typeVariableName);
          if (keySimpleName != null) {
            typeVariableCounterMap.put(keySimpleName,typeVariableCounterMap.get(keySimpleName) + 1);
          }
 else {
            typeVariableCounterMap.put(typeVariableName,1);
          }
          if (analyzer.allParentNodesAreConditionalAndOperators()) {
            analyzer.putTypeVariableExpression(typeVariableName,leafInfixExpression);
            analyzer.putTypeVariableStaticField(typeVariableName,staticFieldName);
          }
        }
      }
      for (      InstanceofExpression leafInstanceofExpression : analyzer.getInstanceofExpressions()) {
        SimpleName operandName=extractOperandName(leafInstanceofExpression.getLeftOperand());
        if (operandName != null) {
          SimpleName keySimpleName=containsKey(operandName);
          if (keySimpleName != null) {
            typeVariableCounterMap.put(keySimpleName,typeVariableCounterMap.get(keySimpleName) + 1);
          }
 else {
            typeVariableCounterMap.put(operandName,1);
          }
          if (analyzer.allParentNodesAreConditionalAndOperators()) {
            analyzer.putTypeVariableExpression(operandName,leafInstanceofExpression);
            analyzer.putTypeVariableSubclass(operandName,leafInstanceofExpression.getRightOperand());
          }
        }
      }
      complexExpressionMap.put(typeCheckExpression,analyzer);
    }
  }
  for (  SimpleName typeVariable : typeVariableCounterMap.keySet()) {
    if (typeVariableCounterMap.get(typeVariable) == typeCheckExpressions.size()) {
      for (      Expression complexExpression : complexExpressionMap.keySet()) {
        IfStatementExpressionAnalyzer analyzer=complexExpressionMap.get(complexExpression);
        for (        SimpleName analyzerTypeVariable : analyzer.getTargetVariables()) {
          if (analyzerTypeVariable.resolveBinding().isEqualTo(typeVariable.resolveBinding())) {
            typeCheckElimination.addRemainingIfStatementExpression(analyzer.getCompleteExpression(),analyzer.getRemainingExpression(analyzer.getTypeVariableExpression(analyzerTypeVariable)));
            SimpleName staticField=analyzer.getTypeVariableStaticField(analyzerTypeVariable);
            if (staticField != null)             typeCheckElimination.addStaticType(analyzer.getCompleteExpression(),staticField);
            Type subclassType=analyzer.getTypeVariableSubclass(analyzerTypeVariable);
            if (subclassType != null)             typeCheckElimination.addSubclassType(analyzer.getCompleteExpression(),subclassType);
          }
        }
      }
      IBinding binding=typeVariable.resolveBinding();
      if (binding.getKind() == IBinding.VARIABLE) {
        IVariableBinding variableBinding=(IVariableBinding)binding;
        for (        InheritanceTree tree : inheritanceTreeList) {
          DefaultMutableTreeNode root=tree.getRootNode();
          String rootClassName=(String)root.getUserObject();
          ITypeBinding variableTypeBinding=variableBinding.getType();
          if (rootClassName.equals(variableTypeBinding.getQualifiedName())) {
            typeCheckElimination.setExistingInheritanceTree(tree);
            break;
          }
        }
        if (variableBinding.isField()) {
          for (          FieldDeclaration field : fields) {
            List<VariableDeclarationFragment> fragments=field.fragments();
            for (            VariableDeclarationFragment fragment : fragments) {
              IVariableBinding fragmentVariableBinding=fragment.resolveBinding();
              if (fragmentVariableBinding.isEqualTo(variableBinding)) {
                typeCheckElimination.setTypeField(fragment);
                for (                MethodDeclaration method : methods) {
                  SimpleName fieldInstruction=MethodDeclarationUtility.isSetter(method);
                  if (fieldInstruction != null && fragment.getName().getIdentifier().equals(fieldInstruction.getIdentifier())) {
                    typeCheckElimination.setTypeFieldSetterMethod(method);
                  }
                  fieldInstruction=MethodDeclarationUtility.isGetter(method);
                  if (fieldInstruction != null && fragment.getName().getIdentifier().equals(fieldInstruction.getIdentifier())) {
                    typeCheckElimination.setTypeFieldGetterMethod(method);
                  }
                }
                break;
              }
            }
          }
        }
 else {
          typeCheckElimination.setTypeLocalVariable(typeVariable);
        }
      }
    }
  }
}