Program: 81601
Project: 81601
Buggy source:
public String toJavaCode(TypeSymbol currentType){
  String code="String_Node_Str";
  boolean isParentMessageSend=false;
  boolean currentValueIsToken=false;
  if (literal != null) {
    if (literal.value.equals("String_Node_Str")) {
      code+="String_Node_Str";
      if (modifications.size() == 0 || (modifications.size() > 0 && modifications.get(0) instanceof CMessageSend)) {
        if (SymbolTable.is_mobile_actor) {
          code+="String_Node_Str";
        }
      }
    }
 else     if (literal.value.equals("String_Node_Str")) {
      if (modifications.size() > 0 && modifications.get(0) instanceof CMessageSend) {
        code+="String_Node_Str";
        if (SymbolTable.is_mobile_actor) {
          code+="String_Node_Str";
        }
        isParentMessageSend=true;
      }
 else {
        code+="String_Node_Str";
      }
    }
 else     if (literal.value.equals("String_Node_Str")) {
      code+="String_Node_Str";
    }
 else {
      code+=literal.toJavaCode();
    }
  }
 else   if (variable_name != null) {
    code+=variable_name;
    try {
      currentValueIsToken=SymbolTable.isToken(variable_name.name);
    }
 catch (    SalsaNotFoundException snfe) {
      CompilerErrors.printErrorMessage("String_Node_Str",variable_name);
      currentValueIsToken=false;
    }
  }
 else   if (expression != null) {
    code+="String_Node_Str" + expression.toJavaCode() + "String_Node_Str";
    currentValueIsToken=expression.isToken();
  }
 else   if (allocation != null) {
    code+=allocation.toJavaCode();
    currentValueIsToken=allocation.isToken();
  }
  if (cast_type != null) {
    if (isToken()) {
      if (cast_type.is_token) {
        code="String_Node_Str" + code;
      }
 else {
        CompilerErrors.printErrorMessage("String_Node_Str",cast_type);
      }
    }
 else {
      if (cast_type.is_token) {
        CompilerErrors.printErrorMessage("String_Node_Str",cast_type);
      }
 else {
        code="String_Node_Str" + cast_type.name + "String_Node_Str"+ code;
      }
    }
  }
  if (currentType == null)   currentType=getValueType();
  int position=0;
  for (  CModification modification : modifications) {
    if (modification instanceof CArrayAccess) {
      CArrayAccess aa=(CArrayAccess)modification;
      if (aa.expression.isToken()) {
        System.err.println("String_Node_Str");
        CompilerErrors.printErrorMessage("String_Node_Str",aa);
        currentType=null;
      }
 else {
        code+="String_Node_Str" + aa.expression.toJavaCode() + "String_Node_Str";
        if (currentType == null) {
          System.err.println("String_Node_Str");
          throw new RuntimeException();
        }
        currentType=((ArrayType)currentType).getSubtype();
      }
      if (aa.expression.isToken())       currentValueIsToken=true;
    }
 else     if (modification instanceof CFieldAccess) {
      CFieldAccess fa=(CFieldAccess)modification;
      if (currentType instanceof ObjectType) {
        code+="String_Node_Str" + fa.name;
        currentType=((ObjectType)currentType).getFieldType(fa.name);
      }
 else       if (currentType instanceof ActorType) {
        code+="String_Node_Str" + fa.name;
        currentType=((ActorType)currentType).getFieldType(fa.name);
      }
 else       if (currentType instanceof ArrayType) {
        code+="String_Node_Str" + fa.name;
        currentType=((ArrayType)currentType).getFieldType(fa.name);
      }
 else       if (currentType instanceof PrimitiveType) {
        CompilerErrors.printErrorMessage("String_Node_Str",fa);
        currentType=null;
      }
 else {
        CompilerErrors.printErrorMessage("String_Node_Str",fa);
        currentType=null;
      }
    }
 else     if (modification instanceof CMethodInvocation) {
      CMethodInvocation mi=(CMethodInvocation)modification;
      try {
        if (currentType instanceof ObjectType) {
          MethodSymbol ms=((ObjectType)currentType).getMethod(mi.method_name,mi.arguments);
          if (ms == null) {
            CompilerErrors.printErrorMessage("String_Node_Str",mi);
            currentType=null;
          }
          currentType=ms.getReturnType();
        }
 else         if (currentType instanceof ActorType) {
          if (modifications.getFirst().equals(modification) && (isSelf() || isParent() || SymbolTable.isReferenceMethod((CMethodInvocation)modification))) {
            currentType=((ActorType)currentType).getMessage(mi.method_name,mi.arguments,isParentMessageSend).getPassType();
          }
 else {
            CompilerErrors.printErrorMessage("String_Node_Str",mi);
            currentType=null;
          }
        }
 else         if (currentType instanceof ArrayType) {
          CompilerErrors.printErrorMessage("String_Node_Str",mi);
          currentType=null;
        }
 else         if (currentType instanceof PrimitiveType) {
          CompilerErrors.printErrorMessage("String_Node_Str",mi);
          currentType=null;
        }
 else {
          CompilerErrors.printErrorMessage("String_Node_Str",mi);
          currentType=null;
        }
        if (currentType != null) {
          code+="String_Node_Str" + mi.method_name + "String_Node_Str";
          for (          CExpression argument : mi.arguments) {
            if (!argument.isToken()) {
              code+=argument.toJavaCode();
              if (!argument.equals(mi.arguments.lastElement()))               code+="String_Node_Str";
            }
 else {
              CompilerErrors.printErrorMessage("String_Node_Str",argument);
            }
          }
          code+="String_Node_Str";
        }
      }
 catch (      VariableDeclarationException vde) {
        CompilerErrors.printErrorMessage("String_Node_Str" + vde.toString(),mi);
        throw new RuntimeException(vde);
      }
catch (      SalsaNotFoundException snfe) {
        CompilerErrors.printErrorMessage("String_Node_Str" + snfe.toString(),mi);
        throw new RuntimeException(snfe);
      }
    }
 else     if (modification instanceof CMessageSend) {
      CMessageSend ms=(CMessageSend)modification;
      try {
        String joinDirector=SymbolTable.getJoinDirector();
        if (ms.message_property != null && !ms.message_property.name.equals("String_Node_Str")) {
          CompilerErrors.printErrorMessage("String_Node_Str" + ms.message_property.name + "String_Node_Str",ms);
        }
        boolean moreMessages=false;
        for (int new_pos=position + 1; new_pos < modifications.size(); new_pos++) {
          if (modifications.get(new_pos) instanceof CMessageSend) {
            moreMessages=true;
            break;
          }
        }
        String pre_code="String_Node_Str";
        if (SymbolTable.continuesToPass && !SymbolTable.withinArguments) {
          pre_code+="String_Node_Str";
        }
 else         if (SymbolTable.withinArguments) {
          pre_code+="String_Node_Str";
        }
 else         if (SymbolTable.continuationTokenMessage) {
          pre_code+="String_Node_Str";
        }
 else         if (SymbolTable.isExpressionContinuation) {
          pre_code+="String_Node_Str";
        }
 else         if (SymbolTable.messageContinues || joinDirector != null) {
          if (moreMessages) {
            pre_code+="String_Node_Str";
          }
 else {
            if (SymbolTable.firstContinuation()) {
              pre_code+="String_Node_Str";
              SymbolTable.initializedFirstContinuation();
            }
            pre_code+="String_Node_Str";
          }
        }
 else         if (moreMessages) {
          pre_code+="String_Node_Str";
        }
 else {
          pre_code+="String_Node_Str";
        }
        String expression_director_code="String_Node_Str";
        pre_code+="String_Node_Str";
        String target_code=code;
        if (currentType.isInterface)         target_code="String_Node_Str" + target_code;
        if (currentValueIsToken) {
          code=pre_code + "String_Node_Str";
        }
 else {
          code=pre_code + target_code + "String_Node_Str";
        }
        if (!(currentType instanceof ActorType)) {
          CompilerErrors.printErrorMessage("String_Node_Str" + currentType.getLongSignature() + "String_Node_Str",ms);
          throw new RuntimeException();
        }
        ActorType at=(ActorType)currentType;
        MessageSymbol messageSymbol=null;
        try {
          messageSymbol=at.getMessage(ms.message_name,ms.arguments,isParentMessageSend);
        }
 catch (        VariableDeclarationException vde) {
          CompilerErrors.printErrorMessage("String_Node_Str" + ms.message_name + "String_Node_Str"+ vde.toString(),ms);
          throw new RuntimeException(vde);
        }
catch (        SalsaNotFoundException snfe) {
          CompilerErrors.printErrorMessage("String_Node_Str" + ms.message_name + "String_Node_Str",ms);
          throw new RuntimeException(snfe);
        }
        code+=messageSymbol.getId();
        code+="String_Node_Str" + ms.message_name + "String_Node_Str";
        String argument_code="String_Node_Str";
        String argument_tokens="String_Node_Str";
        boolean hasContinuationToken=false;
        boolean hasToken=false;
        int j=0;
        for (        CExpression argument : ms.arguments) {
          if (argument.isToken()) {
            if (argument.requiresExpressionDirector()) {
              expression_director_code+=argument.getExpressionDirectorCode();
            }
            if (argument_tokens.length() > 10)             argument_tokens+="String_Node_Str";
            argument_tokens+=j;
            hasToken=true;
          }
 else           if (SymbolTable.isMutableObject(argument.getType())) {
            argument_code+="String_Node_Str" + argument.getType().getName() + "String_Node_Str";
          }
          SymbolTable.withinArguments=true;
          argument_code+=argument.toJavaCode();
          SymbolTable.withinArguments=false;
          if (SymbolTable.isMutableObject(argument.getType()))           argument_code+="String_Node_Str";
          if (!argument.equals(ms.arguments.lastElement()))           argument_code+="String_Node_Str";
          j++;
        }
        code=expression_director_code + code;
        if (hasToken) {
          argument_code+="String_Node_Str" + argument_tokens + "String_Node_Str";
        }
 else {
          argument_code+="String_Node_Str";
        }
        if (ms.arguments.size() == 0)         argument_code="String_Node_Str";
        code+=argument_code;
        if (ms.message_property != null && ms.message_property.name.equals("String_Node_Str")) {
          code+="String_Node_Str";
          for (int i=0; i < ms.message_property.arguments.size(); i++) {
            CExpression arg=ms.message_property.arguments.get(i);
            if (!arg.isToken()) {
              CompilerErrors.printErrorMessage("String_Node_Str",arg);
              throw new RuntimeException();
            }
            code+=arg.toJavaCode();
            if (i != ms.message_property.arguments.size() - 1)             code+="String_Node_Str";
          }
          if (SymbolTable.messageRequiresContinuation) {
            code+="String_Node_Str";
            SymbolTable.messageRequiresContinuation=false;
          }
          code+="String_Node_Str";
        }
 else         if (SymbolTable.messageRequiresContinuation) {
          code+="String_Node_Str";
          SymbolTable.messageRequiresContinuation=false;
        }
        if (SymbolTable.continuesToPass && !SymbolTable.withinArguments) {
          code+="String_Node_Str";
        }
        if (currentValueIsToken) {
          code+="String_Node_Str" + target_code;
        }
        code+="String_Node_Str";
        if (joinDirector != null && !SymbolTable.messageContinues) {
          code+="String_Node_Str";
          code+=CIndent.getIndent() + "String_Node_Str" + joinDirector+ "String_Node_Str"+ joinDirector+ "String_Node_Str";
        }
        currentType=((ActorType)currentType).getMessage(ms.message_name,ms.arguments,isParentMessageSend).getPassType();
        SymbolTable.setContinuationType(currentType);
      }
 catch (      VariableDeclarationException vde) {
        CompilerErrors.printErrorMessage("String_Node_Str" + vde.toString(),ms);
        throw new RuntimeException(vde);
      }
catch (      SalsaNotFoundException snfe) {
        CompilerErrors.printErrorMessage("String_Node_Str" + snfe.toString(),ms);
        throw new RuntimeException(snfe);
      }
      currentValueIsToken=true;
    }
    isParentMessageSend=false;
    position++;
  }
  return code;
}

