Program: 73537
Project: 73537
Buggy source:
/** 
 * Specify the container. If the container is not the same as the previous container, then start monitoring the new container.
 * @param container The container to attach this attribute to..
 * @exception IllegalActionException If this attribute is not of theexpected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.
 * @exception NameDuplicationException If the container already hasan attribute with the name of this attribute.
 * @see #getContainer()
 */
public void setContainer(final NamedObj container) throws IllegalActionException, NameDuplicationException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  NamedObj previousContainer=getContainer();
  if (previousContainer == container) {
    return;
  }
  if ((previousContainer != null) && (previousContainer instanceof CompositeActor)) {
    if (_piggybackContainer != null) {
      _piggybackContainer.removePiggyback(_executable);
    }
    _executable=null;
    String name;
    try {
      workspace().getWriteAccess();
      List<Actor> entities=((CompositeActor)previousContainer).deepEntityList();
      for (      Actor entity : entities) {
        List<Attribute> paramList=((Entity)entity).attributeList();
        for (        Attribute param : paramList) {
          name=param.getDisplayName();
          if (name.equals("String_Node_Str") || name.equals("String_Node_Str")) {
          }
        }
      }
    }
 catch (    Exception ex) {
      throw new InternalErrorException(ex);
    }
 finally {
      workspace().doneTemporaryWriting();
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
  }
  super.setContainer(container);
  if (container != null && container instanceof CompositeActor) {
    if (_executable == null) {
      _executable=new Executable(){
        public void initialize() throws IllegalActionException {
          if (_random == null || ((BooleanToken)resetOnEachRun.getToken()).booleanValue()) {
            _createGenerator();
          }
          _needNew=true;
        }
        public boolean postfire() throws IllegalActionException {
          if (_debugging) {
            _debug("String_Node_Str");
          }
          _needNew=true;
          double actorExecutionTimes=0;
          double actorWorstCaseExecutionTimes=0;
          List<Actor> entities=((CompositeActor)container).deepEntityList();
          for (          Actor actor : entities) {
            Attribute executionTime=((Entity)actor).getAttribute("String_Node_Str");
            Attribute WCET=((Entity)actor).getAttribute("String_Node_Str");
            try {
              actorWorstCaseExecutionTimes+=((DoubleToken)((Variable)WCET).getToken()).doubleValue();
              actorExecutionTimes+=((DoubleToken)((Variable)executionTime).getToken()).doubleValue();
            }
 catch (            IllegalActionException ex) {
              ex.printStackTrace();
            }
          }
          if (_debugging) {
            _debug("String_Node_Str" + actorExecutionTimes + "String_Node_Str"+ actorWorstCaseExecutionTimes);
          }
          if (actorExecutionTimes > actorWorstCaseExecutionTimes) {
            if (_debugging) {
              _debug("String_Node_Str");
            }
            System.out.println("String_Node_Str");
            handleModelError(container,new IllegalActionException(container,"String_Node_Str" + actorExecutionTimes + "String_Node_Str"+ actorWorstCaseExecutionTimes+ "String_Node_Str"+ container.getDisplayName()));
          }
          ChangeRequest request=new ChangeRequest(this,"String_Node_Str",true){
            protected void _execute() throws IllegalActionException {
            }
          }
;
          request.setPersistent(false);
          requestChange(request);
          if (_debugging) {
            _debug("String_Node_Str");
          }
          return true;
        }
        public void wrapup(){
          ChangeRequest request=new ChangeRequest(this,"String_Node_Str",true){
            protected void _execute() throws IllegalActionException {
            }
          }
;
          request.setPersistent(false);
          requestChange(request);
        }
        public void fire() throws IllegalActionException {
          if (_debugging) {
            _debug("String_Node_Str");
          }
          if (_needNewGenerator) {
            _createGenerator();
          }
          if (_needNew) {
            _generateRandomNumber();
            _needNew=false;
          }
          List<Actor> entities=((CompositeActor)container).deepEntityList();
          for (          Actor actor : entities) {
            _myPhysicalTime=actor.getDirector().getModelTime().getDoubleValue() + _overRunThusFar;
            if (_debugging) {
              _debug("String_Node_Str" + actor.getName());
            }
            double actorWCET;
            Attribute executionTime=((Entity)actor).getAttribute("String_Node_Str");
            Attribute WCET=((Entity)actor).getAttribute("String_Node_Str");
            actorWCET=((DoubleToken)((Variable)WCET).getToken()).doubleValue();
            double t=_random.nextDouble() * 2 * actorWCET;
            if (t > actorWCET) {
              _overRunThusFar+=(t - actorWCET);
              _myPhysicalTime+=t;
              System.out.println("String_Node_Str" + actorWCET + "String_Node_Str"+ t);
              System.out.println("String_Node_Str" + (actor.getDirector().getModelTime().getDoubleValue() + actorWCET) + "String_Node_Str"+ _myPhysicalTime);
            }
            Parameter dummyP=(Parameter)executionTime;
            dummyP.setExpression(Double.toString(t));
          }
          if (_debugging) {
            _debug("String_Node_Str" + "String_Node_Str");
          }
        }
        public boolean isFireFunctional(){
          return true;
        }
        public boolean isStrict(){
          return true;
        }
        public int iterate(        int count){
          return Executable.COMPLETED;
        }
        public boolean prefire() throws IllegalActionException {
          return true;
        }
        public void stop(){
        }
        public void stopFire(){
        }
        public void terminate(){
        }
        public void addInitializable(        Initializable initializable){
        }
        public void preinitialize() throws IllegalActionException {
          double wcet=0;
          double _periodValue=0;
          wcet=_getDirectorWCET(container);
          _periodValue=_getDirectorPeriod(container);
          if (_debugging) {
            _debug("String_Node_Str" + wcet + "String_Node_Str"+ _periodValue);
          }
          if (wcet > _periodValue) {
            if (_debugging) {
              _debug("String_Node_Str");
            }
            throw new IllegalActionException(container,"String_Node_Str" + wcet + "String_Node_Str"+ _periodValue+ "String_Node_Str"+ ((CompositeActor)(getContainer())).getDisplayName());
          }
          if (_debugging) {
            _debug("String_Node_Str");
          }
        }
        public void removeInitializable(        Initializable initializable){
        }
      }
;
    }
    _piggybackContainer=(CompositeActor)container;
    _piggybackContainer.addPiggyback(_executable);
  }
}

