nus-yam/ex-repair huggingface dataset:
Program: 74117
Project: 74117
Buggy source:
int _getThenIncrementCurrentSharedMemoryAddress(TypedIOPort port) throws IllegalActionException {
  String type=targetType(port.getType());
  int portWidth=port.getWidth();
  int offset=0;
  if (type.equals("String_Node_Str") || type.equals("String_Node_Str") || type.equals("String_Node_Str")|| type.equals("String_Node_Str")) {
    offset=4 * portWidth;
  }
 else   if (type.equals("String_Node_Str") || type.equals("String_Node_Str")) {
    offset=8 * portWidth;
  }
 else   if (type.equals("String_Node_Str")) {
    offset=1 * portWidth;
  }
 else   if (type.equals("String_Node_Str")) {
    offset=2 * portWidth;
  }
 else {
    offset=8 * portWidth;
  }
  int currentSharedMemoryAddress=(nextSharedMemoryAddress / offset) * offset;
  nextSharedMemoryAddress=currentSharedMemoryAddress + offset;
  if (nextSharedMemoryAddress >= 0x40000000) {
    throw new IllegalActionException("String_Node_Str");
  }
  return currentSharedMemoryAddress;
}

Fixed version (ground truth):
int _getThenIncrementCurrentSharedMemoryAddress(TypedIOPort port) throws IllegalActionException {
  String type=targetType(port.getType());
  int portWidth=port.getWidth();
  int offset=0;
  if (type.equals("String_Node_Str") || type.equals("String_Node_Str") || type.equals("String_Node_Str")|| type.equals("String_Node_Str")) {
    offset=4 * portWidth;
  }
 else   if (type.equals("String_Node_Str") || type.equals("String_Node_Str")) {
    offset=8 * portWidth;
  }
 else   if (type.equals("String_Node_Str")) {
    offset=1 * portWidth;
  }
 else   if (type.equals("String_Node_Str")) {
    offset=2 * portWidth;
  }
 else {
    offset=8 * portWidth;
  }
  int currentSharedMemoryAddress=(nextSharedMemoryAddress + offset - 1) / offset * offset;
  nextSharedMemoryAddress=currentSharedMemoryAddress + offset;
  if (nextSharedMemoryAddress >= 0x40000000) {
    throw new IllegalActionException("String_Node_Str");
  }
  return currentSharedMemoryAddress;
}
Program: 74119
Project: 74119
Buggy source:
/** 
 * Construct a depth-first firing schedule recursively. It first creates a new firing to add to the given schedule for the given actor. Then, it make a recursive call on each of the successors (sinks connected to the given actor). The successors are specified in the given directed acyclic graph constructed previously. If the given actor is null, return and do nothing.
 * @param schedule The given schedule to add the firings to.
 * @param dag The given directed acyclic graph of the model.
 * @param actorToAdd The given actor to add a firing to theschedule.
 */
private void _constructDepthFirstSchedule(Schedule schedule,DirectedAcyclicGraph dag,Object actorToAdd){
  if (actorToAdd == null) {
    return;
  }
  Firing firing=new Firing();
  firing.setActor((Actor)actorToAdd);
  schedule.add(firing);
  for (  Object actor : dag.successors(dag.node(actorToAdd))) {
    _constructDepthFirstSchedule(schedule,dag,actor);
  }
}

Fixed version (ground truth):
/** 
 * Construct a depth-first firing schedule recursively. It first creates a new firing to add to the given schedule for the given actor. Then, it make a recursive call on each of the successors (sinks connected to the given actor). The successors are specified in the given directed acyclic graph constructed previously. If the given actor is null, return and do nothing.
 * @param schedule The given schedule to add the firings to.
 * @param dag The given directed acyclic graph of the model.
 * @param actorToAdd The given actor to add a firing to theschedule.
 */
private void _constructDepthFirstSchedule(Schedule schedule,DirectedAcyclicGraph dag,Object actorToAdd){
  if (actorToAdd == null) {
    return;
  }
  Firing firing=new Firing();
  firing.setActor((Actor)actorToAdd);
  schedule.add(firing);
  for (  Object node : dag.successors(dag.node(actorToAdd))) {
    _constructDepthFirstSchedule(schedule,dag,((Node)node).getWeight());
  }
}
Program: 74120
Project: 74120
Buggy source:
public void init(GLAutoDrawable gLDrawable){
  _gl=gLDrawable.getGL();
  _gl.glShadeModel(GL.GL_SMOOTH);
  _gl.glClearColor(0.0f,0.0f,0.0f,0.0f);
  _gl.glClearDepth(1.0f);
  _gl.glEnable(GL.GL_DEPTH_TEST);
  _gl.glDepthFunc(GL.GL_LEQUAL);
  _gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT,GL.GL_NICEST);
}

