nus-yam/ex-repair huggingface dataset:
Program: 74714
Project: 74714
Buggy source:
/** 
 * output a consecutive subset of the input bits.  If there is no input, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (select.isKnown() && input.isKnown()) {
    if (select.hasToken(0)) {
      FixToken channel=(FixToken)select.get(0);
      _checkFixMaxValue(channel,input.getWidth() - 1);
      _channel=channel.fixValue().getUnscaledValue().intValue();
    }
    for (int i=0; i < input.getWidth(); i++) {
      if (input.hasToken(i)) {
        Token token=input.get(i);
        if (i == _channel) {
          output.send(0,token);
        }
      }
    }
  }
 else {
    output.resend(0);
  }
}

Fixed version (ground truth):
/** 
 * output a consecutive subset of the input bits.  If there is no input, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (select.isKnown() && input.isKnown()) {
    if (select.hasToken(0)) {
      FixToken channel=(FixToken)select.get(0);
      _checkFixMaxValue(channel,input.getWidth() - 1);
      _channel=channel.fixValue().getUnscaledValue().intValue();
    }
    for (int i=0; i < input.getWidth(); i++) {
      if (input.hasToken(i)) {
        Token token=input.get(i);
        if (i == _channel) {
          sendOutput(output,0,token);
        }
      }
    }
  }
 else {
    output.resend(0);
  }
}
Program: 74715
Project: 74715
Buggy source:
/** 
 * output a consecutive subset of the input bits.  If there is no input, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  int widthValue=((IntToken)width.getToken()).intValue();
  int startValue=((IntToken)start.getToken()).intValue();
  int endValue=((IntToken)end.getToken()).intValue() + 1;
  int binaryPointValue=((IntToken)binaryPoint.getToken()).intValue();
  boolean lsbValue=((StringToken)lsb.getToken()).stringValue().equals("String_Node_Str");
  int newStartValue=(lsbValue) ? widthValue - endValue : startValue;
  int newEndValue=(lsbValue) ? widthValue - startValue : endValue;
  int shiftBits=(lsbValue) ? startValue : widthValue - endValue;
  char[] mask=new char[widthValue];
  Arrays.fill(mask,'0');
  Arrays.fill(mask,newStartValue,newEndValue,'1');
  if (input.hasToken(0)) {
    FixToken in=(FixToken)input.get(0);
    BigDecimal value=new BigDecimal(in.fixValue().getUnscaledValue().and(new BigInteger(new String(mask),2)).shiftRight(shiftBits));
    FixPoint result=new FixPoint(value,new FixPointQuantization(new Precision(0,newEndValue - newStartValue,binaryPointValue),Overflow.GROW,Rounding.HALF_EVEN));
    output.send(0,new FixToken(result));
  }
}

Fixed version (ground truth):
/** 
 * output a consecutive subset of the input bits.  If there is no input, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  int widthValue=((IntToken)width.getToken()).intValue();
  int startValue=((IntToken)start.getToken()).intValue();
  int endValue=((IntToken)end.getToken()).intValue() + 1;
  int binaryPointValue=((IntToken)binaryPoint.getToken()).intValue();
  boolean lsbValue=((StringToken)lsb.getToken()).stringValue().equals("String_Node_Str");
  int newStartValue=(lsbValue) ? widthValue - endValue : startValue;
  int newEndValue=(lsbValue) ? widthValue - startValue : endValue;
  int shiftBits=(lsbValue) ? startValue : widthValue - endValue;
  char[] mask=new char[widthValue];
  Arrays.fill(mask,'0');
  Arrays.fill(mask,newStartValue,newEndValue,'1');
  if (input.hasToken(0)) {
    FixToken in=(FixToken)input.get(0);
    BigDecimal value=new BigDecimal(in.fixValue().getUnscaledValue().and(new BigInteger(new String(mask),2)).shiftRight(shiftBits));
    FixPoint result=new FixPoint(value,new FixPointQuantization(new Precision(0,newEndValue - newStartValue,binaryPointValue),Overflow.GROW,Rounding.HALF_EVEN));
    sendOutput(output,0,new FixToken(result));
  }
}
Program: 74716
Project: 74716
Buggy source:
/** 
 * Output the fixpoint value of the concatenation of the input bits.  If there is no inputs, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  Precision precision=new Precision(((Parameter)getAttribute("String_Node_Str")).getExpression());
  Overflow overflow=Overflow.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
  Rounding rounding=Rounding.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
  String bits="String_Node_Str";
  for (int i=0; i < input.getWidth(); i++) {
    if (input.hasToken(i)) {
      FixToken in=(FixToken)input.get(i);
      bits+=in.fixValue().toBitString();
    }
  }
  FixPoint result=new FixPoint(new BigDecimal(new BigInteger(bits,2)),new FixPointQuantization(precision,overflow,rounding));
  sendOutput(output,0,new FixToken(result));
}

Fixed version (ground truth):
/** 
 * Output the fixpoint value of the concatenation of the input bits.  If there is no inputs, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  Precision precision=new Precision(getPortPrecision(output));
  Overflow overflow=Overflow.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
  Rounding rounding=Rounding.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
  String bits="String_Node_Str";
  for (int i=0; i < input.getWidth(); i++) {
    if (input.hasToken(i)) {
      FixToken in=(FixToken)input.get(i);
      bits+=in.fixValue().toBitString();
    }
  }
  FixPoint result=new FixPoint(new BigDecimal(new BigInteger(bits,2)),new FixPointQuantization(precision,overflow,rounding));
  sendOutput(output,0,new FixToken(result));
}
Program: 74718
Project: 74718
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Memory(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  capacity=new Parameter(this,"String_Node_Str");
  capacity.setExpression("String_Node_Str");
  dataWidth=new Parameter(this,"String_Node_Str");
  dataWidth.setExpression("String_Node_Str");
  writeEnable=new TypedIOPort(this,"String_Node_Str",true,false);
  writeEnable.setTypeEquals(BaseType.BOOLEAN);
  address=new TypedIOPort(this,"String_Node_Str",true,false);
  address.setTypeEquals(BaseType.FIX);
  dataIn=new TypedIOPort(this,"String_Node_Str",true,false);
  dataIn.setTypeEquals(BaseType.FIX);
  dataOut=new TypedIOPort(this,"String_Node_Str",false,true);
  dataOut.setTypeEquals(BaseType.FIX);
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Memory(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  capacity=new Parameter(this,"String_Node_Str");
  capacity.setExpression("String_Node_Str");
  writeEnable=new TypedIOPort(this,"String_Node_Str",true,false);
  writeEnable.setTypeEquals(BaseType.FIX);
  address=new TypedIOPort(this,"String_Node_Str",true,false);
  address.setTypeEquals(BaseType.FIX);
  dataIn=new TypedIOPort(this,"String_Node_Str",true,false);
  dataIn.setTypeEquals(BaseType.FIX);
}
Program: 74719
Project: 74719
Buggy source:
/** 
 * Override the base class to determine which function is being specified.
 * @param attribute The attribute that changed.
 * @throws IllegalActionException 
 * @exception IllegalActionException If the function is not recognized.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  super.attributeChanged(attribute);
  if (attribute == capacity) {
    _capacity=((ScalarToken)capacity.getToken()).intValue();
    _addressWidth=(int)Math.floor(Math.log(_capacity) / Math.log(2));
    _storage=new FixToken[_capacity];
  }
 else   if (attribute == dataWidth) {
    _dataWidth=((ScalarToken)dataWidth.getToken()).intValue();
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to determine which function is being specified.
 * @param attribute The attribute that changed.
 * @throws IllegalActionException 
 * @exception IllegalActionException If the function is not recognized.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  super.attributeChanged(attribute);
  if (attribute == capacity) {
    _capacity=((ScalarToken)capacity.getToken()).intValue();
    _addressWidth=(int)Math.floor(Math.log(_capacity) / Math.log(2));
  }
 else   if (attribute.getName().equals("String_Node_Str")) {
    _dataWidth=new Precision(getPortPrecision(output)).getNumberOfBits();
  }
}
Program: 74720
Project: 74720
Buggy source:
/** 
 * Output the fixpoint value of the concatenation of the input bits.  If there is no inputs, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  int addressValue;
  if (!address.hasToken(0) || !writeEnable.hasToken(0) || !dataIn.hasToken(0)) {
    return;
  }
  FixToken in=((FixToken)dataIn.get(0));
  FixPoint addressFixValue=((FixToken)address.get(0)).fixValue();
  boolean writeEnableValue=((BooleanToken)writeEnable.get(0)).booleanValue();
  if (Math.pow(2,addressFixValue.getPrecision().getNumberOfBits()) - 1 > _addressWidth) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  }
  addressValue=addressFixValue.getUnscaledValue().intValue();
  if (addressValue >= _capacity) {
    throw new IllegalActionException("String_Node_Str");
  }
  if (in.fixValue().getPrecision().getNumberOfBits() != _dataWidth) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  }
  if (writeEnableValue) {
    _storage[addressValue]=in;
  }
  FixToken result=_storage[_preAddress].quantize(new FixPointQuantization(new Precision(((Parameter)getAttribute("String_Node_Str")).getExpression()),Overflow.GROW,Rounding.HALF_EVEN));
  dataOut.send(0,result);
}

Fixed version (ground truth):
/** 
 * Output the fixpoint value of the concatenation of the input bits.  If there is no inputs, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  int addressValue;
  if (!address.hasToken(0) || !writeEnable.hasToken(0) || !dataIn.hasToken(0)) {
    return;
  }
  FixToken in=((FixToken)dataIn.get(0));
  FixPoint addressFixValue=((FixToken)address.get(0)).fixValue();
  FixPoint writeEnableValue=((FixToken)writeEnable.get(0)).fixValue();
  if (writeEnableValue.getPrecision().getNumberOfBits() != 1) {
    throw new IllegalActionException(this,"String_Node_Str" + writeEnableValue.getPrecision() + "String_Node_Str");
  }
  if (addressFixValue.getPrecision().getNumberOfBits() != _addressWidth) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  addressValue=addressFixValue.getUnscaledValue().intValue();
  if (addressValue >= _capacity) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  if (in.fixValue().getPrecision().getNumberOfBits() != _dataWidth) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  Token result=_storage[addressValue];
  if (result == null) {
    result=FixToken.NIL;
  }
  if (writeEnableValue.toBitString().equals("String_Node_Str")) {
    _storage[addressValue]=in;
  }
  sendOutput(output,0,result);
}
Program: 74721
Project: 74721
Buggy source:
/** 
 * Output the fixpoint value of the sum of the input bits.  If there is no inputs, then produce null.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  Token result=null;
  if (A.hasToken(0) && B.hasToken(0)) {
    result=A.get(0).multiply(B.get(0));
    Precision precision=new Precision(((Parameter)getAttribute("String_Node_Str")).getExpression());
    Overflow overflow=Overflow.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
    Rounding rounding=Rounding.getName(((Parameter)getAttribute("String_Node_Str")).getExpression().toLowerCase());
    Quantization quantization=new FixPointQuantization(precision,overflow,rounding);
    result=((FixToken)result).quantize(quantization);
    if (!((FixToken)result).fixValue().getPrecision().equals(new Precision(((Parameter)getAttribute("String_Node_Str")).getExpression()))) {
      System.out.println("String_Node_Str");
    }
  }
  output.send(0,result);
}

Fixed version (ground truth):
/** 
 * Output the fixpoint value of the sum of the input bits.  If there is no inputs, then produce null.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (A.hasToken(0) && B.hasToken(0)) {
    Token result=A.get(0).multiply(B.get(0));
    sendOutput(output,0,result);
  }
}
Program: 74723
Project: 74723
Buggy source:
/** 
 * Enqueue the token that is being sent and send to the parent whatever is at the end of the queue
 */
