Program: 76468
Project: 76468
Buggy source:
/** 
 * return an Enumeration of the detail schedules. The first element in the Enumeration is the stateschedule, then transitionschedule, then output schedule, and then event generating schedule. Each schedule is an Enumeration of actors in their topological order. Each schedule can also be accessed by individual getXXSchedule method.
 * @return an Enumeration of sub-schedules.
 * @exception NotSchedulableException either the system constructionis wrong or arithmetic loop exists.
 */
protected Enumeration _schedule() throws NotSchedulableException {
  CTDirector dir=(CTDirector)getContainer();
  if (dir == null) {
    return null;
  }
  CompositeActor ca=(CompositeActor)(dir.getContainer());
  if (ca == null) {
    return null;
  }
  _stateschedule=new LinkedList();
  _transitionschedule=new LinkedList();
  _outputschedule=new LinkedList();
  _statessc=new LinkedList();
  _outputssc=new LinkedList();
  LinkedList _scheList=new LinkedList();
  DirectedAcyclicGraph g=_toGraph(ca.deepGetEntities());
  if (!g.isAcyclic()) {
    throw new NotSchedulableException("String_Node_Str");
  }
  _classifyActors();
  int numofdyn=_dynam.size();
  if (numofdyn > 0) {
    Object[] dynactors=new Object[numofdyn];
    Enumeration enumdynactors=_dynam.elements();
    int count=0;
    while (enumdynactors.hasMoreElements()) {
      dynactors[count++]=enumdynactors.nextElement();
    }
    Object[] xsort=g.topologicalSort(dynactors);
    for (int i=0; i < xsort.length; i++) {
      Actor a=(Actor)xsort[i];
      _stateschedule.insertFirst(a);
      if (a instanceof CTStepSizeControlActor) {
        _statessc.insertFirst(a);
      }
    }
    _scheList.insertLast(_stateschedule);
    Object[] fx=g.backwardReachableNodes(dynactors);
    Object[] fxsort=g.topologicalSort(fx);
    for (int i=0; i < fxsort.length; i++) {
      Actor a=(Actor)fxsort[i];
      _transitionschedule.insertLast(a);
      if (a instanceof CTStepSizeControlActor) {
        _statessc.insertFirst(a);
      }
    }
    _scheList.insertLast(_transitionschedule);
  }
  int numofsink=_sink.size();
  if (numofsink > 0) {
    Object[] sinkactors=new Object[numofsink];
    Enumeration enumsinks=_sink.elements();
    int count=0;
    while (enumsinks.hasMoreElements()) {
      sinkactors[count++]=enumsinks.nextElement();
    }
    Object[] gx=g.backwardReachableNodes(sinkactors);
    Object[] gxsort=g.topologicalSort(gx);
    for (int i=0; i < gxsort.length; i++) {
      Actor a=(Actor)gxsort[i];
      _outputschedule.insertLast(a);
      if (a instanceof CTStepSizeControlActor) {
        _outputssc.insertFirst(a);
      }
    }
    _outputschedule.appendElements(_sink.elements());
    _scheList.insertLast(_outputschedule);
  }
  return _scheList.elements();
}

Fixed version (ground truth):
/** 
 * return an Enumeration of the detail schedules. The first element in the Enumeration is the stateschedule, then transitionschedule, then output schedule, and then event generating schedule. Each schedule is an Enumeration of actors in their topological order. Each schedule can also be accessed by individual getXXSchedule method.
 * @return an Enumeration of sub-schedules.
 * @exception NotSchedulableException either the system constructionis wrong or arithmetic loop exists.
 */
protected Enumeration _schedule() throws NotSchedulableException {
  CTDirector dir=(CTDirector)getContainer();
  if (dir == null) {
    return null;
  }
  CompositeActor ca=(CompositeActor)(dir.getContainer());
  if (ca == null) {
    return null;
  }
  _stateschedule=new LinkedList();
  _transitionschedule=new LinkedList();
  _outputschedule=new LinkedList();
  _statessc=new LinkedList();
  _outputssc=new LinkedList();
  LinkedList _scheList=new LinkedList();
  _classifyActors();
  DirectedAcyclicGraph g=_toArithGraph(ca.deepGetEntities());
  DirectedAcyclicGraph gd=_toGraph(dynamicActors());
  if (!g.isAcyclic()) {
    throw new NotSchedulableException("String_Node_Str");
  }
  int numofdyn=_dynam.size();
  if (numofdyn > 0) {
    Object[] dynactors=new Object[numofdyn];
    Enumeration enumdynactors=_dynam.elements();
    int count=0;
    while (enumdynactors.hasMoreElements()) {
      dynactors[count++]=enumdynactors.nextElement();
    }
    Object[] xsort=gd.topologicalSort(dynactors);
    for (int i=0; i < xsort.length; i++) {
      Actor a=(Actor)xsort[i];
      _stateschedule.insertFirst(a);
      if (a instanceof CTStepSizeControlActor) {
        _statessc.insertFirst(a);
      }
    }
    _scheList.insertLast(_stateschedule);
    Object[] fx=g.backwardReachableNodes(dynactors);
    Object[] fxsort=g.topologicalSort(fx);
    for (int i=0; i < fxsort.length; i++) {
      Actor a=(Actor)fxsort[i];
      _transitionschedule.insertLast(a);
      if (a instanceof CTStepSizeControlActor) {
        _statessc.insertFirst(a);
      }
    }
    _scheList.insertLast(_transitionschedule);
  }
  int numofsink=_sink.size();
  if (numofsink > 0) {
    Object[] sinkactors=new Object[numofsink];
    Enumeration enumsinks=_sink.elements();
    int count=0;
    while (enumsinks.hasMoreElements()) {
      sinkactors[count++]=enumsinks.nextElement();
    }
    Object[] gx=g.backwardReachableNodes(sinkactors);
    Object[] gxsort=g.topologicalSort(gx);
    for (int i=0; i < gxsort.length; i++) {
      Actor a=(Actor)gxsort[i];
      _outputschedule.insertLast(a);
      if (a instanceof CTStepSizeControlActor) {
        _outputssc.insertFirst(a);
      }
    }
    _outputschedule.appendElements(_sink.elements());
    _scheList.insertLast(_outputschedule);
  }
  return _scheList.elements();
}