Fixed version (ground truth):
public void init(GLAutoDrawable gLDrawable){
  _gl=gLDrawable.getGL();
  _gl.glEnable(GL.GL_BLEND);
  _gl.glEnable(GL.GL_LINE_SMOOTH);
  _gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA);
  _gl.glLineWidth((float)2.0);
  _gl.glPointSize((float)2.0);
  _gl.glClearColor(0.0f,0.0f,0.0f,0.0f);
  _gl.glColor3f(1.0f,1.0f,1.0f);
  _gl.glLoadIdentity();
}
Program: 74121
Project: 74121
Buggy source:
public void display(GLAutoDrawable gLDrawable){
  try {
    _gl=gLDrawable.getGL();
    _gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    _gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
    _gl.glLoadIdentity();
    _gl.glTranslatef(0.0f,0.0f,-5.0f);
    _gl.glPushMatrix();
    fire();
    _gl.glPopMatrix();
  }
 catch (  IllegalActionException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void display(GLAutoDrawable gLDrawable){
  try {
    _gl=gLDrawable.getGL();
    _gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    _gl.glLoadIdentity();
    _gl.glLineWidth(4.0f);
    _gl.glTranslatef(0.0f,0.0f,-0.45f);
    _gl.glRotatef(-90.0f,1.0f,0.0f,0.0f);
    _gl.glTranslatef(0.0f,0.0f,-3.0f);
    _gl.glPushMatrix();
    _fire();
    _gl.glPopMatrix();
    _gl.glFlush();
  }
 catch (  IllegalActionException e) {
    e.printStackTrace();
  }
}
Program: 74122
Project: 74122
Buggy source:
public void reshape(GLAutoDrawable gLDrawable,int x,int y,int width,int height){
  final GL gl=gLDrawable.getGL();
  if (height <= 0) {
    height=1;
  }
  final float h=(float)width / (float)height;
  gl.glMatrixMode(GL.GL_PROJECTION);
  gl.glLoadIdentity();
  glu.gluPerspective(50.0f,h,1.0,1000.0);
  gl.glMatrixMode(GL.GL_MODELVIEW);
  gl.glLoadIdentity();
}

Fixed version (ground truth):
public void reshape(GLAutoDrawable gLDrawable,int x,int y,int width,int height){
  final GL gl=gLDrawable.getGL();
  if (height <= 0) {
    height=1;
  }
  final float h=(float)width / (float)height;
  gl.glMatrixMode(GL.GL_PROJECTION);
  gl.glLoadIdentity();
  glu.gluPerspective(0.0f,h,1.0,1000.0);
  gl.glMatrixMode(GL.GL_MODELVIEW);
  gl.glLoadIdentity();
}
Program: 74123
Project: 74123
Buggy source:
/** 
 * Make sure that <i>iterationLowerUpperBound</i> milliseconds have elapsed since the last iteration.  Go through the schedule and iterate every actor. If an actor returns false in its prefire(), fire() and postfire() will not be called on it.
 * @exception IllegalActionException If an actor executed by thisdirector returns false in its prefire().
 */
private void _fire() throws IllegalActionException {
  long currentTime=System.currentTimeMillis();
  int frameRate=((IntToken)iterationTimeLowerBound.getToken()).intValue();
  long timeElapsed=currentTime - _lastIterationTime;
  long timeRemaining=frameRate - timeElapsed;
  if (timeRemaining > 0) {
    try {
      java.lang.Thread.sleep(timeRemaining);
    }
 catch (    InterruptedException e) {
    }
  }
  _lastIterationTime=currentTime;
}

Fixed version (ground truth):
/** 
 * Make sure that <i>iterationLowerUpperBound</i> milliseconds have elapsed since the last iteration.  Go through the schedule and iterate every actor. If an actor returns false in its prefire(), fire() and postfire() will not be called on it.
 * @exception IllegalActionException If an actor executed by thisdirector returns false in its prefire().
 */
private void _fire() throws IllegalActionException {
  super.fire();
}
Program: 74127
Project: 74127
Buggy source:
/** 
 * Generate include files. FIXME: State what is included.
 * @return The #include statements, surrounded by #ifndef to ensurethat the files are included only once.
 * @exception IllegalActionException If the adapter class for some actorcannot be found.
 */
protected String _generateIncludeFiles() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  CodeGeneratorAdapter compositeActorAdapter=getAdapter(getContainer());
  Set includingFiles=compositeActorAdapter.getHeaderFiles();
  includingFiles.add("String_Node_Str");
  if (_isTopLevel() && ((BooleanToken)measureTime.getToken()).booleanValue()) {
    includingFiles.add("String_Node_Str");
  }
  if (!_isTopLevel()) {
    includingFiles.add("String_Node_Str" + _sanitizedModelName + "String_Node_Str");
    includingFiles.addAll(((CCodeGeneratorAdapterStrategy)compositeActorAdapter.getStrategy()).getJVMHeaderFiles());
  }
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  for (  String file : (Set<String>)includingFiles) {
    code.append("String_Node_Str" + file.substring(1,file.length() - 3).replace('/','_').toUpperCase() + "String_Node_Str"+ _eol+ "String_Node_Str"+ file+ _eol+ "String_Node_Str"+ _eol);
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate include files. FIXME: State what is included.
 * @return The #include statements, surrounded by #ifndef to ensurethat the files are included only once.
 * @exception IllegalActionException If the adapter class for some actorcannot be found.
 */
protected String _generateIncludeFiles() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  CodeGeneratorAdapter compositeActorAdapter=getAdapter(getContainer());
  Set<String> includingFiles=compositeActorAdapter.getHeaderFiles();
  includingFiles.add("String_Node_Str");
  if (_isTopLevel() && ((BooleanToken)measureTime.getToken()).booleanValue()) {
    includingFiles.add("String_Node_Str");
  }
  if (!_isTopLevel()) {
    includingFiles.add("String_Node_Str" + _sanitizedModelName + "String_Node_Str");
    includingFiles.addAll(((CCodeGeneratorAdapterStrategy)compositeActorAdapter.getStrategy()).getJVMHeaderFiles());
  }
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  for (  String file : (Set<String>)includingFiles) {
    code.append("String_Node_Str" + file.substring(1,file.length() - 3).replace('/','_').toUpperCase() + "String_Node_Str"+ _eol+ "String_Node_Str"+ file+ _eol+ "String_Node_Str"+ _eol);
  }
  return code.toString();
}
Program: 74128
Project: 74128
Buggy source:
/** 
 * Update the _sanitizedActorName variable. Consider calling this method each time _version is updated.
 */
private void _updateSanitizedActorName(){
  _sanitizedActorName=StringUtilities.sanitizeName(getFullName());
  if (_sanitizedActorName.charAt(0) == '_') {
    _sanitizedActorName=_sanitizedActorName.replaceFirst("String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Update the _sanitizedActorName variable. Consider calling this method each time _version is updated.
 */
private void _updateSanitizedActorName(){
  _sanitizedActorName=StringUtilities.sanitizeName(getFullName());
  _sanitizedActorName=_sanitizedActorName.replace("String_Node_Str","String_Node_Str") + _version;
}
Program: 74129
Project: 74129
Buggy source:
public String generateCodeForHasToken(int channel) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  IOPort port=((ptolemy.domains.de.kernel.DEReceiver)getObject()).getContainer();
  code.append("String_Node_Str" + port.getContainer().getName() + "String_Node_Str"+ port.getName()+ "String_Node_Str"+ channel+ "String_Node_Str");
  return code.toString();
}

Fixed version (ground truth):
public String generateCodeForHasToken(int channel) throws IllegalActionException {
  IOPort port=getReceiver().getContainer();
  return "String_Node_Str" + generateName(port) + "String_Node_Str"+ channel+ "String_Node_Str";
}
Program: 74133
Project: 74133
Buggy source:
/** 
 * Generate a variable declaration for the <i>period</i> parameter, if there is one.
 * @return code The generated code.
 * @exception IllegalActionException If the helper class for the modeldirector cannot be found.
 */
public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer variableDeclarations=new StringBuffer();
  Iterator actors=((CompositeActor)_director.getContainer()).deepEntityList().iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    CodeGeneratorHelper helperObject=(CodeGeneratorHelper)_getHelper((NamedObj)actor);
    variableDeclarations.append(helperObject.generateVariableDeclaration());
    variableDeclarations.append(_generatePortVariableDeclarations(actor));
  }
  return variableDeclarations.toString();
}

Fixed version (ground truth):
/** 
 * Generate a variable declaration for the <i>period</i> parameter, if there is one.
 * @return code The generated code.
 * @exception IllegalActionException If the helper class for the modeldirector cannot be found.
 */
public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer variableDeclarations=new StringBuffer();
  Iterator actors=((CompositeActor)_director.getContainer()).deepEntityList().iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    CodeGeneratorHelper helperObject=(CodeGeneratorHelper)_getHelper((NamedObj)actor);
    variableDeclarations.append(helperObject.generateVariableDeclaration());
    List<TypedIOPort> actorPorts=actor.outputPortList();
    if (actorPorts.size() > 0) {
      Iterator portItr=actorPorts.iterator();
      TypedIOPort actorport;
      String type;
      while (portItr.hasNext()) {
        actorport=(TypedIOPort)portItr.next();
        type=targetType(actorport.getType());
        variableDeclarations.append("String_Node_Str" + type + "String_Node_Str"+ _getActorName(actor)+ "String_Node_Str"+ _eol);
      }
    }
    variableDeclarations.append(_generatePortVariableDeclarations(actor));
  }
  return variableDeclarations.toString();
}
Program: 74135
Project: 74135
Buggy source:
/** 
 * This method is similar to the getReference method however it it taylored  for use by a driver method.
 * @param port, the port whose information is desired
 * @param channelAndOffset
 * @param forComposite
 * @param isWrite
 * @param helper, codegerator helper associated with this port
 * @return string containing the port information
 */
