Program: 12248
Project: 12248
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=null;
    if (switchStatementExpression instanceof SimpleName) {
      SimpleName simpleName=(SimpleName)switchStatementExpression;
      switchStatementExpressionName=simpleName;
    }
 else     if (switchStatementExpression instanceof FieldAccess) {
      FieldAccess fieldAccess=(FieldAccess)switchStatementExpression;
      switchStatementExpressionName=fieldAccess.getName();
    }
 else     if (switchStatementExpression instanceof MethodInvocation) {
      MethodInvocation methodInvocation=(MethodInvocation)switchStatementExpression;
      for (      MethodDeclaration method : methods) {
        SimpleName fieldInstruction=MethodDeclarationUtility.isGetter(method);
        if (fieldInstruction != null && method.resolveBinding().isEqualTo(methodInvocation.resolveMethodBinding()))         switchStatementExpressionName=fieldInstruction;
      }
      if (switchStatementExpressionName == null) {
        IMethodBinding methodInvocationBinding=methodInvocation.resolveMethodBinding();
        if ((methodInvocationBinding.getModifiers() & Modifier.ABSTRACT) != 0) {
          for (          InheritanceTree tree : inheritanceTreeList) {
            DefaultMutableTreeNode root=tree.getRootNode();
            String rootClassName=(String)root.getUserObject();
            ITypeBinding declaringClassTypeBinding=methodInvocationBinding.getDeclaringClass();
            if (rootClassName.equals(declaringClassTypeBinding.getQualifiedName())) {
              typeCheckElimination.setTypeMethodInvocation(methodInvocation);
              typeCheckElimination.setExistingInheritanceTree(tree);
              break;
            }
          }
        }
      }
    }
    IBinding switchStatementExpressionNameBinding=switchStatementExpressionName.resolveBinding();
    IVariableBinding switchStatementExpressionNameVariableBinding=null;
    if (switchStatementExpressionNameBinding.getKind() == IBinding.VARIABLE)     switchStatementExpressionNameVariableBinding=(IVariableBinding)switchStatementExpressionNameBinding;
    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;
        }
      }
    }
  }
  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 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 (  VariableDeclarationFragment fragment : fieldTypeCounterMap.keySet()) {
    if (fieldTypeCounterMap.get(fragment) == typeCheckExpressions.size()) {
      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);
        }
      }
    }
  }
  for (  MethodInvocation methodInvocation : typeMethodInvocationCounterMap.keySet()) {
    if (typeMethodInvocationCounterMap.get(methodInvocation) == typeCheckExpressions.size()) {
      typeCheckElimination.setTypeMethodInvocation(methodInvocation);
      IMethodBinding methodInvocationBinding=methodInvocation.resolveMethodBinding();
      for (      InheritanceTree tree : inheritanceTreeList) {
        DefaultMutableTreeNode root=tree.getRootNode();
        String rootClassName=(String)root.getUserObject();
        ITypeBinding declaringClassTypeBinding=methodInvocationBinding.getDeclaringClass();
        if (rootClassName.equals(declaringClassTypeBinding.getQualifiedName())) {
          typeCheckElimination.setExistingInheritanceTree(tree);
          break;
        }
      }
    }
  }
}

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=null;
    if (switchStatementExpression instanceof SimpleName) {
      SimpleName simpleName=(SimpleName)switchStatementExpression;
      switchStatementExpressionName=simpleName;
    }
 else     if (switchStatementExpression instanceof QualifiedName) {
      QualifiedName qualifiedName=(QualifiedName)switchStatementExpression;
      switchStatementExpressionName=qualifiedName.getName();
    }
 else     if (switchStatementExpression instanceof FieldAccess) {
      FieldAccess fieldAccess=(FieldAccess)switchStatementExpression;
      switchStatementExpressionName=fieldAccess.getName();
    }
 else     if (switchStatementExpression instanceof MethodInvocation) {
      MethodInvocation methodInvocation=(MethodInvocation)switchStatementExpression;
      for (      MethodDeclaration method : methods) {
        SimpleName fieldInstruction=MethodDeclarationUtility.isGetter(method);
        if (fieldInstruction != null && method.resolveBinding().isEqualTo(methodInvocation.resolveMethodBinding()))         switchStatementExpressionName=fieldInstruction;
      }
      if (switchStatementExpressionName == null) {
        IMethodBinding methodInvocationBinding=methodInvocation.resolveMethodBinding();
        if ((methodInvocationBinding.getModifiers() & Modifier.ABSTRACT) != 0) {
          for (          InheritanceTree tree : inheritanceTreeList) {
            DefaultMutableTreeNode root=tree.getRootNode();
            String rootClassName=(String)root.getUserObject();
            ITypeBinding declaringClassTypeBinding=methodInvocationBinding.getDeclaringClass();
            if (rootClassName.equals(declaringClassTypeBinding.getQualifiedName())) {
              typeCheckElimination.setTypeMethodInvocation(methodInvocation);
              typeCheckElimination.setExistingInheritanceTree(tree);
              break;
            }
          }
        }
      }
    }
    if (switchStatementExpressionName != null) {
      IBinding switchStatementExpressionNameBinding=switchStatementExpressionName.resolveBinding();
      if (switchStatementExpressionNameBinding.getKind() == IBinding.VARIABLE) {
        IVariableBinding switchStatementExpressionNameVariableBinding=(IVariableBinding)switchStatementExpressionNameBinding;
        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;
            }
          }
        }
      }
    }
  }
  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 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 (  VariableDeclarationFragment fragment : fieldTypeCounterMap.keySet()) {
    if (fieldTypeCounterMap.get(fragment) == typeCheckExpressions.size()) {
      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);
        }
      }
    }
  }
  for (  MethodInvocation methodInvocation : typeMethodInvocationCounterMap.keySet()) {
    if (typeMethodInvocationCounterMap.get(methodInvocation) == typeCheckExpressions.size()) {
      typeCheckElimination.setTypeMethodInvocation(methodInvocation);
      IMethodBinding methodInvocationBinding=methodInvocation.resolveMethodBinding();
      for (      InheritanceTree tree : inheritanceTreeList) {
        DefaultMutableTreeNode root=tree.getRootNode();
        String rootClassName=(String)root.getUserObject();
        ITypeBinding declaringClassTypeBinding=methodInvocationBinding.getDeclaringClass();
        if (rootClassName.equals(declaringClassTypeBinding.getQualifiedName())) {
          typeCheckElimination.setExistingInheritanceTree(tree);
          break;
        }
      }
    }
  }
}