public void send(int channelIndex,Token token) throws IllegalActionException, NoRoomException {
  myQueue.add(token);
  Token sendToken=myQueue.getFirst();
  super.send(channelIndex,sendToken);
}

Fixed version (ground truth):
/** 
 * Enqueue the token that is being sent and send to the parent whatever is at the end of the queue
 */
public void send(int channelIndex,Token token) throws IllegalActionException, NoRoomException {
  myQueue.add(token);
  Token sendToken=myQueue.removeFirst();
  super.send(channelIndex,sendToken);
}
Program: 74724
Project: 74724
Buggy source:
/** 
 * Read a token from the row and column ports and illuminate that led until the next fire.   
 * @exception IllegalActionException If the row or column portscannot be read.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (row.hasToken(0) && column.hasToken(0) && control.hasToken(0)) {
    int rowValue=((IntToken)row.get(0)).intValue();
    int columnValue=((IntToken)row.get(0)).intValue();
    boolean controlValue=((BooleanToken)control.get(0)).booleanValue();
    if (controlValue) {
      _leds[rowValue][columnValue].fillColor.setToken("String_Node_Str");
    }
 else {
      _leds[rowValue][columnValue].fillColor.setToken("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Read a token from the row and column ports and illuminate that led until the next fire.   
 * @exception IllegalActionException If the row or column portscannot be read.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (row.hasToken(0) && column.hasToken(0) && control.hasToken(0)) {
    int rowValue=((IntToken)row.get(0)).intValue();
    int columnValue=((IntToken)column.get(0)).intValue();
    boolean controlValue=((BooleanToken)control.get(0)).booleanValue();
    if (controlValue) {
      _leds[rowValue][columnValue].fillColor.setToken("String_Node_Str");
    }
 else {
      _leds[rowValue][columnValue].fillColor.setToken("String_Node_Str");
    }
  }
}
Program: 74725
Project: 74725
Buggy source:
/** 
 * Return all the InequalityTerms for all input ports in an array.
 * @return An array of InequalityTerm.
 */