public String driverGetReference(TypedIOPort port,String[] channelAndOffset,boolean forComposite,boolean isWrite,CodeGeneratorHelper helper) throws IllegalActionException {
  Actor actor=(Actor)port.getContainer();
  Director director=actor.getDirector();
  if (port.isOutput() || ((port.isInput() && (actor instanceof CompositeActor) && (director != null)))) {
    return "String_Node_Str" + CodeGeneratorHelper.generateName(port) + "String_Node_Str";
  }
 else   return super.getReference(port,channelAndOffset,forComposite,isWrite,helper);
}

Fixed version (ground truth):
/** 
 * This method is similar to the getReference method however it it taylored  for use by a driver method.
 * @param port, the port whose information is desired
 * @param channelAndOffset
 * @param forComposite
 * @param isWrite
 * @param helper, codegerator helper associated with this port
 * @return string containing the port information
 */
public String driverGetReference(TypedIOPort port,String[] channelAndOffset,boolean forComposite,boolean isWrite,CodeGeneratorHelper helper) throws IllegalActionException {
  Actor actor=(Actor)port.getContainer();
  Director director=actor.getDirector();
  System.out.println("String_Node_Str" + actor.getFullName() + "String_Node_Str"+ director.getFullName());
  if (port.isOutput() || ((port.isInput() && (actor instanceof CompositeActor) && (director != null)&& (director.getFullName().contains("String_Node_Str") == false)&& (director.getFullName().contains("String_Node_Str") == false)))) {
    return "String_Node_Str" + CodeGeneratorHelper.generateName(port) + "String_Node_Str";
  }
 else   return super.getReference(port,channelAndOffset,forComposite,isWrite,helper);
}
Program: 74137
Project: 74137
Buggy source:
/** 
 * A small helper function that will convert a manifest into an array of bytes.
 */
