Program: 12082
Project: 12082
Buggy source:
private int getAction(CompositeStatementObject parentComposite,int i,CompositeStatementObject childComposite){
  int action=PUSH_NEW_LIST;
  List<AbstractStatement> statements=new ArrayList<AbstractStatement>(parentComposite.getStatements());
  CompositeStatementObject parent=(CompositeStatementObject)statements.get(0).getParent();
  boolean isBlockWithoutCompositeParent=isBlockWithoutCompositeParent(parent);
  if (parent.getStatement() instanceof Block)   parent=(CompositeStatementObject)parent.getParent();
  int position=i;
  while (parent != null && parent instanceof TryStatementObject) {
    CompositeStatementObject tryStatement=parent;
    CompositeStatementObject tryStatementParent=(CompositeStatementObject)tryStatement.getParent();
    List<AbstractStatement> tryParentStatements=new ArrayList<AbstractStatement>(tryStatementParent.getStatements());
    if (tryStatementParent.getStatement() instanceof Block)     tryStatementParent=(CompositeStatementObject)tryStatementParent.getParent();
    int positionOfTryStatementInParent=0;
    int j=0;
    for (    AbstractStatement statement : tryParentStatements) {
      if (statement.equals(tryStatement)) {
        positionOfTryStatementInParent=j;
        break;
      }
      j++;
    }
    if (((TryStatementObject)tryStatement).hasResources()) {
      tryParentStatements.addAll(positionOfTryStatementInParent + 1,statements);
    }
 else {
      tryParentStatements.remove(tryStatement);
      tryParentStatements.addAll(positionOfTryStatementInParent,statements);
    }
    statements=tryParentStatements;
    parent=tryStatementParent;
    if (((TryStatementObject)tryStatement).hasResources())     position=positionOfTryStatementInParent + position + 1;
 else     position=positionOfTryStatementInParent + position;
  }
  if (parent != null && parent.getStatement() instanceof SwitchStatement && parentComposite.getStatement() instanceof Block) {
    List<AbstractStatement> switchStatements=new ArrayList<AbstractStatement>(parent.getStatements());
    int positionOfBlockInParentSwitch=0;
    int j=0;
    for (    AbstractStatement statement : switchStatements) {
      if (statement.equals(parentComposite)) {
        positionOfBlockInParentSwitch=j;
        break;
      }
      j++;
    }
    switchStatements.remove(parentComposite);
    switchStatements.addAll(positionOfBlockInParentSwitch,statements);
    statements=switchStatements;
    position=positionOfBlockInParentSwitch + position;
  }
  if (parent != null && isBlockWithoutCompositeParent) {
    List<AbstractStatement> blockStatements=new ArrayList<AbstractStatement>(parent.getStatements());
    int positionOfBlockInParent=0;
    int j=0;
    for (    AbstractStatement statement : blockStatements) {
      if (statement.equals(parentComposite)) {
        positionOfBlockInParent=j;
        break;
      }
      j++;
    }
    blockStatements.remove(parentComposite);
    blockStatements.addAll(positionOfBlockInParent,statements);
    statements=blockStatements;
    position=positionOfBlockInParent + position;
  }
  if (statements.size() == 1) {
    action=JOIN_TOP_LIST;
    if (parent != null) {
      if (isLoop(parent) || parent.getStatement() instanceof DoStatement)       action=PUSH_NEW_LIST;
    }
  }
 else   if (statements.size() > 1) {
    AbstractStatement previousStatement=null;
    if (position >= 1)     previousStatement=statements.get(position - 1);
    int j=0;
    while (previousStatement != null && previousStatement instanceof TryStatementObject && !((TryStatementObject)previousStatement).hasResources()) {
      CompositeStatementObject tryStatement=(CompositeStatementObject)previousStatement;
      AbstractStatement firstStatement=tryStatement.getStatements().get(0);
      if (firstStatement instanceof CompositeStatementObject) {
        CompositeStatementObject tryBlock=(CompositeStatementObject)firstStatement;
        List<AbstractStatement> tryBlockStatements=tryBlock.getStatements();
        if (tryBlockStatements.size() > 0) {
          previousStatement=tryBlockStatements.get(tryBlockStatements.size() - 1);
        }
 else {
          if (position >= 2 + j)           previousStatement=statements.get(position - 2 - j);
 else           previousStatement=null;
        }
      }
      j++;
    }
    while (previousStatement != null && isBlockWithoutCompositeParent(previousStatement)) {
      CompositeStatementObject block=(CompositeStatementObject)previousStatement;
      List<AbstractStatement> blockStatements=block.getStatements();
      if (blockStatements.size() > 0) {
        previousStatement=blockStatements.get(blockStatements.size() - 1);
      }
    }
    if (statements.get(statements.size() - 1).equals(childComposite)) {
      if (previousStatement != null && (previousStatement.getStatement() instanceof IfStatement || previousStatement.getStatement() instanceof SwitchStatement)) {
        action=JOIN_SECOND_FROM_TOP_LIST;
        if (parent != null && (isLoop(parent) || parent.getStatement() instanceof DoStatement))         action=PLACE_NEW_LIST_SECOND_FROM_TOP;
      }
 else {
        action=JOIN_TOP_LIST;
        if (parent != null && (isLoop(parent) || parent.getStatement() instanceof DoStatement))         action=PUSH_NEW_LIST;
      }
    }
 else {
      if (previousStatement != null && (previousStatement.getStatement() instanceof IfStatement || previousStatement.getStatement() instanceof SwitchStatement))       action=PLACE_NEW_LIST_SECOND_FROM_TOP;
 else {
        action=PUSH_NEW_LIST;
      }
    }
  }
  return action;
}