public InequalityTerm[] getVariables(){
  List inputPorts=inputPortList();
  Object[] portsObj=inputPorts.toArray();
  InequalityTerm[] variables=new InequalityTerm[portsObj.length];
  for (int i=0; i < variables.length; i++) {
    TypedIOPort port=(TypedIOPort)portsObj[i];
    variables[i]=port.getTypeTerm();
  }
  return variables;
}

Fixed version (ground truth):
/** 
 * Return all the InequalityTerms for all input ports in an array.
 * @return An array of InequalityTerm.
 */
public InequalityTerm[] getVariables(){
  Iterator inputPorts=inputPortList().iterator();
  LinkedList result=new LinkedList();
  while (inputPorts.hasNext()) {
    TypedIOPort port=(TypedIOPort)inputPorts.next();
    InequalityTerm term=port.getTypeTerm();
    if (term.isSettable()) {
      result.add(term);
    }
  }
  InequalityTerm[] variables=new InequalityTerm[result.size()];
  Iterator results=result.iterator();
  int i=0;
  while (results.hasNext()) {
    variables[i]=(InequalityTerm)results.next();
    i++;
  }
  return variables;
}
Program: 74726
Project: 74726
Buggy source:
/** 
 * Create a new if tree.
 * @param name The name to give this if tree.
 * @param parent The paretn to this tree, which may be nullif this is the root of a tree.
 */
public IfTree(IfTree parent,String name){
  super(parent,name);
  _trueNameMappings=new Hashtable<String,String>();
  _trueSetStatus=new Hashtable<String,Boolean>();
  _trueSymbols=new Hashtable<String,String>();
  _falseNameMappings=new Hashtable<String,String>();
  _falseSetStatus=new Hashtable<String,Boolean>();
  _falseSymbols=new Hashtable<String,String>();
}

Fixed version (ground truth):
/** 
 * Create a new if tree.
 * @param name The name to give this if tree.
 * @param parent The parent to this tree, which may be nullif this is the root of a tree.
 */
public IfTree(IfTree parent,String name){
  super(parent,name);
  _trueNameMappings=new Hashtable<String,String>();
  _trueSetStatus=new Hashtable<String,Boolean>();
  _trueSymbols=new Hashtable<String,String>();
  _falseNameMappings=new Hashtable<String,String>();
  _falseSetStatus=new Hashtable<String,Boolean>();
  _falseSymbols=new Hashtable<String,String>();
}
Program: 74727
Project: 74727
Buggy source:
/** 
 * Evaluate this for block, assuming this is a for block.
 * @throws PtalonRuntimeException If there isany trouble evaluating this for block.
 */
public void evaluateForScope() throws PtalonRuntimeException {
  Token initialValue=evaluateExpression(initExpr);
  _scope.addVariable(variable,initialValue);
  _currentBranch=true;
  _inNewWhileIteration=true;
  while (evaluateBoolean(satExpr)) {
    try {
      populator.iterative_statement_evaluator(forBlock);
    }
 catch (    RecognitionException e) {
      throw new PtalonRuntimeException("String_Node_Str",e);
    }
    Token nextValue=evaluateExpression(nextExpr);
    _scope.addVariable(variable,nextValue);
  }
  _inNewWhileIteration=false;
  _scope.removeVariable(variable);
  _currentBranch=false;
}

Fixed version (ground truth):
/** 
 * Evaluate this for block, assuming this is a for block.
 * @throws PtalonRuntimeException If there isany trouble evaluating this for block.
 */