private byte[] _serialiseManifest(Manifest manifest) throws IOException {
  ByteArrayOutputStream baos=null;
  try {
    baos=new ByteArrayOutputStream();
    manifest.write(baos);
    baos.flush();
  }
  finally {
    if (baos != null) {
      baos.close();
    }
  }
  return baos.toByteArray();
}

Fixed version (ground truth):
/** 
 * A small helper function that will convert a manifest into an array of bytes.
 */
private static byte[] _serialiseManifest(Manifest manifest) throws IOException {
  ByteArrayOutputStream baos=null;
  try {
    baos=new ByteArrayOutputStream();
    manifest.write(baos);
    baos.flush();
  }
  finally {
    if (baos != null) {
      baos.close();
    }
  }
  return baos.toByteArray();
}
Program: 74139
Project: 74139
Buggy source:
/** 
 * Construct a jar signer.
 * @param alias The alias for the signing key.
 * @param privateKey The private key to sign with.
 * @param certChain The certificate chain.
 */
public JarSigner(String alias,PrivateKey privateKey,X509Certificate[] certChain){
  _alias=alias;
  _privateKey=privateKey;
  _certChain=certChain;
}

Fixed version (ground truth):
/** 
 * Construct a jar signer.
 * @param alias The alias for the signing key.
 * @param privateKey The private key to sign with.
 * @param certChain The certificate chain.
 */
public JarSigner(String alias,PrivateKey privateKey,X509Certificate[] certChain){
  _alias=alias;
  _privateKey=privateKey;
  System.arraycopy(certChain,0,_certChain,0,certChain.length);
}
Program: 74140
Project: 74140
Buggy source:
public String _generateActorCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  ptolemy.domains.fsm.kernel.FSMDirector director=(ptolemy.domains.fsm.kernel.FSMDirector)getComponent();
  ptolemy.domains.fsm.kernel.FSMActor controller=director.getController();
  int depth=1;
  Iterator states=controller.entityList().iterator();
  int stateCount=0;
  depth++;
  while (states.hasNext()) {
    stateCount++;
    depth++;
    State state=(State)states.next();
    Actor[] actors=state.getRefinement();
    if (actors != null) {
      for (int i=0; i < actors.length; i++) {
        CodeGeneratorHelper actorHelper=(CodeGeneratorHelper)_getHelper((NamedObj)actors[i]);
        code.append("String_Node_Str" + _getActorName(actors[i]) + "String_Node_Str");
        code.append(actorHelper.generateFireCode());
        code.append(actorHelper.generateTypeConvertFireCode());
        code.append(_eol + "String_Node_Str" + _eol);
      }
    }
  }
  return code.toString();
}

Fixed version (ground truth):
public String _generateActorCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  ptolemy.domains.fsm.kernel.FSMDirector director=(ptolemy.domains.fsm.kernel.FSMDirector)getComponent();
  ptolemy.domains.fsm.kernel.FSMActor controller=director.getController();
  int depth=1;
  Iterator states=controller.deepEntityList().iterator();
  int stateCount=0;
  depth++;
  while (states.hasNext()) {
    stateCount++;
    depth++;
    State state=(State)states.next();
    Actor[] actors=state.getRefinement();
    Set<Actor> actorsSet=new HashSet();
    ;
    if (actors != null) {
      for (int i=0; i < actors.length; i++) {
        actorsSet.add(actors[i]);
      }
    }
    if (actors != null) {
      Iterator actorIterator=actorsSet.iterator();
      Actor actors2;
      while (actorIterator.hasNext()) {
        actors2=(Actor)actorIterator.next();
        CodeGeneratorHelper actorHelper=(CodeGeneratorHelper)_getHelper((NamedObj)actors2);
        code.append("String_Node_Str" + _getActorName(actors2) + "String_Node_Str");
        code.append(actorHelper.generateFireCode());
        code.append(actorHelper.generateTypeConvertFireCode());
        code.append(_eol + "String_Node_Str" + _eol);
      }
    }
  }
  return code.toString();
}
Program: 74141
Project: 74141
Buggy source:
public String generatePreinitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(super.generatePreinitializeCode());
  code.append(_generateActorCode());
  return code.toString();
}

Fixed version (ground truth):
public String generatePreinitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(super.generatePreinitializeCode());
  code.append(_eol + "String_Node_Str" + _eol);
  code.append(_generateActorCode());
  code.append(_eol + "String_Node_Str" + _eol);
  return code.toString();
}
Program: 74143
Project: 74143
Buggy source:
private String _generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  System.out.println("String_Node_Str");
  code.append("String_Node_Str");
  if (!_isTopDirectorFSM()) {
    code.append(_eol + "String_Node_Str" + _eol);
  }
  code.append("String_Node_Str" + _eol);
  code.append(generateMyThreads());
  code.append("String_Node_Str" + _eol);
  code.append("String_Node_Str" + _eol);
  if (_isTopDirectorFSM()) {
    code.append(_eol + "String_Node_Str" + _eol);
  }
  return code.toString();
}

Fixed version (ground truth):
protected String _generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  System.out.println("String_Node_Str");
  code.append("String_Node_Str");
  if (!_isTopDirectorFSM()) {
    code.append(_eol + "String_Node_Str" + _eol);
  }
  code.append("String_Node_Str" + _eol);
  code.append(generateMyThreads());
  code.append("String_Node_Str" + _eol);
  code.append("String_Node_Str" + _eol);
  if (_isTopDirectorFSM()) {
    code.append(_eol + "String_Node_Str" + _eol);
  }
  return code.toString();
}
Program: 74146
Project: 74146
Buggy source:
/** 
 * Generate the type conversion fire code. This method is called by the Director to append necessary fire code to handle type conversion.
 * @param forComposite True if we are generating code for a composite.
 * @return The generated code.
 * @exception IllegalActionException Not thrown in this base class.
 */