Fixed version (ground truth):
public String toJavaCode(TypeSymbol currentType){
  String code="String_Node_Str";
  boolean isParentMessageSend=false;
  boolean currentValueIsToken=false;
  if (literal != null) {
    if (literal.value.equals("String_Node_Str")) {
      code+="String_Node_Str";
      if (modifications.size() == 0 || (modifications.size() > 0 && modifications.get(0) instanceof CMessageSend)) {
        if (SymbolTable.is_mobile_actor) {
          code+="String_Node_Str";
        }
      }
    }
 else     if (literal.value.equals("String_Node_Str")) {
      if (modifications.size() > 0 && modifications.get(0) instanceof CMessageSend) {
        code+="String_Node_Str";
        if (SymbolTable.is_mobile_actor) {
          code+="String_Node_Str";
        }
        isParentMessageSend=true;
      }
 else {
        code+="String_Node_Str";
      }
    }
 else     if (literal.value.equals("String_Node_Str")) {
      code+="String_Node_Str";
    }
 else {
      code+=literal.toJavaCode();
    }
  }
 else   if (variable_name != null) {
    code+=variable_name;
    try {
      currentValueIsToken=SymbolTable.isToken(variable_name.name);
    }
 catch (    SalsaNotFoundException snfe) {
      CompilerErrors.printErrorMessage("String_Node_Str",variable_name);
      currentValueIsToken=false;
    }
  }
 else   if (expression != null) {
    code+="String_Node_Str" + expression.toJavaCode() + "String_Node_Str";
    currentValueIsToken=expression.isToken();
  }
 else   if (allocation != null) {
    code+=allocation.toJavaCode();
    currentValueIsToken=allocation.isToken();
  }
  if (cast_type != null) {
    if (isToken()) {
      if (cast_type.is_token) {
        code="String_Node_Str" + code;
      }
 else {
        CompilerErrors.printErrorMessage("String_Node_Str",cast_type);
      }
    }
 else {
      if (cast_type.is_token) {
        CompilerErrors.printErrorMessage("String_Node_Str",cast_type);
      }
 else {
        code="String_Node_Str" + cast_type.name + "String_Node_Str"+ code;
      }
    }
  }
  if (currentType == null)   currentType=getValueType();
  int position=0;
  for (  CModification modification : modifications) {
    if (modification instanceof CArrayAccess) {
      CArrayAccess aa=(CArrayAccess)modification;
      if (aa.expression.isToken()) {
        System.err.println("String_Node_Str");
        CompilerErrors.printErrorMessage("String_Node_Str",aa);
        currentType=null;
      }
 else {
        code+="String_Node_Str" + aa.expression.toJavaCode() + "String_Node_Str";
        if (currentType == null) {
          System.err.println("String_Node_Str");
          throw new RuntimeException();
        }
        currentType=((ArrayType)currentType).getSubtype();
      }
      if (aa.expression.isToken())       currentValueIsToken=true;
    }
 else     if (modification instanceof CFieldAccess) {
      CFieldAccess fa=(CFieldAccess)modification;
      if (currentType instanceof ObjectType) {
        code+="String_Node_Str" + fa.name;
        currentType=((ObjectType)currentType).getFieldType(fa.name);
      }
 else       if (currentType instanceof ActorType) {
        code+="String_Node_Str" + fa.name;
        currentType=((ActorType)currentType).getFieldType(fa.name);
      }
 else       if (currentType instanceof ArrayType) {
        code+="String_Node_Str" + fa.name;
        currentType=((ArrayType)currentType).getFieldType(fa.name);
      }
 else       if (currentType instanceof PrimitiveType) {
        CompilerErrors.printErrorMessage("String_Node_Str",fa);
        currentType=null;
      }
 else {
        CompilerErrors.printErrorMessage("String_Node_Str",fa);
        currentType=null;
      }
    }
 else     if (modification instanceof CMethodInvocation) {
      CMethodInvocation mi=(CMethodInvocation)modification;
      try {
        if (currentType instanceof ObjectType) {
          MethodSymbol ms=((ObjectType)currentType).getMethod(mi.method_name,mi.arguments);
          if (ms == null) {
            CompilerErrors.printErrorMessage("String_Node_Str",mi);
            currentType=null;
          }
          currentType=ms.getReturnType();
        }
 else         if (currentType instanceof ActorType) {
          if (modifications.getFirst().equals(modification) && (isSelf() || isParent() || SymbolTable.isReferenceMethod((CMethodInvocation)modification))) {
            currentType=((ActorType)currentType).getMessage(mi.method_name,mi.arguments,isParentMessageSend).getPassType();
          }
 else {
            CompilerErrors.printErrorMessage("String_Node_Str",mi);
            currentType=null;
          }
        }
 else         if (currentType instanceof ArrayType) {
          CompilerErrors.printErrorMessage("String_Node_Str",mi);
          currentType=null;
        }
 else         if (currentType instanceof PrimitiveType) {
          CompilerErrors.printErrorMessage("String_Node_Str",mi);
          currentType=null;
        }
 else {
          CompilerErrors.printErrorMessage("String_Node_Str",mi);
          currentType=null;
        }
        if (currentType != null) {
          code+="String_Node_Str" + mi.method_name + "String_Node_Str";
          for (          CExpression argument : mi.arguments) {
            if (!argument.isToken()) {
              code+=argument.toJavaCode();
              if (!argument.equals(mi.arguments.lastElement()))               code+="String_Node_Str";
            }
 else {
              CompilerErrors.printErrorMessage("String_Node_Str",argument);
            }
          }
          code+="String_Node_Str";
        }
      }
 catch (      VariableDeclarationException vde) {
        CompilerErrors.printErrorMessage("String_Node_Str" + vde.toString(),mi);
        throw new RuntimeException(vde);
      }
catch (      SalsaNotFoundException snfe) {
        CompilerErrors.printErrorMessage("String_Node_Str" + snfe.toString(),mi);
        throw new RuntimeException(snfe);
      }
    }
 else     if (modification instanceof CMessageSend) {
      CMessageSend ms=(CMessageSend)modification;
      try {
        String joinDirector=SymbolTable.getJoinDirector();
        if (ms.message_property != null && !ms.message_property.name.equals("String_Node_Str")) {
          CompilerErrors.printErrorMessage("String_Node_Str" + ms.message_property.name + "String_Node_Str",ms);
        }
        boolean moreMessages=false;
        for (int new_pos=position + 1; new_pos < modifications.size(); new_pos++) {
          if (modifications.get(new_pos) instanceof CMessageSend) {
            moreMessages=true;
            break;
          }
        }
        String pre_code="String_Node_Str";
        if (SymbolTable.continuesToPass && !SymbolTable.withinArguments) {
          pre_code+="String_Node_Str";
        }
 else         if (SymbolTable.withinArguments) {
          pre_code+="String_Node_Str";
        }
 else         if (SymbolTable.continuationTokenMessage) {
          pre_code+="String_Node_Str";
        }
 else         if (SymbolTable.isExpressionContinuation) {
          pre_code+="String_Node_Str";
        }
 else         if (SymbolTable.messageContinues || joinDirector != null) {
          if (moreMessages) {
            pre_code+="String_Node_Str";
          }
 else {
            if (SymbolTable.firstContinuation()) {
              pre_code+="String_Node_Str";
              SymbolTable.initializedFirstContinuation();
            }
            pre_code+="String_Node_Str";
          }
        }
 else         if (moreMessages) {
          pre_code+="String_Node_Str";
        }
 else {
          pre_code+="String_Node_Str";
        }
        String expression_director_code="String_Node_Str";
        pre_code+="String_Node_Str";
        String target_code=code;
        if (currentType.isInterface)         target_code="String_Node_Str" + target_code;
        if (currentValueIsToken) {
          code=pre_code + "String_Node_Str";
        }
 else {
          code=pre_code + target_code + "String_Node_Str";
        }
        if (!(currentType instanceof ActorType)) {
          CompilerErrors.printErrorMessage("String_Node_Str" + currentType.getLongSignature() + "String_Node_Str",ms);
          throw new RuntimeException();
        }
        ActorType at=(ActorType)currentType;
        MessageSymbol messageSymbol=null;
        try {
          messageSymbol=at.getMessage(ms.message_name,ms.arguments,isParentMessageSend);
        }
 catch (        VariableDeclarationException vde) {
          CompilerErrors.printErrorMessage("String_Node_Str" + ms.message_name + "String_Node_Str"+ vde.toString(),ms);
          throw new RuntimeException(vde);
        }
catch (        SalsaNotFoundException snfe) {
          CompilerErrors.printErrorMessage("String_Node_Str" + ms.message_name + "String_Node_Str",ms);
          throw new RuntimeException(snfe);
        }
        code+=messageSymbol.getId();
        code+="String_Node_Str" + ms.message_name + "String_Node_Str";
        String argument_code="String_Node_Str";
        String argument_tokens="String_Node_Str";
        boolean hasContinuationToken=false;
        boolean hasToken=false;
        int j=0;
        for (        CExpression argument : ms.arguments) {
          if (argument.isToken()) {
            if (argument.requiresExpressionDirector()) {
              expression_director_code+=argument.getExpressionDirectorCode();
            }
            if (argument_tokens.length() > 10)             argument_tokens+="String_Node_Str";
            argument_tokens+=j;
            hasToken=true;
          }
 else           if (SymbolTable.isMutableObject(argument.getType())) {
            argument_code+="String_Node_Str" + argument.getType().getName() + "String_Node_Str";
          }
          SymbolTable.withinArguments=true;
          argument_code+=argument.toJavaCode();
          SymbolTable.withinArguments=false;
          if (!argument.isToken() && SymbolTable.isMutableObject(argument.getType()))           argument_code+="String_Node_Str";
          if (!argument.equals(ms.arguments.lastElement()))           argument_code+="String_Node_Str";
          j++;
        }
        code=expression_director_code + code;
        if (hasToken) {
          argument_code+="String_Node_Str" + argument_tokens + "String_Node_Str";
        }
 else {
          argument_code+="String_Node_Str";
        }
        if (ms.arguments.size() == 0)         argument_code="String_Node_Str";
        code+=argument_code;
        if (ms.message_property != null && ms.message_property.name.equals("String_Node_Str")) {
          code+="String_Node_Str";
          for (int i=0; i < ms.message_property.arguments.size(); i++) {
            CExpression arg=ms.message_property.arguments.get(i);
            if (!arg.isToken()) {
              CompilerErrors.printErrorMessage("String_Node_Str",arg);
              throw new RuntimeException();
            }
            code+=arg.toJavaCode();
            if (i != ms.message_property.arguments.size() - 1)             code+="String_Node_Str";
          }
          if (SymbolTable.messageRequiresContinuation) {
            code+="String_Node_Str";
            SymbolTable.messageRequiresContinuation=false;
          }
          code+="String_Node_Str";
        }
 else         if (SymbolTable.messageRequiresContinuation) {
          code+="String_Node_Str";
          SymbolTable.messageRequiresContinuation=false;
        }
        if (SymbolTable.continuesToPass && !SymbolTable.withinArguments) {
          code+="String_Node_Str";
        }
        if (currentValueIsToken) {
          code+="String_Node_Str" + target_code;
        }
        code+="String_Node_Str";
        if (joinDirector != null && !SymbolTable.messageContinues) {
          code+="String_Node_Str";
          code+=CIndent.getIndent() + "String_Node_Str" + joinDirector+ "String_Node_Str"+ joinDirector+ "String_Node_Str";
        }
        currentType=((ActorType)currentType).getMessage(ms.message_name,ms.arguments,isParentMessageSend).getPassType();
        SymbolTable.setContinuationType(currentType);
      }
 catch (      VariableDeclarationException vde) {
        CompilerErrors.printErrorMessage("String_Node_Str" + vde.toString(),ms);
        throw new RuntimeException(vde);
      }
catch (      SalsaNotFoundException snfe) {
        CompilerErrors.printErrorMessage("String_Node_Str" + snfe.toString(),ms);
        throw new RuntimeException(snfe);
      }
      currentValueIsToken=true;
    }
    isParentMessageSend=false;
    position++;
  }
  return code;
}