public void evaluateForScope() throws PtalonRuntimeException {
  if (getParent().isForStatement) {
    entered=1;
  }
  Token initialValue=evaluateExpression(initExpr);
  _scope.addVariable(variable,initialValue);
  _currentBranch=true;
  _inNewWhileIteration=true;
  while (evaluateBoolean(satExpr)) {
    try {
      populator.iterative_statement_evaluator(forBlock);
    }
 catch (    RecognitionException e) {
      throw new PtalonRuntimeException("String_Node_Str",e);
    }
    Token nextValue=evaluateExpression(nextExpr);
    _scope.addVariable(variable,nextValue);
  }
  _inNewWhileIteration=false;
  _scope.removeVariable(variable);
  _currentBranch=false;
}
Program: 74729
Project: 74729
Buggy source:
/** 
 * Execute the compile and run commands in the <i>codeDirectory</i> directory.
 * @return The return value of the last subprocess that was executedor -1 if no commands were executed.
 */
private int _executeCommands() throws IllegalActionException {
  List commands=new LinkedList();
  if (((BooleanToken)compile.getToken()).booleanValue()) {
    commands.add("String_Node_Str" + _sanitizedModelName + "String_Node_Str");
  }
  if (isTopLevel()) {
    if (((BooleanToken)compile.getToken()).booleanValue()) {
      String command=codeDirectory.stringValue() + ((!codeDirectory.stringValue().endsWith("String_Node_Str") && !codeDirectory.stringValue().endsWith("String_Node_Str")) ? "String_Node_Str" : "String_Node_Str") + _sanitizedModelName;
      commands.add("String_Node_Str" + command.replace('\\','/') + "String_Node_Str");
    }
  }
  if (commands.size() == 0) {
    return -1;
  }
  _executeCommands.setCommands(commands);
  _executeCommands.setWorkingDirectory(codeDirectory.asFile());
  try {
    _executeCommands.start();
  }
 catch (  Exception ex) {
    StringBuffer errorMessage=new StringBuffer();
    Iterator allCommands=commands.iterator();
    while (allCommands.hasNext()) {
      errorMessage.append((String)allCommands.next() + "String_Node_Str");
    }
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + errorMessage);
  }
  return _executeCommands.getLastSubprocessReturnCode();
}

Fixed version (ground truth):
/** 
 * Execute the compile and run commands in the <i>codeDirectory</i> directory.
 * @return The return value of the last subprocess that was executedor -1 if no commands were executed.
 */
private int _executeCommands() throws IllegalActionException {
  List commands=new LinkedList();
  if (((BooleanToken)compile.getToken()).booleanValue()) {
    commands.add("String_Node_Str" + _sanitizedModelName + "String_Node_Str");
  }
  if (isTopLevel()) {
    if (((BooleanToken)run.getToken()).booleanValue()) {
      String command=codeDirectory.stringValue() + ((!codeDirectory.stringValue().endsWith("String_Node_Str") && !codeDirectory.stringValue().endsWith("String_Node_Str")) ? "String_Node_Str" : "String_Node_Str") + _sanitizedModelName;
      commands.add("String_Node_Str" + command.replace('\\','/') + "String_Node_Str");
    }
  }
  if (commands.size() == 0) {
    return -1;
  }
  _executeCommands.setCommands(commands);
  _executeCommands.setWorkingDirectory(codeDirectory.asFile());
  try {
    _executeCommands.start();
  }
 catch (  Exception ex) {
    StringBuffer errorMessage=new StringBuffer();
    Iterator allCommands=commands.iterator();
    while (allCommands.hasNext()) {
      errorMessage.append((String)allCommands.next() + "String_Node_Str");
    }
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + errorMessage);
  }
  return _executeCommands.getLastSubprocessReturnCode();
}
Program: 74732
Project: 74732
Buggy source:
/** 
 * Update connections to subscribers.
 * @exception IllegalActionException If there is already a publisherpublishing on the same channel.
 */
private void _updateLinks() throws IllegalActionException {
  if (_channel == null) {
    return;
  }
  Iterator subscribers=_findSubscribers().iterator();
  if (_relation != null) {
    try {
      _relation.setContainer(null);
    }
 catch (    NameDuplicationException e) {
      throw new InternalErrorException(e);
    }
    _relation=null;
  }
  NamedObj container=getContainer();
  if (container instanceof TypedCompositeActor) {
    try {
      _relation=new TypedIORelation((TypedCompositeActor)container,container.uniqueName("String_Node_Str"));
      _relation.setPersistent(false);
      new Parameter(_relation,"String_Node_Str",BooleanToken.TRUE);
      _relation.setWidth(input.getWidth());
    }
 catch (    NameDuplicationException e) {
      throw new InternalErrorException(e);
    }
    output.link(_relation);
    while (subscribers.hasNext()) {
      Subscriber subscriber=(Subscriber)subscribers.next();
      subscriber.input.liberalLink(_relation);
    }
  }
  Director director=getDirector();
  if (director != null) {
    director.invalidateSchedule();
    director.invalidateResolvedTypes();
  }
}

Fixed version (ground truth):
/** 
 * Update connections to subscribers.
 * @exception IllegalActionException If there is already a publisherpublishing on the same channel.
 */