public String _generateTypeConvertFireCode(IOPort source,IOPort sink) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  System.out.println("String_Node_Str");
  return code.toString();
}

Fixed version (ground truth):
/** 
 * This method simply overwrites the base class method and returns a blank string
 * @exception IllegalActionException Not thrown in this base class.
 */
public String _generateTypeConvertFireCode(IOPort source,IOPort sink) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  System.out.println("String_Node_Str");
  return code.toString();
}
Program: 74147
Project: 74147
Buggy source:
/** 
 * Generates the preinitialization code for the Giotto Director which includes generating driver code for all the actors as well as the firefunction code. None of the methods can be inlined in this implementation.
 * @param none
 * @return String containing the preinitialization code.
 */
public String generatePreinitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer(super.generatePreinitializeCode());
  code.append(_eol + _generateInDriverCode());
  code.append(_eol + _generateOutDriverCode());
  code.append(_generateActorsCode());
  if (_isTopDirectorFSM()) {
    code.append(_eol + "String_Node_Str" + _eol);
    code.append(_generateFireCode());
    code.append(_eol + "String_Node_Str" + _eol);
  }
  return processCode(code.toString());
}

Fixed version (ground truth):
/** 
 * Generates the preinitialization code for the Giotto Director which includes generating driver code for all the actors as well as the firefunction code. None of the methods can be inlined in this implementation.
 * @return String containing the preinitialization code.
 */
public String generatePreinitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer(super.generatePreinitializeCode());
  code.append(_eol + _generateInDriverCode());
  code.append(_eol + _generateOutDriverCode());
  code.append(_generateActorsCode());
  if (_isTopDirectorFSM()) {
    code.append(_eol + "String_Node_Str" + _eol);
    code.append(_generateFireCode());
    code.append(_eol + "String_Node_Str" + _eol);
  }
  return processCode(code.toString());
}
Program: 74149
Project: 74149
Buggy source:
/** 
 * @param port, the port whose information is desired
 * @param channelAndOffset
 * @param forComposite
 * @param isWrite
 * @param helper, codegerator helper associated with this port
 * @return string containing the port information
 */
public String getReference(TypedIOPort port,String[] channelAndOffset,boolean forComposite,boolean isWrite,CodeGeneratorHelper helper) throws IllegalActionException {
  if (port.isOutput() && forComposite == false) {
    if (channelAndOffset[0] == "String_Node_Str") {
      channelAndOffset[0]="String_Node_Str";
    }
    return CodeGeneratorHelper.generateName(port);
  }
 else   return super.getReference(port,channelAndOffset,forComposite,isWrite,helper);
}

Fixed version (ground truth):
/** 
 * Returns a reference for this port.
 * @param port
 * @param channelAndOffset
 * @param forComposite
 * @param isWrite
 * @param helper
 * @return string containing the port information
 */
public String getReference(TypedIOPort port,String[] channelAndOffset,boolean forComposite,boolean isWrite,CodeGeneratorHelper helper) throws IllegalActionException {
  if (port.isOutput() && forComposite == false) {
    if (channelAndOffset[0] == "String_Node_Str") {
      channelAndOffset[0]="String_Node_Str";
    }
    return CodeGeneratorHelper.generateName(port);
  }
 else   return super.getReference(port,channelAndOffset,forComposite,isWrite,helper);
}
Program: 74150
Project: 74150
Buggy source:
/** 
 * Construct a new SharedUtilities object.
 */
public SharedUtilities(){
  id=count++;
}

Fixed version (ground truth):
/** 
 * Construct a new SharedUtilities object.
 */
public SharedUtilities(){
  _id=_count++;
}
Program: 74151
Project: 74151
Buggy source:
/** 
 * Return the representation for the SharedUtilities object.
 */
public String toString(){
  String result="String_Node_Str" + id;
  return result;
}

Fixed version (ground truth):
/** 
 * Return the representation for the SharedUtilities object.
 */
public String toString(){
  String result="String_Node_Str" + _id;
  return result;
}
Program: 74152
Project: 74152
Buggy source:
/** 
 * Clear and return the previously recorded errors.
 * @return The previously recorded errors.
 */
public List removeErrors(){
  List result=new ArrayList(_errors);
  _errors.clear();
  return result;
}

Fixed version (ground truth):
/** 
 * Clear and return the previously recorded errors.
 * @return The list of previously recorded errors.
 */
public List removeErrors(){
  List result=new ArrayList(_errors);
  _errors.clear();
  return result;
}
Program: 74153
Project: 74153
Buggy source:
private void createKPorts(KNode knode,List<Port> ports,KPortType portType){
  for (Iterator iterator2=ports.iterator(); iterator2.hasNext(); ) {
    Port port=(Port)iterator2.next();
    KPort kport=KimlLayoutUtil.createInitializedPort();
    KShapeLayout kportlayout=KimlLayoutUtil.getShapeLayout(kport);
    kportlayout.setXpos(0);
    kportlayout.setYpos(0);
    kportlayout.setHeight(5);
    kportlayout.setWidth(5);
    knode.getPorts().add(kport);
    kport.setType(portType);
    LayoutOptions.setPortConstraints(kportlayout,PortConstraints.FIXED_POS);
    _ptolemy2KielerPorts.put(port,kport);
  }
}

