Program: 74323
Project: 74323
Buggy source:
/** 
 * This compare method is used to sort all events.
 * @param arg0 First event.
 * @param arg1 Second event.
 * @return -1 if event arg0 should be processed before event arg1 andvice versa.
 */
public int compare(Object arg0,Object arg1){
  TimedEvent event1=(TimedEvent)arg0;
  TimedEvent event2=(TimedEvent)arg1;
  Actor actor1=event1.contents instanceof IOPort ? (Actor)((IOPort)event1.contents).getContainer() : (Actor)event1.contents;
  Actor actor2=event2.contents instanceof IOPort ? (Actor)((IOPort)event2.contents).getContainer() : (Actor)event2.contents;
  double wcet1=PtidesActorProperties.getWCET(actor1);
  double wcet2=PtidesActorProperties.getWCET(actor2);
  Time time1=event1.timeStamp;
  Time time2=event2.timeStamp;
  boolean fireAtRT1=PtidesActorProperties.mustBeFiredAtRealTime(event1.contents);
  boolean fireAtRT2=PtidesActorProperties.mustBeFiredAtRealTime(event2.contents);
  int index1=-1;
  int index2=-1;
  int priority1=PtidesActorProperties.getPriority(actor1);
  int priority2=PtidesActorProperties.getPriority(actor2);
  CompositeActor compositeActor=(CompositeActor)actor1.getContainer();
  CausalityInterfaceForComposites causalityInterface=(CausalityInterfaceForComposites)compositeActor.getCausalityInterface();
  try {
    index1=causalityInterface.getDepthOfActor(actor1);
    index2=causalityInterface.getDepthOfActor(actor2);
  }
 catch (  IllegalActionException e) {
    e.printStackTrace();
  }
  if (priority1 != priority2) {
    return priority2 - priority1;
  }
  if (wcet1 == 0 && (!fireAtRT1 || (fireAtRT1 && time1.equals(_physicalTime)))) {
    return -1;
  }
  if (wcet2 == 0 && (!fireAtRT2 || (fireAtRT2 && time2.equals(_physicalTime)))) {
    return 1;
  }
  if (wcet1 > 0 && wcet2 == 0) {
    if (!fireAtRT2 || time2.equals(_physicalTime)) {
      return 1;
    }
  }
  if (wcet1 == 0 && wcet2 == 0) {
    if (fireAtRT1 && time1.equals(_physicalTime) && !fireAtRT2) {
      return -1;
    }
    if (fireAtRT1 && time1.compareTo(_physicalTime) > 0 && !fireAtRT2) {
      return 1;
    }
    if (fireAtRT2 && time2.equals(_physicalTime) && !fireAtRT1) {
      return 1;
    }
    if (fireAtRT2 && time2.compareTo(_physicalTime) > 0 && !fireAtRT1) {
      return -1;
    }
    if (fireAtRT1 && fireAtRT2 && time1.equals(_physicalTime)&& time2.equals(_physicalTime)) {
      return 0;
    }
    if (time1.compareTo(time2) < 0) {
      return -1;
    }
    if (time2.compareTo(time1) < 0) {
      return 1;
    }
 else {
      return index2 - index1;
    }
  }
 else {
    if (fireAtRT1 && fireAtRT2) {
      if (time1.compareTo(time2) < 0) {
        return -1;
      }
 else       if (time1.compareTo(time2) > 0) {
        return 1;
      }
 else {
      }
    }
 else {
      if (time1.compareTo(time2) < 0) {
        return -1;
      }
 else       if (time1.compareTo(time2) > 0) {
        return 1;
      }
 else {
        if (index1 < index2) {
          return -1;
        }
 else         if (index1 > index2) {
          return 1;
        }
      }
    }
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * This compare method is used to sort all events.
 * @param arg0 First event.
 * @param arg1 Second event.
 * @return -1 if event arg0 should be processed before event arg1 andvice versa.
 */
public int compare(Object arg0,Object arg1){
  TimedEvent event1=(TimedEvent)arg0;
  TimedEvent event2=(TimedEvent)arg1;
  Actor actor1=event1.contents instanceof IOPort ? (Actor)((IOPort)event1.contents).getContainer() : (Actor)event1.contents;
  Actor actor2=event2.contents instanceof IOPort ? (Actor)((IOPort)event2.contents).getContainer() : (Actor)event2.contents;
  double wcet1=PtidesActorProperties.getWCET(actor1);
  double wcet2=PtidesActorProperties.getWCET(actor2);
  Time time1=event1.timeStamp;
  Time time2=event2.timeStamp;
  boolean fireAtRT1=PtidesActorProperties.mustBeFiredAtRealTime(event1.contents);
  boolean fireAtRT2=PtidesActorProperties.mustBeFiredAtRealTime(event2.contents);
  boolean fixedWCET1=!(actor1 instanceof TDLModule);
  boolean fixedWCET2=!(actor2 instanceof TDLModule);
  int index1=-1;
  int index2=-1;
  int priority1=PtidesActorProperties.getPriority(actor1);
  int priority2=PtidesActorProperties.getPriority(actor2);
  CompositeActor compositeActor=(CompositeActor)actor1.getContainer();
  CausalityInterfaceForComposites causalityInterface=(CausalityInterfaceForComposites)compositeActor.getCausalityInterface();
  try {
    index1=causalityInterface.getDepthOfActor(actor1);
    index2=causalityInterface.getDepthOfActor(actor2);
  }
 catch (  IllegalActionException e) {
    e.printStackTrace();
  }
  if (priority1 != priority2) {
    return priority2 - priority1;
  }
  if (wcet1 > 0 && wcet2 == 0) {
    return 1;
  }
 else   if (wcet2 > 0 && wcet1 == 0) {
    return -1;
  }
  if (wcet1 == 0 && wcet2 == 0) {
    if (fixedWCET1 && !fixedWCET2)     return -1;
 else     if (fixedWCET2 && !fixedWCET1)     return 1;
 else     return index1 - index2;
  }
 else {
    if (fireAtRT1 && fireAtRT2) {
      if (time1.compareTo(time2) < 0) {
        return -1;
      }
 else       if (time1.compareTo(time2) > 0) {
        return 1;
      }
 else {
      }
    }
 else {
      if (time1.compareTo(time2) < 0) {
        return -1;
      }
 else       if (time1.compareTo(time2) > 0) {
        return 1;
      }
 else {
        if (index1 < index2) {
          return -1;
        }
 else         if (index1 > index2) {
          return 1;
        }
      }
    }
  }
  return 0;
}