Program: 73413
Project: 73413
Buggy source:
/** 
 * Generate The fire function code. This method is called when the firing code of each actor is not inlined. If the <i>inline</i> parameter of the code generator is true, then each actor's firing code is in a function with the same name as that of the actor.  If the <i>inline</i> parameter is false, then the firing code is grouped in inner classes.
 * @return The fire function code.
 * @exception IllegalActionException If thrown while generating fire code.
 */
public String generateFireFunctionCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  List actorList=((CompositeActor)_director.getContainer()).deepEntityList();
  Collections.sort(actorList,new Comparator(){
    /** 
 * Compare two NamedObjs by fullName().
 * @return -1 if object1 has fewer dots in its fullName(),1 if object1 has more dots in its fullName(), 0 if the objects are the same. If the fullName()s of both NamedObjs have the same number of dots, then return the String compareTo() of the fullName()s.
 */
    public int compare(    Object object1,    Object object2){
      String name1=((NamedObj)object1).getFullName();
      String name2=((NamedObj)object2).getFullName();
      int index=0;
      int dots1=0;
      while ((index=name1.indexOf("String_Node_Str",index)) != -1) {
        index++;
        dots1++;
      }
      int dots2=0;
      while ((index=name2.indexOf('.',index)) != -1) {
        index++;
        dots2++;
      }
      if (dots1 == dots2) {
        return 0;
      }
 else       if (dots1 < dots2) {
        return -1;
      }
      return 1;
    }
  }
);
  ProgramCodeGenerator codeGenerator=getCodeGenerator();
  code.append(codeGenerator.comment("String_Node_Str"));
  boolean inline=((BooleanToken)codeGenerator.inline.getToken()).booleanValue();
  String className="String_Node_Str";
  String hackStart="String_Node_Str";
  ptolemy.actor.Director director=(ptolemy.actor.Director)getComponent();
  HashMap<String,StringBuffer> innerClasses=new HashMap<String,StringBuffer>();
  Iterator<?> actors=actorList.iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    NamedProgramCodeGeneratorAdapter actorAdapter=(NamedProgramCodeGeneratorAdapter)codeGenerator.getAdapter(actor);
    if (inline) {
      code.append(actorAdapter.generateFireFunctionCode());
    }
 else {
      String results[]=codeGenerator.generateFireFunctionVariableAndMethodName((NamedObj)actor);
      className=results[0];
      StringBuffer innerClassBuffer=innerClasses.get(className);
      if (innerClassBuffer == null) {
        innerClassBuffer=new StringBuffer();
        if (!director.isEmbedded() || director.getContainer() instanceof ptolemy.cg.lib.CompiledCompositeActor) {
          innerClassBuffer.append(codeGenerator.generateFireFunctionCompositeStart(className));
        }
 else {
          innerClassBuffer.append(hackStart + className + "String_Node_Str");
        }
        innerClasses.put(className,innerClassBuffer);
      }
      String subFireCode=actorAdapter.generateFireFunctionCode();
      int startIndex=0;
      if ((startIndex=subFireCode.indexOf(hackStart)) != -1) {
        int endIndex=subFireCode.indexOf("String_Node_Str",startIndex);
        className=subFireCode.substring(startIndex + hackStart.length(),endIndex);
        innerClassBuffer=innerClasses.get(className);
        if (innerClassBuffer == null) {
          innerClassBuffer=new StringBuffer();
          innerClassBuffer.append("String_Node_Str" + className + "String_Node_Str"+ _eol);
          innerClasses.put(className,innerClassBuffer);
        }
      }
      innerClassBuffer.append(subFireCode);
    }
  }
  if (!inline) {
    for (    Map.Entry<String,StringBuffer> innerClassBuffer : innerClasses.entrySet()) {
      code.append(innerClassBuffer.getValue());
      if (!director.isEmbedded() || director.getContainer() instanceof ptolemy.cg.lib.CompiledCompositeActor) {
        code.append(codeGenerator.generateFireFunctionCompositeEnd());
      }
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate The fire function code. This method is called when the firing code of each actor is not inlined. If the <i>inline</i> parameter of the code generator is true, then each actor's firing code is in a function with the same name as that of the actor.  If the <i>inline</i> parameter is false, then the firing code is grouped in inner classes.
 * @return The fire function code.
 * @exception IllegalActionException If thrown while generating fire code.
 */
public String generateFireFunctionCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  List actorList=((CompositeActor)_director.getContainer()).deepEntityList();
  Collections.sort(actorList,new FullNameComparator());
  ProgramCodeGenerator codeGenerator=getCodeGenerator();
  code.append(codeGenerator.comment("String_Node_Str"));
  boolean inline=((BooleanToken)codeGenerator.inline.getToken()).booleanValue();
  String className="String_Node_Str";
  String hackStart="String_Node_Str";
  ptolemy.actor.Director director=(ptolemy.actor.Director)getComponent();
  HashMap<String,StringBuffer> innerClasses=new HashMap<String,StringBuffer>();
  Iterator<?> actors=actorList.iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    NamedProgramCodeGeneratorAdapter actorAdapter=(NamedProgramCodeGeneratorAdapter)codeGenerator.getAdapter(actor);
    if (inline) {
      code.append(actorAdapter.generateFireFunctionCode());
    }
 else {
      String results[]=codeGenerator.generateFireFunctionVariableAndMethodName((NamedObj)actor);
      className=results[0];
      StringBuffer innerClassBuffer=innerClasses.get(className);
      if (innerClassBuffer == null) {
        innerClassBuffer=new StringBuffer();
        if (!director.isEmbedded() || director.getContainer() instanceof ptolemy.cg.lib.CompiledCompositeActor) {
          innerClassBuffer.append(codeGenerator.generateFireFunctionCompositeStart(className));
        }
 else {
          innerClassBuffer.append(hackStart + className + "String_Node_Str");
        }
        innerClasses.put(className,innerClassBuffer);
      }
      String subFireCode=actorAdapter.generateFireFunctionCode();
      int startIndex=0;
      if ((startIndex=subFireCode.indexOf(hackStart)) != -1) {
        int endIndex=subFireCode.indexOf("String_Node_Str",startIndex);
        className=subFireCode.substring(startIndex + hackStart.length(),endIndex);
        innerClassBuffer=innerClasses.get(className);
        if (innerClassBuffer == null) {
          innerClassBuffer=new StringBuffer();
          innerClassBuffer.append("String_Node_Str" + className + "String_Node_Str"+ _eol);
          innerClasses.put(className,innerClassBuffer);
        }
      }
      innerClassBuffer.append(subFireCode);
    }
  }
  if (!inline) {
    for (    Map.Entry<String,StringBuffer> innerClassBuffer : innerClasses.entrySet()) {
      code.append(innerClassBuffer.getValue());
      if (!director.isEmbedded() || director.getContainer() instanceof ptolemy.cg.lib.CompiledCompositeActor) {
        code.append(codeGenerator.generateFireFunctionCompositeEnd());
      }
    }
  }
  return code.toString();
}