private void _updateLinks() throws IllegalActionException {
  if (_channel == null) {
    return;
  }
  Iterator subscribers=_findSubscribers().iterator();
  if (_relation != null) {
    try {
      _relation.setContainer(null);
    }
 catch (    NameDuplicationException e) {
      throw new InternalErrorException(e);
    }
    _relation=null;
  }
  NamedObj container=getContainer();
  if (container instanceof TypedCompositeActor) {
    try {
      _relation=new TypedIORelation((TypedCompositeActor)container,container.uniqueName("String_Node_Str"));
      _relation.setPersistent(false);
      new Parameter(_relation,"String_Node_Str",BooleanToken.TRUE);
      _relation.setWidth(input.getWidth());
    }
 catch (    NameDuplicationException e) {
      throw new InternalErrorException(e);
    }
    output.link(_relation);
    while (subscribers.hasNext()) {
      Subscriber subscriber=(Subscriber)subscribers.next();
      subscriber.input.liberalLink(_relation);
    }
  }
  Director director=getDirector();
  if (director != null) {
    director.invalidateSchedule();
    director.invalidateResolvedTypes();
  }
  _updatedLinks=true;
}
Program: 74733
Project: 74733
Buggy source:
/** 
 * Override the base class to ensure that there is a publisher.
 * @exception IllegalActionException If there is no matchingpublisher.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  int width=input.getWidth();
  if (width == 0) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to ensure that there is a publisher.
 * @exception IllegalActionException If there is no matchingpublisher.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  if (!_updatedLinks) {
    _updateLinks();
  }
  int width=input.getWidth();
  if (width == 0) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
}
Program: 74734
Project: 74734
Buggy source:
/** 
 * Update the connection to the publisher, if there is one.
 * @exception IllegalActionException If creating the linktriggers an exception.
 */
protected void _updateLinks() throws IllegalActionException {
  if (_channel == null) {
    return;
  }
  Publisher publisher=_findPublisher();
  if (_relation != null) {
    input.unlink(_relation);
    _relation=null;
  }
  if (publisher != null) {
    _relation=publisher._relation;
    input.liberalLink(_relation);
  }
  Director director=getDirector();
  if (director != null) {
    director.invalidateSchedule();
    director.invalidateResolvedTypes();
  }
}

Fixed version (ground truth):
/** 
 * Update the connection to the publisher, if there is one.
 * @exception IllegalActionException If creating the linktriggers an exception.
 */
protected void _updateLinks() throws IllegalActionException {
  if (_channel == null) {
    return;
  }
  Publisher publisher=_findPublisher();
  if (_relation != null) {
    input.unlink(_relation);
    _relation=null;
  }
  if (publisher != null) {
    _relation=publisher._relation;
    input.liberalLink(_relation);
  }
  Director director=getDirector();
  if (director != null) {
    director.invalidateSchedule();
    director.invalidateResolvedTypes();
  }
  _updatedLinks=true;
}
Program: 74735
Project: 74735
Buggy source:
/** 
 * Update the connection to the publishers, if there are any.
 * @exception IllegalActionException If creating the linktriggers an exception.
 */
protected void _updateLinks() throws IllegalActionException {
  if (_channel == null) {
    return;
  }
  Iterator relations=_relations.iterator();
  while (relations.hasNext()) {
    Relation relation=(Relation)relations.next();
    input.unlink(relation);
  }
  _relations.clear();
  Iterator publishers=_findPublishers().iterator();
  while (publishers.hasNext()) {
    Publisher publisher=(Publisher)publishers.next();
    ComponentRelation relation=publisher._relation;
    input.liberalLink(relation);
  }
  Director director=getDirector();
  if (director != null) {
    director.invalidateSchedule();
    director.invalidateResolvedTypes();
  }
}

Fixed version (ground truth):
/** 
 * Update the connection to the publishers, if there are any.
 * @exception IllegalActionException If creating the linktriggers an exception.
 */
protected void _updateLinks() throws IllegalActionException {
  if (_channel == null) {
    return;
  }
  Iterator relations=_relations.iterator();
  while (relations.hasNext()) {
    Relation relation=(Relation)relations.next();
    input.unlink(relation);
  }
  _relations.clear();
  Iterator publishers=_findPublishers().iterator();
  while (publishers.hasNext()) {
    Publisher publisher=(Publisher)publishers.next();
    ComponentRelation relation=publisher._relation;
    input.liberalLink(relation);
  }
  Director director=getDirector();
  if (director != null) {
    director.invalidateSchedule();
    director.invalidateResolvedTypes();
  }
  _updatedLinks=true;
}
Program: 74736
Project: 74736
Buggy source:
/** 
 * Return the direction between two points who differ by the given amounts.  The direction returned is restricted to the closest orthogonal direction.  The integer returned is from SwingUtilities.
 */
private int getManhattanDirection(double xDiff,double yDiff){
  int dir;
  if ((xDiff > 0) && (yDiff > 0)) {
    if (xDiff > yDiff) {
      dir=SwingUtilities.EAST;
    }
 else {
      dir=SwingUtilities.SOUTH;
    }
  }
 else   if ((xDiff < 0) && (yDiff < 0)) {
    if (xDiff > yDiff) {
      dir=SwingUtilities.NORTH;
    }
 else {
      dir=SwingUtilities.WEST;
    }
  }
 else   if (xDiff > 0) {
    if (xDiff > -yDiff) {
      dir=SwingUtilities.EAST;
    }
 else {
      dir=SwingUtilities.NORTH;
    }
  }
 else {
    if (-xDiff > yDiff) {
      dir=SwingUtilities.WEST;
    }
 else {
      dir=SwingUtilities.SOUTH;
    }
  }
  return dir;
}

Fixed version (ground truth):
/** 
 * Return the direction between two points who differ by the given amounts.  The direction returned is restricted to the closest orthogonal direction.  The integer returned is from SwingUtilities.
 */
private int getManhattanDirection(double xDiff,double yDiff){
  int dir;
  if ((xDiff > 0) && (yDiff > 0)) {
    if (xDiff > yDiff) {
      dir=SwingConstants.EAST;
    }
 else {
      dir=SwingConstants.SOUTH;
    }
  }
 else   if ((xDiff < 0) && (yDiff < 0)) {
    if (xDiff > yDiff) {
      dir=SwingConstants.NORTH;
    }
 else {
      dir=SwingConstants.WEST;
    }
  }
 else   if (xDiff > 0) {
    if (xDiff > -yDiff) {
      dir=SwingConstants.EAST;
    }
 else {
      dir=SwingConstants.NORTH;
    }
  }
 else {
    if (-xDiff > yDiff) {
      dir=SwingConstants.WEST;
    }
 else {
      dir=SwingConstants.SOUTH;
    }
  }
  return dir;
}
Program: 74738
Project: 74738
Buggy source:
public void mouseDragged(MouseEvent evt){
  if ((_target != null) && ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0)) {
    setPosition(evt.getX(),evt.getY());
  }
}