Fixed version (ground truth):
private void createKPorts(KNode knode,List<Port> ports,KPortType portType){
  for (Iterator iterator2=ports.iterator(); iterator2.hasNext(); ) {
    Port port=(Port)iterator2.next();
    KPort kport=KimlLayoutUtil.createInitializedPort();
    KShapeLayout kportlayout=KimlLayoutUtil.getShapeLayout(kport);
    kportlayout.setXpos(0);
    kportlayout.setYpos(0);
    kportlayout.setHeight(5);
    kportlayout.setWidth(5);
    knode.getPorts().add(kport);
    kport.setType(portType);
    LayoutOptions.setPortConstraints(kportlayout,PortConstraints.FIXED_POS);
    _ptolemy2KielerPorts.put(port,kport);
    _kieler2PtolemyPorts.put(kport,port);
  }
}
Program: 74154
Project: 74154
Buggy source:
private Relation createRelationWithVertex(double x,double y){
  String relationName=compositeActor.uniqueName("String_Node_Str");
  Relation relation=null;
  try {
    relation=compositeActor.newRelation(relationName);
    Vertex vertex=new Vertex(relation,relationName);
    double[] location={x,y};
    vertex.setLocation(location);
  }
 catch (  IllegalActionException e) {
  }
catch (  NameDuplicationException e) {
  }
  return relation;
}

Fixed version (ground truth):
private String createRelationWithVertex(double x,double y){
  String relationName=compositeActor.uniqueName("String_Node_Str");
  String vertexName=compositeActor.uniqueName("String_Node_Str");
  String moml="String_Node_Str" + relationName + "String_Node_Str"+ "String_Node_Str"+ vertexName+ "String_Node_Str"+ x+ "String_Node_Str"+ y+ "String_Node_Str";
  MoMLChangeRequest request=new MoMLChangeRequest(this,compositeActor,moml);
  request.setUndoable(true);
  compositeActor.requestChange(request);
  return relationName;
}
Program: 74155
Project: 74155
Buggy source:
private void addRelationswithVertices(HyperedgeConnectionTree connectionTree){
  List<KPoint> bendpoints=connectionTree.bendPointList();
  for (  KPoint point : bendpoints) {
    if (point != null) {
      Relation relation=this.createRelationWithVertex(point.getX(),point.getY());
    }
  }
  for (  HyperedgeConnectionTree subtree : connectionTree.subTreeList()) {
    addRelationswithVertices(subtree);
  }
}

Fixed version (ground truth):
private String addRelationswithVertices(HyperedgeConnectionTree connectionTree){
  List<KPoint> bendpoints=connectionTree.bendPointList();
  System.out.println("String_Node_Str" + connectionTree);
  String firstRelationName=null;
  String relationName=null;
  for (  KPoint point : bendpoints) {
    if (point != null) {
      String newRelationName=this.createRelationWithVertex(point.getX(),point.getY());
      if (relationName != null) {
        this.link("String_Node_Str",relationName,"String_Node_Str",newRelationName);
      }
      relationName=newRelationName;
      if (firstRelationName == null) {
        firstRelationName=relationName;
      }
    }
 else {
      KEdge edge=connectionTree.commonEdgeSet().iterator().next();
      Port targetPort=_kieler2PtolemyPorts.get(edge.getTargetPort());
      Port sourcePort=_kieler2PtolemyPorts.get(edge.getSourcePort());
      if (relationName != null) {
        this.link("String_Node_Str",relationName,"String_Node_Str",targetPort.getName(compositeActor));
      }
 else {
        String dummyRelationName=this.createRelation();
        this.link("String_Node_Str",sourcePort.getName(compositeActor),"String_Node_Str",dummyRelationName);
        this.link("String_Node_Str",dummyRelationName,"String_Node_Str",targetPort.getName(compositeActor));
      }
    }
  }
  for (  HyperedgeConnectionTree subtree : connectionTree.subTreeList()) {
    String firstOfChildren=addRelationswithVertices(subtree);
    this.link("String_Node_Str",relationName,"String_Node_Str",firstOfChildren);
  }
  if (connectionTree.subTreeList().isEmpty()) {
    KEdge edge=connectionTree.commonEdgeSet().iterator().next();
    Port targetPort=_kieler2PtolemyPorts.get(edge.getTargetPort());
    if (relationName != null) {
      this.link("String_Node_Str",relationName,"String_Node_Str",targetPort.getName(compositeActor));
    }
  }
  return firstRelationName;
}
Program: 74156
Project: 74156
Buggy source:
/** 
 * Traverses a KNode (supposed to be the graph) and applies all layout information to the ptolemy model.
 * @param kgraph
 */
private void applyLayout(KNode kgraph){
  for (  KNode knode : kgraph.getChildren()) {
    KShapeLayout klayout=KimlLayoutUtil.getShapeLayout(knode);
    kNode2Ptolemy(klayout);
    Object node=_kieler2ptolemyDivaNodes.get(knode);
    LayoutUtilities.place(getLayoutTarget(),node,klayout.getXpos(),klayout.getYpos());
  }
  for (  Set<Relation> relationGroup : _ptolemy2KielerEdges.keySet()) {
    Set<KEdge> kedges=_ptolemy2KielerEdges.get(relationGroup);
    HyperedgeConnectionTree connectionTree=new HyperedgeConnectionTree();
    connectionTree.addAll(kedges);
    addRelationswithVertices(connectionTree);
  }
}

Fixed version (ground truth):
/** 
 * Traverses a KNode (supposed to be the graph) and applies all layout information to the ptolemy model.
 * @param kgraph
 */