Fixed version (ground truth):
private int getAction(CompositeStatementObject parentComposite,int i,CompositeStatementObject childComposite){
  int action=PUSH_NEW_LIST;
  List<AbstractStatement> statements=new ArrayList<AbstractStatement>(parentComposite.getStatements());
  CompositeStatementObject parent=(CompositeStatementObject)statements.get(0).getParent();
  boolean isBlockWithoutCompositeParent=isBlockWithoutCompositeParent(parent);
  if (parent.getStatement() instanceof Block)   parent=(CompositeStatementObject)parent.getParent();
  int position=i;
  while (parent != null && (parent instanceof TryStatementObject || parent instanceof SynchronizedStatementObject)) {
    CompositeStatementObject tryStatement=parent;
    CompositeStatementObject tryStatementParent=(CompositeStatementObject)tryStatement.getParent();
    List<AbstractStatement> tryParentStatements=new ArrayList<AbstractStatement>(tryStatementParent.getStatements());
    if (tryStatementParent.getStatement() instanceof Block)     tryStatementParent=(CompositeStatementObject)tryStatementParent.getParent();
    int positionOfTryStatementInParent=0;
    int j=0;
    for (    AbstractStatement statement : tryParentStatements) {
      if (statement.equals(tryStatement)) {
        positionOfTryStatementInParent=j;
        break;
      }
      j++;
    }
    if (tryStatement instanceof TryStatementObject) {
      TryStatementObject tempTry=(TryStatementObject)tryStatement;
      if (tempTry.hasResources()) {
        tryParentStatements.addAll(positionOfTryStatementInParent + 1,statements);
      }
 else {
        tryParentStatements.remove(tryStatement);
        tryParentStatements.addAll(positionOfTryStatementInParent,statements);
      }
    }
 else {
      tryParentStatements.addAll(positionOfTryStatementInParent + 1,statements);
    }
    statements=tryParentStatements;
    parent=tryStatementParent;
    if (tryStatement instanceof TryStatementObject) {
      TryStatementObject tempTry=(TryStatementObject)tryStatement;
      if (tempTry.hasResources())       position=positionOfTryStatementInParent + position + 1;
 else       position=positionOfTryStatementInParent + position;
    }
 else {
      position=positionOfTryStatementInParent + position + 1;
    }
  }
  if (parent != null && parent.getStatement() instanceof SwitchStatement && parentComposite.getStatement() instanceof Block) {
    List<AbstractStatement> switchStatements=new ArrayList<AbstractStatement>(parent.getStatements());
    int positionOfBlockInParentSwitch=0;
    int j=0;
    for (    AbstractStatement statement : switchStatements) {
      if (statement.equals(parentComposite)) {
        positionOfBlockInParentSwitch=j;
        break;
      }
      j++;
    }
    switchStatements.remove(parentComposite);
    switchStatements.addAll(positionOfBlockInParentSwitch,statements);
    statements=switchStatements;
    position=positionOfBlockInParentSwitch + position;
  }
  if (parent != null && isBlockWithoutCompositeParent) {
    List<AbstractStatement> blockStatements=new ArrayList<AbstractStatement>(parent.getStatements());
    int positionOfBlockInParent=0;
    int j=0;
    for (    AbstractStatement statement : blockStatements) {
      if (statement.equals(parentComposite)) {
        positionOfBlockInParent=j;
        break;
      }
      j++;
    }
    blockStatements.remove(parentComposite);
    blockStatements.addAll(positionOfBlockInParent,statements);
    statements=blockStatements;
    position=positionOfBlockInParent + position;
  }
  if (statements.size() == 1) {
    action=JOIN_TOP_LIST;
    if (parent != null) {
      if (isLoop(parent) || parent.getStatement() instanceof DoStatement)       action=PUSH_NEW_LIST;
    }
  }
 else   if (statements.size() > 1) {
    AbstractStatement previousStatement=null;
    if (position >= 1)     previousStatement=statements.get(position - 1);
    int j=0;
    while (previousStatement != null && previousStatement instanceof TryStatementObject && !((TryStatementObject)previousStatement).hasResources()) {
      CompositeStatementObject tryStatement=(CompositeStatementObject)previousStatement;
      AbstractStatement firstStatement=tryStatement.getStatements().get(0);
      if (firstStatement instanceof CompositeStatementObject) {
        CompositeStatementObject tryBlock=(CompositeStatementObject)firstStatement;
        List<AbstractStatement> tryBlockStatements=tryBlock.getStatements();
        if (tryBlockStatements.size() > 0) {
          previousStatement=tryBlockStatements.get(tryBlockStatements.size() - 1);
        }
 else {
          if (position >= 2 + j)           previousStatement=statements.get(position - 2 - j);
 else           previousStatement=null;
        }
      }
      j++;
    }
    while (previousStatement != null && isBlockWithoutCompositeParent(previousStatement)) {
      CompositeStatementObject block=(CompositeStatementObject)previousStatement;
      List<AbstractStatement> blockStatements=block.getStatements();
      if (blockStatements.size() > 0) {
        previousStatement=blockStatements.get(blockStatements.size() - 1);
      }
    }
    if (statements.get(statements.size() - 1).equals(childComposite)) {
      if (previousStatement != null && (previousStatement.getStatement() instanceof IfStatement || previousStatement.getStatement() instanceof SwitchStatement)) {
        action=JOIN_SECOND_FROM_TOP_LIST;
        if (parent != null && (isLoop(parent) || parent.getStatement() instanceof DoStatement))         action=PLACE_NEW_LIST_SECOND_FROM_TOP;
      }
 else {
        action=JOIN_TOP_LIST;
        if (parent != null && (isLoop(parent) || parent.getStatement() instanceof DoStatement))         action=PUSH_NEW_LIST;
      }
    }
 else {
      if (previousStatement != null && (previousStatement.getStatement() instanceof IfStatement || previousStatement.getStatement() instanceof SwitchStatement))       action=PLACE_NEW_LIST_SECOND_FROM_TOP;
 else {
        action=PUSH_NEW_LIST;
      }
    }
  }
  return action;
}