Fixed version (ground truth):
public void mouseDragged(MouseEvent evt){
  if ((_target != null) && ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
    setPosition(evt.getX(),evt.getY());
  }
}
Program: 74739
Project: 74739
Buggy source:
public void mousePressed(MouseEvent evt){
  if ((_target != null) && ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0)) {
    setPosition(evt.getX(),evt.getY());
  }
}

Fixed version (ground truth):
public void mousePressed(MouseEvent evt){
  if ((_target != null) && ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
    setPosition(evt.getX(),evt.getY());
  }
}
Program: 74740
Project: 74740
Buggy source:
public void mouseDragged(MouseEvent evt){
  if ((_target != null) && ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)) {
    setScale(evt.getX(),evt.getY());
  }
}

Fixed version (ground truth):
public void mouseDragged(MouseEvent evt){
  if ((_target != null) && ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0)) {
    setScale(evt.getX(),evt.getY());
  }
}
Program: 74741
Project: 74741
Buggy source:
public void mousePressed(MouseEvent evt){
  if ((_target != null) && ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)) {
    setPosition(evt.getX(),evt.getY());
    origin=evt.getPoint();
    JCanvas canvas=((JCanvas)_target.getView());
    TransformContext context=canvas.getCanvasPane().getTransformContext();
    transformOrigin=(AffineTransform)context.getTransform().clone();
    Dimension viewSize=_target.getView().getSize();
    Rectangle viewRect=new Rectangle(0,0,viewSize.width,viewSize.height);
    Rectangle myRect=_getInsetBounds();
    AffineTransform forward=CanvasUtilities.computeFitTransform(viewRect,myRect);
    double xScaled=(origin.getX() - myRect.getX()) / forward.getScaleX();
    double yScaled=(origin.getY() - myRect.getY()) / forward.getScaleY();
    scaled=new Point2D.Double(xScaled,yScaled);
    try {
      context.getInverseTransform().transform(scaled,scaled);
    }
 catch (    Exception ex) {
      ex.printStackTrace();
    }
  }
}

Fixed version (ground truth):
public void mousePressed(MouseEvent evt){
  if ((_target != null) && ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0)) {
    setPosition(evt.getX(),evt.getY());
    origin=evt.getPoint();
    JCanvas canvas=((JCanvas)_target.getView());
    TransformContext context=canvas.getCanvasPane().getTransformContext();
    transformOrigin=(AffineTransform)context.getTransform().clone();
    Dimension viewSize=_target.getView().getSize();
    Rectangle viewRect=new Rectangle(0,0,viewSize.width,viewSize.height);
    Rectangle myRect=_getInsetBounds();
    AffineTransform forward=CanvasUtilities.computeFitTransform(viewRect,myRect);
    double xScaled=(origin.getX() - myRect.getX()) / forward.getScaleX();
    double yScaled=(origin.getY() - myRect.getY()) / forward.getScaleY();
    scaled=new Point2D.Double(xScaled,yScaled);
    try {
      context.getInverseTransform().transform(scaled,scaled);
    }
 catch (    Exception ex) {
      ex.printStackTrace();
    }
  }
}
Program: 74742
Project: 74742
Buggy source:
/** 
 * Set the line width. If the line width is less than or equal to zero, the stroke will be removed.
 */
public void setLineWidth(float lineWidth){
  if (lineWidth <= 0.0) {
    stroke=null;
  }
 else {
    if ((stroke == null) || (lineWidth != ((BasicStroke)stroke).getLineWidth())) {
      stroke=PaintedPath.getStroke(lineWidth);
    }
  }
}

Fixed version (ground truth):
/** 
 * Set the line width. If the line width is less than or equal to zero, the stroke will be removed.
 */
public void setLineWidth(float lineWidth){
  if (lineWidth <= 0.0) {
    stroke=null;
  }
 else {
    if ((stroke == null) || (lineWidth != ((BasicStroke)stroke).getLineWidth())) {
      stroke=AbstractPaintedGraphic.getStroke(lineWidth);
    }
  }
}
Program: 74743
Project: 74743
Buggy source:
/** 
 * remove an SVGRenderingListener
 * @param listener SVGRenderingListener
 */
public void removeSVGRenderingListener(SVGRenderingListener listener){
  if (listener == null)   return;
  if (svgrListenerList.contains(listener)) {
    svgrListenerList.remove(listener);
  }
}

Fixed version (ground truth):
/** 
 * remove an SVGRenderingListener
 * @param listener SVGRenderingListener
 */
public void removeSVGRenderingListener(SVGRenderingListener listener){
  if (listener == null) {
    return;
  }
  if (svgrListenerList.contains(listener)) {
    svgrListenerList.remove(listener);
  }
}
Program: 74744
Project: 74744
Buggy source:
private void _notifySVGRenderingListeners(){
  Iterator it=svgrListenerList.iterator();
  while (it.hasNext()) {
    SVGRenderingListener l=(SVGRenderingListener)(it.next());
    if (l != null)     l.svgRenderingComplete();
  }
}

