Program: 72921
Project: 72921
Buggy source:
public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  List<TypedIOPort> inputPorts=_myController.inputPortList();
  List<TypedIOPort> outputPorts=_myController.outputPortList();
  String name=_myController.getFullName().substring(1);
  String modalName=name.replace("String_Node_Str","String_Node_Str");
  name=name.replace('.','_');
  modalName=modalName.replace('.','_');
  TypedIOPort inputPort;
  code.append(_eol + getCodeGenerator().comment("String_Node_Str"));
  for (int i=0; i < inputPorts.size(); i++) {
    inputPort=inputPorts.get(i);
    if (!outputPorts.contains(inputPort)) {
      int width=inputPort.getWidth();
      code.append(inputPort.getType() + "String_Node_Str" + name+ "String_Node_Str"+ inputPort.getName());
      if (width > 1) {
        code.append("String_Node_Str" + width + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  code.append("String_Node_Str" + modalName + "String_Node_Str"+ _eol);
  String enumStates=_eol + "String_Node_Str" + name+ "String_Node_Str";
  Iterator states=_myController.entityList().iterator();
  boolean first=true;
  while (states.hasNext()) {
    if (first)     first=false;
 else     enumStates+="String_Node_Str";
    State state=(State)states.next();
    String stateName=CodeGeneratorAdapter.generateName(state);
    enumStates+=stateName;
  }
  enumStates+="String_Node_Str";
  code.append(enumStates);
  code.append(_eol + "String_Node_Str" + name+ "String_Node_Str"+ name+ "String_Node_Str");
  code.append(_eol + getCodeGenerator().comment("String_Node_Str"));
  return code.toString();
}

Fixed version (ground truth):
public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  List<TypedIOPort> inputPorts=_myController.inputPortList();
  List<TypedIOPort> outputPorts=_myController.outputPortList();
  String name=_myController.getFullName().substring(1);
  String modalName=name.replace("String_Node_Str","String_Node_Str");
  name=name.replace('.','_');
  modalName=modalName.replace('.','_');
  TypedIOPort inputPort;
  code.append(_eol + getCodeGenerator().comment("String_Node_Str"));
  for (int i=0; i < inputPorts.size(); i++) {
    inputPort=inputPorts.get(i);
    if (!outputPorts.contains(inputPort)) {
      int width=inputPort.getWidth();
      code.append(inputPort.getType() + "String_Node_Str" + name+ "String_Node_Str"+ inputPort.getName());
      if (width > 1) {
        code.append("String_Node_Str" + width + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  code.append("String_Node_Str" + modalName + "String_Node_Str"+ _eol);
  StringBuffer enumStates=new StringBuffer(_eol + "String_Node_Str" + name+ "String_Node_Str");
  Iterator states=_myController.entityList().iterator();
  boolean first=true;
  while (states.hasNext()) {
    if (first)     first=false;
 else     enumStates.append("String_Node_Str");
    State state=(State)states.next();
    String stateName=CodeGeneratorAdapter.generateName(state);
    enumStates.append(stateName);
  }
  enumStates.append("String_Node_Str");
  code.append(enumStates);
  code.append(_eol + "String_Node_Str" + name+ "String_Node_Str"+ name+ "String_Node_Str");
  code.append(_eol + getCodeGenerator().comment("String_Node_Str"));
  return code.toString();
}