Program: 12241
Project: 12241
Buggy source:
private void modifyTypeFieldAssignmentsInContextClass(){
  AST contextAST=sourceTypeDeclaration.getAST();
  MethodDeclaration[] contextMethods=sourceTypeDeclaration.getMethods();
  List<String> staticFieldNames=typeCheckElimination.getStaticFieldNames();
  for (  MethodDeclaration methodDeclaration : contextMethods) {
    Block methodBody=methodDeclaration.getBody();
    if (methodBody != null) {
      List<Statement> statements=methodBody.statements();
      ExpressionExtractor expressionExtractor=new ExpressionExtractor();
      for (      Statement statement : statements) {
        List<Expression> assignments=expressionExtractor.getAssignments(statement);
        for (        Expression expression : assignments) {
          Assignment assignment=(Assignment)expression;
          Expression leftHandSide=assignment.getLeftHandSide();
          SimpleName assignedVariable=null;
          Expression invoker=null;
          if (leftHandSide instanceof SimpleName) {
            assignedVariable=(SimpleName)leftHandSide;
          }
 else           if (leftHandSide instanceof QualifiedName) {
            QualifiedName qualifiedName=(QualifiedName)leftHandSide;
            assignedVariable=qualifiedName.getName();
            invoker=qualifiedName.getQualifier();
          }
 else           if (leftHandSide instanceof FieldAccess) {
            FieldAccess fieldAccess=(FieldAccess)leftHandSide;
            assignedVariable=fieldAccess.getName();
            invoker=fieldAccess.getExpression();
          }
          IBinding leftHandBinding=assignedVariable.resolveBinding();
          if (leftHandBinding.getKind() == IBinding.VARIABLE) {
            IVariableBinding assignedVariableBinding=(IVariableBinding)leftHandBinding;
            if (assignedVariableBinding.isField() && typeCheckElimination.getTypeField().getName().getIdentifier().equals(assignedVariable.getIdentifier())) {
              MethodInvocation setterMethodInvocation=contextAST.newMethodInvocation();
              if (typeCheckElimination.getTypeFieldSetterMethod() != null) {
                sourceRewriter.set(setterMethodInvocation,MethodInvocation.NAME_PROPERTY,typeCheckElimination.getTypeFieldSetterMethod().getName(),null);
              }
 else {
                sourceRewriter.set(setterMethodInvocation,MethodInvocation.NAME_PROPERTY,contextAST.newSimpleName("String_Node_Str" + typeCheckElimination.getAbstractClassName()),null);
              }
              ListRewrite setterMethodInvocationArgumentsRewrite=sourceRewriter.getListRewrite(setterMethodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
              setterMethodInvocationArgumentsRewrite.insertLast(assignment.getRightHandSide(),null);
              if (invoker != null) {
                sourceRewriter.set(setterMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,invoker,null);
              }
              sourceRewriter.replace(assignment,setterMethodInvocation,null);
              Expression rightHandSide=assignment.getRightHandSide();
              SimpleName staticVariable=decomposeRightHandSide(rightHandSide);
              if (staticVariable != null) {
                IBinding rightHandBinding=staticVariable.resolveBinding();
                if (leftHandBinding.getKind() == IBinding.VARIABLE) {
                  IVariableBinding staticVariableBinding=(IVariableBinding)rightHandBinding;
                  if (staticVariableBinding.isField() && (staticVariableBinding.getModifiers() & Modifier.STATIC) != 0 && !staticFieldNames.contains(staticVariable.getIdentifier())) {
                    String subclassName="String_Node_Str";
                    StringTokenizer tokenizer=new StringTokenizer(staticVariable.getIdentifier(),"String_Node_Str");
                    while (tokenizer.hasMoreTokens()) {
                      String tempName=tokenizer.nextToken().toLowerCase().toString();
                      subclassName+=tempName.subSequence(0,1).toString().toUpperCase() + tempName.subSequence(1,tempName.length()).toString();
                    }
                    additionalStaticFields.put(staticVariable.getIdentifier(),subclassName);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void modifyTypeFieldAssignmentsInContextClass(){
  AST contextAST=sourceTypeDeclaration.getAST();
  MethodDeclaration[] contextMethods=sourceTypeDeclaration.getMethods();
  List<String> staticFieldNames=typeCheckElimination.getStaticFieldNames();
  for (  MethodDeclaration methodDeclaration : contextMethods) {
    Block methodBody=methodDeclaration.getBody();
    if (methodBody != null) {
      List<Statement> statements=methodBody.statements();
      ExpressionExtractor expressionExtractor=new ExpressionExtractor();
      for (      Statement statement : statements) {
        List<Expression> assignments=expressionExtractor.getAssignments(statement);
        for (        Expression expression : assignments) {
          Assignment assignment=(Assignment)expression;
          Expression leftHandSide=assignment.getLeftHandSide();
          SimpleName assignedVariable=null;
          Expression invoker=null;
          if (leftHandSide instanceof SimpleName) {
            assignedVariable=(SimpleName)leftHandSide;
          }
 else           if (leftHandSide instanceof QualifiedName) {
            QualifiedName qualifiedName=(QualifiedName)leftHandSide;
            assignedVariable=qualifiedName.getName();
            invoker=qualifiedName.getQualifier();
          }
 else           if (leftHandSide instanceof FieldAccess) {
            FieldAccess fieldAccess=(FieldAccess)leftHandSide;
            assignedVariable=fieldAccess.getName();
            invoker=fieldAccess.getExpression();
          }
          if (assignedVariable != null) {
            IBinding leftHandBinding=assignedVariable.resolveBinding();
            if (leftHandBinding.getKind() == IBinding.VARIABLE) {
              IVariableBinding assignedVariableBinding=(IVariableBinding)leftHandBinding;
              if (assignedVariableBinding.isField() && typeCheckElimination.getTypeField().getName().getIdentifier().equals(assignedVariable.getIdentifier())) {
                MethodInvocation setterMethodInvocation=contextAST.newMethodInvocation();
                if (typeCheckElimination.getTypeFieldSetterMethod() != null) {
                  sourceRewriter.set(setterMethodInvocation,MethodInvocation.NAME_PROPERTY,typeCheckElimination.getTypeFieldSetterMethod().getName(),null);
                }
 else {
                  sourceRewriter.set(setterMethodInvocation,MethodInvocation.NAME_PROPERTY,contextAST.newSimpleName("String_Node_Str" + typeCheckElimination.getAbstractClassName()),null);
                }
                ListRewrite setterMethodInvocationArgumentsRewrite=sourceRewriter.getListRewrite(setterMethodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
                setterMethodInvocationArgumentsRewrite.insertLast(assignment.getRightHandSide(),null);
                if (invoker != null) {
                  sourceRewriter.set(setterMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,invoker,null);
                }
                sourceRewriter.replace(assignment,setterMethodInvocation,null);
                Expression rightHandSide=assignment.getRightHandSide();
                SimpleName staticVariable=decomposeRightHandSide(rightHandSide);
                if (staticVariable != null) {
                  IBinding rightHandBinding=staticVariable.resolveBinding();
                  if (leftHandBinding.getKind() == IBinding.VARIABLE) {
                    IVariableBinding staticVariableBinding=(IVariableBinding)rightHandBinding;
                    if (staticVariableBinding.isField() && (staticVariableBinding.getModifiers() & Modifier.STATIC) != 0 && !staticFieldNames.contains(staticVariable.getIdentifier())) {
                      String subclassName="String_Node_Str";
                      StringTokenizer tokenizer=new StringTokenizer(staticVariable.getIdentifier(),"String_Node_Str");
                      while (tokenizer.hasMoreTokens()) {
                        String tempName=tokenizer.nextToken().toLowerCase().toString();
                        subclassName+=tempName.subSequence(0,1).toString().toUpperCase() + tempName.subSequence(1,tempName.length()).toString();
                      }
                      additionalStaticFields.put(staticVariable.getIdentifier(),subclassName);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}