Fixed version (ground truth):
private void _notifySVGRenderingListeners(){
  Iterator it=svgrListenerList.iterator();
  while (it.hasNext()) {
    SVGRenderingListener l=(SVGRenderingListener)(it.next());
    if (l != null) {
      l.svgRenderingComplete();
    }
  }
}
Program: 74745
Project: 74745
Buggy source:
public Dimension getPreferredSize(){
  Dimension s=super.getPreferredSize();
  if (s.width > screenSize.width)   s.width=screenSize.width;
  if (s.height > screenSize.height)   s.height=screenSize.height;
  return s;
}

Fixed version (ground truth):
public Dimension getPreferredSize(){
  Dimension s=super.getPreferredSize();
  if (s.width > screenSize.width) {
    s.width=screenSize.width;
  }
  if (s.height > screenSize.height) {
    s.height=screenSize.height;
  }
  return s;
}
Program: 74746
Project: 74746
Buggy source:
/** 
 * Create a painted object from the given valid SVG DOM document.
 * @param doc valid <code>org.w3c.dom.Document</code> containing SVG to berendered
 */
public SVGPaintedObject(Document doc){
  this.svgDoc=(SVGDocument)doc;
  svgComponent=new JSVGComponent(null,false,false){
    Dimension screenSize;
{
      screenSize=Toolkit.getDefaultToolkit().getScreenSize();
      setMaximumSize(screenSize);
      setPreferredSize(screenSize);
    }
    public Dimension getPreferredSize(){
      Dimension s=super.getPreferredSize();
      if (s.width > screenSize.width)       s.width=screenSize.width;
      if (s.height > screenSize.height)       s.height=screenSize.height;
      return s;
    }
    /** 
 * This method is called when the component knows the desired size of the window (based on width/height of outermost SVG element). We override it so we can call container.doLayout() to size this component correctly
 * @param d Dimension
 */
    public void setMySize(    Dimension d){
      setPreferredSize(d);
      invalidate();
      container.doLayout();
    }
  }
;
  _addListeners();
  container.setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
  container.add(svgComponent);
  container.doLayout();
  svgComponent.setRecenterOnResize(true);
  svgComponent.setDoubleBuffered(false);
  svgComponent.setDoubleBufferedRendering(false);
  svgComponent.setIgnoreRepaint(true);
  svgComponent.setDocumentState(JSVGComponent.ALWAYS_STATIC);
  svgComponent.setSVGDocument(svgDoc);
}

Fixed version (ground truth):
/** 
 * Create a painted object from the given valid SVG DOM document.
 * @param doc valid <code>org.w3c.dom.Document</code> containing SVG to berendered
 */
public SVGPaintedObject(Document doc){
  this.svgDoc=(SVGDocument)doc;
  svgComponent=new JSVGComponent(null,false,false){
    Dimension screenSize;
{
      screenSize=Toolkit.getDefaultToolkit().getScreenSize();
      setMaximumSize(screenSize);
      setPreferredSize(screenSize);
    }
    public Dimension getPreferredSize(){
      Dimension s=super.getPreferredSize();
      if (s.width > screenSize.width) {
        s.width=screenSize.width;
      }
      if (s.height > screenSize.height) {
        s.height=screenSize.height;
      }
      return s;
    }
    /** 
 * This method is called when the component knows the desired size of the window (based on width/height of outermost SVG element). We override it so we can call container.doLayout() to size this component correctly
 * @param d Dimension
 */
    public void setMySize(    Dimension d){
      setPreferredSize(d);
      invalidate();
      container.doLayout();
    }
  }
;
  _addListeners();
  container.setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
  container.add(svgComponent);
  container.doLayout();
  svgComponent.setRecenterOnResize(true);
  svgComponent.setDoubleBuffered(false);
  svgComponent.setDoubleBufferedRendering(false);
  svgComponent.setIgnoreRepaint(true);
  svgComponent.setDocumentState(JSVGComponent.ALWAYS_STATIC);
  svgComponent.setSVGDocument(svgDoc);
}
Program: 74747
Project: 74747
Buggy source:
/** 
 * add a listener to receive a callback after Batik has finished rendering the SVG document
 * @param listener SVGRenderingListener
 */
public void addSVGRenderingListener(SVGRenderingListener listener){
  if (listener == null)   return;
  svgrListenerList.add(listener);
}

Fixed version (ground truth):
/** 
 * add a listener to receive a callback after Batik has finished rendering the SVG document
 * @param listener SVGRenderingListener
 */
public void addSVGRenderingListener(SVGRenderingListener listener){
  if (listener == null) {
    return;
  }
  svgrListenerList.add(listener);
}
Program: 74748
Project: 74748
Buggy source:
/** 
 * Paint the shape. Implementations are expected to redraw the entire object. Whether or not the paint overwrites fields in the graphics context such as the current paint, stroke, and composite, depends on the implementing class.
 * @param g2d Graphics2D
 */
public void paint(Graphics2D g2d){
  GraphicsNode gNode=svgComponent.getGraphicsNode();
  if (gNode != null)   gNode.paint(g2d);
}

Fixed version (ground truth):
/** 
 * Paint the shape. Implementations are expected to redraw the entire object. Whether or not the paint overwrites fields in the graphics context such as the current paint, stroke, and composite, depends on the implementing class.
 * @param g2d Graphics2D
 */
public void paint(Graphics2D g2d){
  GraphicsNode gNode=svgComponent.getGraphicsNode();
  if (gNode != null) {
    gNode.paint(g2d);
  }
}
Program: 74749
Project: 74749
Buggy source:
/** 
 * Get the bounding box of the object when painted. Implementations of this method should take account of the thickness of the stroke, if there is one.
 * @return Rectangle2D bounding box
 */
public Rectangle2D getBounds(){
  if (svgBounds == null)   svgBounds=_DEFAULT_SVG_BOUNDS;
  return svgBounds;
}

Fixed version (ground truth):
/** 
 * Get the bounding box of the object when painted. Implementations of this method should take account of the thickness of the stroke, if there is one.
 * @return Rectangle2D bounding box
 */
