Program: 75168
Project: 75168
Buggy source:
/** 
 * Return the reference to the specified parameter or port of the associated actor. For a parameter, the returned string is in the form "fullName_parameterName". For a port, the returned string is in the form "fullName_portName[channelNumber][offset]", if any channel number or offset is given.
 * @param name The name of the parameter or port
 * @return The reference to that parameter or port (a variable name,for example).
 * @exception IllegalActionException If the parameter or port does notexist or does not have a value.
 */
public String getReference(String name) throws IllegalActionException {
  StringBuffer result=new StringBuffer();
  Actor actor=(Actor)_component;
  StringTokenizer tokenizer=new StringTokenizer(name,"String_Node_Str",true);
  if (tokenizer.countTokens() != 1 && tokenizer.countTokens() != 3 && tokenizer.countTokens() != 5) {
    throw new IllegalActionException(_component,"String_Node_Str" + name);
  }
  String refName=tokenizer.nextToken().trim();
  Iterator inputPorts=actor.inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort port=(IOPort)inputPorts.next();
    if (port.getName().equals(refName)) {
      result.append(port.getFullName().replace('.','_'));
      int[] channelAndOffset=_getChannelAndOffset(name);
      if (channelAndOffset[0] >= 0) {
        result.append("String_Node_Str" + channelAndOffset[0] + "String_Node_Str");
      }
      if (channelAndOffset[1] >= 0) {
        int offset=channelAndOffset[1] + _firingCount * port.getReceivers()[0].length;
        result.append("String_Node_Str" + channelAndOffset[1] + "String_Node_Str");
      }
 else       if (_firingsPerIteration > 1) {
        result.append("String_Node_Str" + _firingCount + "String_Node_Str");
      }
      return result.toString();
    }
  }
  Iterator outputPorts=actor.outputPortList().iterator();
  while (outputPorts.hasNext()) {
    IOPort port=(IOPort)outputPorts.next();
    if (port.getName().equals(refName)) {
      Receiver[][] remoteReceivers=(port.getRemoteReceivers());
      if (remoteReceivers.length == 0) {
        result.append(_component.getFullName().replace('.','_'));
        result.append("String_Node_Str");
        result.append(port.getName());
        return result.toString();
      }
      int[] channelAndOffset=_getChannelAndOffset(name);
      if (channelAndOffset[0] < 0) {
        result.append(getSinkChannels(port,0));
      }
 else {
        result.append(getSinkChannels(port,channelAndOffset[0]));
      }
      if (channelAndOffset[1] >= 0) {
        result.append("String_Node_Str" + channelAndOffset[1] + "String_Node_Str");
      }
 else       if (_firingsPerIteration > 1) {
        result.append("String_Node_Str" + _firingCount + "String_Node_Str");
      }
      return result.toString();
    }
  }
  Attribute attribute=_component.getAttribute(refName);
  if (attribute != null) {
    if (attribute instanceof Parameter) {
      _referencedParameters.add(attribute);
    }
    result.append(_component.getFullName().replace('.','_'));
    result.append("String_Node_Str");
    result.append(refName);
    return result.toString();
  }
  throw new IllegalActionException(_component,"String_Node_Str" + name);
}

Fixed version (ground truth):
/** 
 * Return the reference to the specified parameter or port of the associated actor. For a parameter, the returned string is in the form "fullName_parameterName". For a port, the returned string is in the form "fullName_portName[channelNumber][offset]", if any channel number or offset is given.
 * @param name The name of the parameter or port
 * @return The reference to that parameter or port (a variable name,for example).
 * @exception IllegalActionException If the parameter or port does notexist or does not have a value.
 */
public String getReference(String name) throws IllegalActionException {
  StringBuffer result=new StringBuffer();
  Actor actor=(Actor)_component;
  StringTokenizer tokenizer=new StringTokenizer(name,"String_Node_Str",true);
  if (tokenizer.countTokens() != 1 && tokenizer.countTokens() != 3 && tokenizer.countTokens() != 5) {
    throw new IllegalActionException(_component,"String_Node_Str" + name);
  }
  String refName=tokenizer.nextToken().trim();
  Iterator inputPorts=actor.inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort port=(IOPort)inputPorts.next();
    if (port.getName().equals(refName)) {
      result.append(port.getFullName().replace('.','_'));
      int[] channelAndOffset=_getChannelAndOffset(name);
      if (channelAndOffset[0] >= 0) {
        result.append("String_Node_Str" + channelAndOffset[0] + "String_Node_Str");
      }
      if (channelAndOffset[1] >= 0) {
        int offset=channelAndOffset[1] + _firingCount * port.getReceivers()[0].length;
        result.append("String_Node_Str" + channelAndOffset[1] + "String_Node_Str");
      }
 else       if (_firingsPerIteration > 1) {
        result.append("String_Node_Str" + _firingCount + "String_Node_Str");
      }
      return result.toString();
    }
  }
  Iterator outputPorts=actor.outputPortList().iterator();
  while (outputPorts.hasNext()) {
    IOPort port=(IOPort)outputPorts.next();
    if (port.getName().equals(refName)) {
      Receiver[][] remoteReceivers=(port.getRemoteReceivers());
      if (remoteReceivers.length == 0) {
        result.append(_component.getFullName().replace('.','_'));
        result.append("String_Node_Str");
        result.append(port.getName());
        return result.toString();
      }
      int[] channelAndOffset=_getChannelAndOffset(name);
      if (channelAndOffset[0] < 0) {
        result.append(getSinkChannels(port,0));
      }
 else {
        result.append(getSinkChannels(port,channelAndOffset[0]));
      }
      if (channelAndOffset[1] >= 0) {
        result.append("String_Node_Str" + channelAndOffset[1] + "String_Node_Str");
      }
 else       if (_firingsPerIteration > 1) {
        result.append("String_Node_Str" + _firingCount + "String_Node_Str");
      }
      return result.toString();
    }
  }
  Attribute attribute=_component.getAttribute(refName);
  if (attribute != null) {
    if (attribute instanceof Parameter) {
      _referencedParameters.add(attribute);
    }
    result.append(_component.getFullName().replace('.','_'));
    result.append("String_Node_Str");
    result.append(refName);
    int[] channelAndOffset=_getChannelAndOffset(name);
    if (channelAndOffset[0] != -1) {
      throw new IllegalActionException(_component,"String_Node_Str");
    }
    if (channelAndOffset[1] >= 0) {
      result.append("String_Node_Str" + channelAndOffset[1] + "String_Node_Str");
    }
    return result.toString();
  }
  throw new IllegalActionException(_component,"String_Node_Str" + name);
}