private void applyLayout(KNode kgraph){
  GraphModel graph=this.getLayoutTarget().getGraphModel();
  if (graph instanceof ActorGraphModel) {
    for (    KNode knode : kgraph.getChildren()) {
      KShapeLayout klayout=KimlLayoutUtil.getShapeLayout(knode);
      NamedObj namedObj=_kieler2ptolemyEntityNodes.get(knode);
      if (!(namedObj instanceof Attribute))       kNode2Ptolemy(klayout);
      this.setLocation(namedObj,klayout.getXpos(),klayout.getYpos());
    }
    for (    Set<Relation> relationGroup : _ptolemy2KielerEdges.keySet()) {
      Set<KEdge> kedges=_ptolemy2KielerEdges.get(relationGroup);
      for (      Relation oldRelation : relationGroup) {
        this.removeRelation(oldRelation);
      }
      HyperedgeConnectionTree connectionTree=new HyperedgeConnectionTree();
      connectionTree.addAll(kedges);
      String firstRelation=addRelationswithVertices(connectionTree);
      if (firstRelation != null) {
        KEdge edge=kedges.iterator().next();
        Port port=_kieler2PtolemyPorts.get(edge.getSourcePort());
        this.link("String_Node_Str",port.getName(compositeActor),"String_Node_Str",firstRelation);
      }
    }
  }
}
Program: 74158
Project: 74158
Buggy source:
public String generateOutputVariableDeclaration() throws IllegalActionException {
  return null;
}

Fixed version (ground truth):
public String generateOutputVariableDeclaration(CodeGeneratorAdapter target) throws IllegalActionException {
  return null;
}
Program: 74159
Project: 74159
Buggy source:
public String generateInputVariableDeclaration() throws IllegalActionException {
  return null;
}

Fixed version (ground truth):
public String generateInputVariableDeclaration(CodeGeneratorAdapter target) throws IllegalActionException {
  return null;
}
Program: 74160
Project: 74160
Buggy source:
/** 
 * Generate input variable declarations.
 * @return a String that declares input variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
@Override public String generateInputVariableDeclaration() throws IllegalActionException {
  boolean dynamicReferencesAllowed=((BooleanToken)getCodeGenerator().allowDynamicMultiportReference.getToken()).booleanValue();
  StringBuffer code=new StringBuffer();
  Iterator<?> inputPorts=((Actor)getComponent()).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
    if (!inputPort.isOutsideConnected()) {
      continue;
    }
    code.append("String_Node_Str" + targetType(inputPort.getType()) + "String_Node_Str"+ CodeGeneratorAdapterStrategy.generateName(inputPort));
    int bufferSize=_ports.getBufferSize(inputPort);
    if (inputPort.isMultiport()) {
      code.append("String_Node_Str" + inputPort.getWidth() + "String_Node_Str");
      if (bufferSize > 1 || dynamicReferencesAllowed) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
    }
 else {
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
    }
    code.append("String_Node_Str" + _eol);
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate input variable declarations.
 * @return a String that declares input variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
@Override public String generateInputVariableDeclaration(CodeGeneratorAdapter target) throws IllegalActionException {
  boolean dynamicReferencesAllowed=((BooleanToken)getCodeGenerator().allowDynamicMultiportReference.getToken()).booleanValue();
  StringBuffer code=new StringBuffer();
  Iterator<?> inputPorts=((Actor)target.getComponent()).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
    if (!inputPort.isOutsideConnected()) {
      continue;
    }
    code.append("String_Node_Str" + targetType(inputPort.getType()) + "String_Node_Str"+ CodeGeneratorAdapterStrategy.generateName(inputPort));
    int bufferSize=_ports.getBufferSize(inputPort);
    if (inputPort.isMultiport()) {
      code.append("String_Node_Str" + inputPort.getWidth() + "String_Node_Str");
      if (bufferSize > 1 || dynamicReferencesAllowed) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
    }
 else {
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
    }
    code.append("String_Node_Str" + _eol);
  }
  return code.toString();
}
Program: 74161
Project: 74161
Buggy source:
/** 
 * Generate output variable declarations.
 * @return a String that declares output variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
@Override public String generateOutputVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> outputPorts=((Actor)getComponent()).outputPortList().iterator();
  while (outputPorts.hasNext()) {
    TypedIOPort outputPort=(TypedIOPort)outputPorts.next();
    if (!outputPort.isOutsideConnected() || outputPort.isInsideConnected()) {
      code.append("String_Node_Str" + targetType(outputPort.getType()) + "String_Node_Str"+ CodeGeneratorAdapterStrategy.generateName(outputPort));
      if (outputPort.isMultiport()) {
        code.append("String_Node_Str" + outputPort.getWidthInside() + "String_Node_Str");
      }
      int bufferSize=_ports.getBufferSize(outputPort);
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate output variable declarations.
 * @return a String that declares output variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
@Override public String generateOutputVariableDeclaration(CodeGeneratorAdapter target) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> outputPorts=((Actor)target.getComponent()).outputPortList().iterator();
  while (outputPorts.hasNext()) {
    TypedIOPort outputPort=(TypedIOPort)outputPorts.next();
    if (!outputPort.isOutsideConnected() || outputPort.isInsideConnected()) {
      code.append("String_Node_Str" + targetType(outputPort.getType()) + "String_Node_Str"+ CodeGeneratorAdapterStrategy.generateName(outputPort));
      if (outputPort.isMultiport()) {
        code.append("String_Node_Str" + outputPort.getWidthInside() + "String_Node_Str");
      }
      int bufferSize=_ports.getBufferSize(outputPort);
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  return code.toString();
}
Program: 74162
Project: 74162
Buggy source:
/** 
 * Generate input variable declarations.
 * @return a String that declares input variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
@Override public String generateInputVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> inputPorts=((Actor)getComponent().getContainer()).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
    if (!inputPort.isOutsideConnected()) {
      continue;
    }
    _portVariableDeclaration(code,inputPort);
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate input variable declarations.
 * @return a String that declares input variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
@Override public String generateInputVariableDeclaration(CodeGeneratorAdapter target) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> inputPorts=((Actor)target.getComponent()).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
    if (!inputPort.isOutsideConnected()) {
      continue;
    }
    _portVariableDeclaration(code,inputPort);
  }
  return code.toString();
}
Program: 74163
Project: 74163
Buggy source:
/** 
 * Generate output variable declarations.
 * @return a String that declares output variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
@Override public String generateOutputVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> outputPorts=((Actor)getComponent().getContainer()).outputPortList().iterator();
  while (outputPorts.hasNext()) {
    TypedIOPort outputPort=(TypedIOPort)outputPorts.next();
    if (!outputPort.isOutsideConnected() || outputPort.isInsideConnected()) {
      _portVariableDeclaration(code,outputPort);
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate output variable declarations.
 * @return a String that declares output variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
@Override public String generateOutputVariableDeclaration(CodeGeneratorAdapter target) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> outputPorts=((Actor)target.getComponent()).outputPortList().iterator();
  while (outputPorts.hasNext()) {
    TypedIOPort outputPort=(TypedIOPort)outputPorts.next();
    if (!outputPort.isOutsideConnected() || outputPort.isInsideConnected()) {
      _portVariableDeclaration(code,outputPort);
    }
  }
  return code.toString();
}
Program: 74166
Project: 74166
Buggy source:
/** 
 * Generate the wrapup code of the director associated with this adapter class. For this base class, this method just generate the wrapup code for each actor.
 * @return The generated wrapup code.
 * @exception IllegalActionException If the adapter class for each actorcannot be found, or if an error occurs while the adapter generate the wrapup code.
 */