public Rectangle2D getBounds(){
  if (svgBounds == null) {
    svgBounds=_DEFAULT_SVG_BOUNDS;
  }
  return svgBounds;
}
Program: 74753
Project: 74753
Buggy source:
/** 
 * Generate a new random number.
 * @exception IllegalActionException If parameter values are incorrect.
 */
protected void _generateRandomNumber() throws IllegalActionException {
  long[] sourceValues=new long[populations.getWidth()];
  long sourceTotal=0;
  for (int i=0; i < sourceValues.length; i++) {
    sourceValues[i]=((LongToken)populations.get(i)).longValue();
    if (sourceValues[i] < 0)     throw new IllegalActionException(this,"String_Node_Str" + i + "String_Node_Str");
    sourceTotal+=sourceValues[i];
  }
  int trialsRemaining=((IntToken)trials.getToken()).intValue();
  long sourcePool=sourceTotal;
  _current=new IntToken[sourceValues.length];
  for (int i=0; i < _current.length; i++) {
    int selected=0;
    if ((trialsRemaining > 0) && (sourceValues[i] > 0)) {
      double p=(double)sourceValues[i] / (double)sourcePool;
      if (p < 1.0) {
        selected=_generator.nextInt(trialsRemaining,p);
      }
 else {
        selected=trialsRemaining;
      }
    }
    _current[i]=new IntToken(selected);
    trialsRemaining-=selected;
    sourcePool-=sourceValues[i];
  }
}

Fixed version (ground truth):
/** 
 * Generate a new random number.
 * @exception IllegalActionException If parameter values are incorrect.
 */
protected void _generateRandomNumber() throws IllegalActionException {
  long[] sourceValues=new long[populations.getWidth()];
  long sourceTotal=0;
  for (int i=0; i < sourceValues.length; i++) {
    sourceValues[i]=((LongToken)populations.get(i)).longValue();
    if (sourceValues[i] < 0) {
      throw new IllegalActionException(this,"String_Node_Str" + i + "String_Node_Str");
    }
    sourceTotal+=sourceValues[i];
  }
  int trialsRemaining=((IntToken)trials.getToken()).intValue();
  long sourcePool=sourceTotal;
  _current=new IntToken[sourceValues.length];
  for (int i=0; i < _current.length; i++) {
    int selected=0;
    if ((trialsRemaining > 0) && (sourceValues[i] > 0)) {
      double p=(double)sourceValues[i] / (double)sourcePool;
      if (p < 1.0) {
        selected=_generator.nextInt(trialsRemaining,p);
      }
 else {
        selected=trialsRemaining;
      }
    }
    _current[i]=new IntToken(selected);
    trialsRemaining-=selected;
    sourcePool-=sourceValues[i];
  }
}
Program: 74754
Project: 74754
Buggy source:
/** 
 * Specify the container in which the slider should be displayed. An instance of JSlider will be added to that container. This method needs to be called before the first call to initialize(). Otherwise, an instance of JSlider will be placed in its own frame. The slider is also placed in its own frame if this method is called with a null argument. The background of the slider is set equal to that of the container (unless it is null).
 * @param container The container into which to place the slider.
 */
public void place(Container container){
  int min=-10;
  int max=10;
  try {
    min=((IntToken)minimum.getToken()).intValue();
    max=((IntToken)maximum.getToken()).intValue();
  }
 catch (  IllegalActionException ex) {
  }
  _container=container;
  slider=new JSlider(JSlider.HORIZONTAL,min,max,(min + max) / 2);
  slider.addChangeListener(this);
  _panel=new JPanel();
  _panel.add(slider);
  if (_container == null) {
    _frame=new JFrame(getFullName());
    _frame.getContentPane().add(_panel);
  }
 else {
    _container.add(_panel);
    _panel.setBackground(null);
    _panel.setBorder(new EmptyBorder(10,10,10,10));
    _panel.setBorder(new LineBorder(Color.black));
  }
  String titleSpec=title.getExpression();
  if (!titleSpec.trim().equals("String_Node_Str")) {
    _panel.setBorder(BorderFactory.createTitledBorder(titleSpec));
  }
  slider.setBackground(null);
  slider.setMajorTickSpacing(10);
  slider.setMinorTickSpacing(1);
  slider.setPaintTicks(true);
  slider.setPaintLabels(true);
}

Fixed version (ground truth):
/** 
 * Specify the container in which the slider should be displayed. An instance of JSlider will be added to that container. This method needs to be called before the first call to initialize(). Otherwise, an instance of JSlider will be placed in its own frame. The slider is also placed in its own frame if this method is called with a null argument. The background of the slider is set equal to that of the container (unless it is null).
 * @param container The container into which to place the slider.
 */
public void place(Container container){
  int min=-10;
  int max=10;
  try {
    min=((IntToken)minimum.getToken()).intValue();
    max=((IntToken)maximum.getToken()).intValue();
  }
 catch (  IllegalActionException ex) {
  }
  _container=container;
  slider=new JSlider(SwingConstants.HORIZONTAL,min,max,(min + max) / 2);
  slider.addChangeListener(this);
  _panel=new JPanel();
  _panel.add(slider);
  if (_container == null) {
    _frame=new JFrame(getFullName());
    _frame.getContentPane().add(_panel);
  }
 else {
    _container.add(_panel);
    _panel.setBackground(null);
    _panel.setBorder(new EmptyBorder(10,10,10,10));
    _panel.setBorder(new LineBorder(Color.black));
  }
  String titleSpec=title.getExpression();
  if (!titleSpec.trim().equals("String_Node_Str")) {
    _panel.setBorder(BorderFactory.createTitledBorder(titleSpec));
  }
  slider.setBackground(null);
  slider.setMajorTickSpacing(10);
  slider.setMinorTickSpacing(1);
  slider.setPaintTicks(true);
  slider.setPaintLabels(true);
}