Fixed version (ground truth):
/** 
 * Specify the container. If the container is not the same as the previous container, then start monitoring the new container.
 * @param container The container to attach this attribute to..
 * @exception IllegalActionException If this attribute is not of theexpected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.
 * @exception NameDuplicationException If the container already hasan attribute with the name of this attribute.
 * @see #getContainer()
 */
public void setContainer(final NamedObj container) throws IllegalActionException, NameDuplicationException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  NamedObj previousContainer=getContainer();
  if (previousContainer == container) {
    return;
  }
  if ((previousContainer != null) && (previousContainer instanceof CompositeActor)) {
    if (_piggybackContainer != null) {
      _piggybackContainer.removePiggyback(_executable);
    }
    _executable=null;
    String name;
    try {
      workspace().getWriteAccess();
      List<Actor> entities=((CompositeActor)previousContainer).deepEntityList();
      for (      Actor entity : entities) {
        List<Attribute> paramList=((Entity)entity).attributeList();
        for (        Attribute param : paramList) {
          name=param.getDisplayName();
          if (name.equals("String_Node_Str") || name.equals("String_Node_Str")) {
          }
        }
      }
    }
 catch (    Exception ex) {
      throw new InternalErrorException(ex);
    }
 finally {
      workspace().doneTemporaryWriting();
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
  }
  super.setContainer(container);
  if (container != null && container instanceof CompositeActor) {
    if (_executable == null) {
      _executable=new Executable(){
        public void initialize() throws IllegalActionException {
          if (_random == null || ((BooleanToken)resetOnEachRun.getToken()).booleanValue()) {
            _createGenerator();
          }
          _needNew=true;
        }
        public boolean postfire() throws IllegalActionException {
          if (_debugging) {
            _debug("String_Node_Str");
          }
          _needNew=true;
          if (_debugging) {
            _debug("String_Node_Str" + _totalObservedExecutionTime + "String_Node_Str"+ _totalExpectedExecutionTime);
          }
          if (_totalObservedExecutionTime > _totalExpectedExecutionTime) {
            if (_debugging) {
              _debug("String_Node_Str");
            }
            if (_debugging) {
              _debug("String_Node_Str");
            }
            handleModelError(container,new IllegalActionException(container,"String_Node_Str" + _totalObservedExecutionTime + "String_Node_Str"+ _totalExpectedExecutionTime+ "String_Node_Str"+ container.getDisplayName()));
          }
          _totalObservedExecutionTime=0;
          ChangeRequest request=new ChangeRequest(this,"String_Node_Str",true){
            protected void _execute() throws IllegalActionException {
            }
          }
;
          request.setPersistent(false);
          requestChange(request);
          if (_debugging) {
            _debug("String_Node_Str");
          }
          return true;
        }
        public void wrapup(){
          ChangeRequest request=new ChangeRequest(this,"String_Node_Str",true){
            protected void _execute() throws IllegalActionException {
            }
          }
;
          request.setPersistent(false);
          requestChange(request);
        }
        public void fire() throws IllegalActionException {
          if (!_readyToFire) {
            return;
          }
          if (_debugging) {
            _debug("String_Node_Str" + container);
          }
          if (_debugging) {
            _debug("String_Node_Str");
          }
          if (_needNewGenerator) {
            _createGenerator();
          }
          if (_needNew) {
            _generateRandomNumber();
            _needNew=false;
          }
          if (!_readyToFire) {
            return;
          }
          while ((_unitIndex < _schedule.size())) {
            Schedule unitSchedule=(Schedule)_schedule.get(_unitIndex);
            Iterator scheduleIterator=unitSchedule.iterator();
            while (scheduleIterator.hasNext()) {
              Actor actor=((Firing)scheduleIterator.next()).getActor();
              if (_debugging) {
                _debug("String_Node_Str" + actor.getFullName());
              }
              _myPhysicalTime=actor.getDirector().getModelTime().getDoubleValue() + _overRunThusFar;
              double actorWCET;
              Attribute executionTime=((Entity)actor).getAttribute("String_Node_Str");
              Attribute WCET=((Entity)actor).getAttribute("String_Node_Str");
              actorWCET=((DoubleToken)((Variable)WCET).getToken()).doubleValue();
              double t=_random.nextDouble() * 2 * actorWCET;
              if (_debugging) {
                _debug("String_Node_Str" + t);
              }
              _totalObservedExecutionTime+=t;
              if (t > actorWCET) {
                _overRunThusFar+=(t - actorWCET);
                _myPhysicalTime+=t;
                if (_debugging) {
                  _debug("String_Node_Str" + actorWCET + "String_Node_Str"+ t);
                  _debug("String_Node_Str" + (actor.getDirector().getModelTime().getDoubleValue() + actorWCET) + "String_Node_Str"+ _myPhysicalTime);
                }
              }
              Parameter dummyP=(Parameter)executionTime;
              dummyP.setExpression(Double.toString(t));
              if (_debugging) {
                _debug("String_Node_Str" + actor + "String_Node_Str");
              }
            }
            scheduleIterator=unitSchedule.iterator();
            while (scheduleIterator.hasNext()) {
              Actor actor1=((Firing)scheduleIterator.next()).getActor();
              if (_debugging) {
                _debug("String_Node_Str" + ((NamedObj)actor1).getFullName());
              }
              if (actor1.iterate(1) == STOP_ITERATING) {
                System.err.println("String_Node_Str" + "String_Node_Str" + actor1.getFullName() + "String_Node_Str");
              }
            }
            _unitIndex++;
          }
          if (_unitIndex >= _schedule.size()) {
            _unitIndex=0;
          }
        }
        public boolean isFireFunctional(){
          return true;
        }
        public boolean isStrict(){
          return true;
        }
        public int iterate(        int count){
          return Executable.COMPLETED;
        }
        public boolean prefire() throws IllegalActionException {
          return true;
        }
        public void stop(){
        }
        public void stopFire(){
        }
        public void terminate(){
        }
        public void addInitializable(        Initializable initializable){
        }
        public void preinitialize() throws IllegalActionException {
          double wcet=0;
          double _periodValue=0;
          wcet=_getDirectorWCET(container);
          _periodValue=_getDirectorPeriod(container);
          GiottoScheduler scheduler=(GiottoScheduler)((GiottoDirector)((CompositeActor)container).getDirector()).getScheduler();
          _schedule=scheduler.getSchedule();
          if (_debugging) {
            _debug("String_Node_Str" + wcet + "String_Node_Str"+ _periodValue);
          }
          if (wcet > _periodValue) {
            if (_debugging) {
              _debug("String_Node_Str");
            }
            throw new IllegalActionException(container,"String_Node_Str" + wcet + "String_Node_Str"+ _periodValue+ "String_Node_Str"+ ((CompositeActor)(getContainer())).getDisplayName());
          }
          if (_debugging) {
            _debug("String_Node_Str");
          }
        }
        public void removeInitializable(        Initializable initializable){
        }
      }
;
    }
    _piggybackContainer=(CompositeActor)container;
    _piggybackContainer.addPiggyback(_executable);
  }
}