public String generateWrapupCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(getCodeGenerator().comment(1,"String_Node_Str"));
  Iterator<?> actors=((CompositeActor)_director.getContainer()).deepEntityList().iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    ComponentCodeGenerator adapterObject=getCodeGenerator().getAdapter((NamedObj)actor);
    code.append(adapterObject.generateWrapupCode());
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate the wrapup code of the director associated with this adapter class. For this base class, this method just generate the wrapup code for each actor.
 * @return The generated wrapup code.
 * @exception IllegalActionException If the adapter class for each actorcannot be found, or if an error occurs while the adapter generate the wrapup code.
 */
public String generateWrapupCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(getCodeGenerator().comment(1,"String_Node_Str"));
  Iterator<?> actors=((CompositeActor)_director.getContainer()).deepEntityList().iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    CodeGeneratorAdapter adapterObject=getCodeGenerator().getAdapter((NamedObj)actor);
    code.append(adapterObject.generateWrapupCode());
  }
  return code.toString();
}
Program: 74167
Project: 74167
Buggy source:
public String getReference(String name,boolean isWrite,CodeGeneratorAdapter target) throws IllegalActionException {
}

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. FIXME: need documentation on the input string format.
 * @param name The name of the parameter or port
 * @param target The CodeGeneratorAdapter for which code needs to be generated.
 * @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,boolean isWrite,CodeGeneratorAdapter target) throws IllegalActionException {
  return "String_Node_Str";
}
Program: 74168
Project: 74168
Buggy source:
/** 
 * Generate variable declarations for inputs and outputs and parameters. Append the declarations to the given string buffer.
 * @return code The generated code.
 * @exception IllegalActionException If the adapter class for the modeldirector cannot be found.
 */
public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> actors=((CompositeActor)_director.getContainer()).deepEntityList().iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    CodeGeneratorAdapter adapterObject=getCodeGenerator().getAdapter((NamedObj)actor);
    code.append(adapterObject.generateVariableDeclaration());
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate variable declarations for inputs and outputs and parameters. Append the declarations to the given string buffer.
 * @return code The generated code.
 * @exception IllegalActionException If the adapter class for the modeldirector cannot be found.
 */
@Override public String generateVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  CompositeActor container=(CompositeActor)_director.getContainer();
  GenericCodeGenerator codeGenerator=getCodeGenerator();
{
    CodeGeneratorAdapter adapterObject=codeGenerator.getAdapter(container);
    code.append(_generateVariableDeclaration(adapterObject));
  }
  Iterator<?> actors=container.deepEntityList().iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    CodeGeneratorAdapter adapterObject=codeGenerator.getAdapter((NamedObj)actor);
    code.append(_generateVariableDeclaration(adapterObject));
  }
  return code.toString();
}
Program: 74169
Project: 74169
Buggy source:
public String generateCodeForGet(IOPort port,int channel) throws IllegalActionException {
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Generate the get code for Port port.
 * @param port The port for which to generate get code.
 * @param channel The channel for which the get code is generated.
 * @return The code that gets data from the channel.
 */
public String generateCodeForGet(IOPort port,int channel) throws IllegalActionException {
  return "String_Node_Str";
}
Program: 74170
Project: 74170
Buggy source:
public String generateCodeForSend(IOPort port,int channel,String dataToken) throws IllegalActionException {
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Generate the send code for Port port.
 * @param port The port for which to generate send code. 
 * @param channel The channel for which the send code is generated.
 * @param dataToken The token to be sent
 * @return The code that sends the dataToken on the channel.
 */
public String generateCodeForSend(IOPort port,int channel,String dataToken) throws IllegalActionException {
  return "String_Node_Str";
}