Program: 73298
Project: 73298
Buggy source:
/** 
 * Initialize the model that already has RemoteSinks/Sources from the supplied xml string and set appropriate model types from the inferred model mapping. <p>This method is indented to be used on the Android to avoid loading unneeded actors.</p>
 * @param modelXML The modelXML file containing or
 * @param modelTypes The map of ports and their resolved types
 * @exception Exception If there is a problem parsing the modelXML.
 */
public void initModel(String modelXML,HashMap<String,String> modelTypes) throws Exception {
  MoMLParser parser=_createMoMLParser();
  _topLevelActor=(CompositeActor)parser.parse(modelXML);
  for (  Object obj : getTopLevelActor().deepEntityList()) {
    ComponentEntity actor=(ComponentEntity)obj;
    if (actor instanceof RemoteSink) {
      RemoteSink remoteSink=(RemoteSink)actor;
      remoteSink.setTokenPublisher(_tokenPublisher);
      _remoteSinkMap.put(remoteSink.getTargetEntityName(),remoteSink);
    }
 else     if (actor instanceof RemoteSource) {
      RemoteSource remoteSource=(RemoteSource)actor;
      RemoteSourceData remoteSourceData=new RemoteSourceData(remoteSource,this);
      remoteSource.setRemoteSourceData(remoteSourceData);
      getRemoteSourceMap().put(remoteSource.getTargetEntityName(),remoteSourceData);
    }
    Type type;
    for (    Object portObject : actor.portList()) {
      if (portObject instanceof TypedIOPort) {
        TypedIOPort port=(TypedIOPort)portObject;
        StringAttribute targetPortName=(StringAttribute)port.getAttribute("String_Node_Str");
        if (targetPortName != null) {
          type=BaseType.forName(modelTypes.get(targetPortName.getExpression()));
          if (type != null) {
            port.setTypeEquals(type);
          }
          port.typeConstraints().clear();
        }
 else         if ((type=BaseType.forName(modelTypes.get(port.getFullName()))) != null) {
          port.setTypeEquals(type);
          port.typeConstraints().clear();
        }
 else {
          throw new IllegalActionException(port,"String_Node_Str");
        }
      }
    }
    for (    Typeable attribute : actor.attributeList(Typeable.class)) {
      if ((type=BaseType.forName(modelTypes.get(((Nameable)attribute).getFullName()))) != null) {
        attribute.setTypeEquals(type);
        attribute.typeConstraints().clear();
      }
    }
  }
  _initRemoteAttributes(_topLevelActor);
}

Fixed version (ground truth):
/** 
 * Initialize the model that already has RemoteSinks/Sources from the supplied xml string and set appropriate model types from the inferred model mapping. <p>This method is indented to be used on the Android to avoid loading unneeded actors.</p>
 * @param modelXML The modelXML file containing or
 * @param modelTypes The map of ports and their resolved types
 * @exception Exception If there is a problem parsing the modelXML.
 */
public void initModel(String modelXML,HashMap<String,Type> modelTypes) throws Exception {
  MoMLParser parser=_createMoMLParser();
  _topLevelActor=(CompositeActor)parser.parse(modelXML);
  for (  Entry<String,Type> entry : modelTypes.entrySet()) {
    if (entry.getValue() instanceof BaseType) {
      BaseType type=(BaseType)entry.getValue();
      Type staticTypeInstance=BaseType.forName(type.toString());
      entry.setValue(staticTypeInstance);
    }
  }
  for (  Object obj : getTopLevelActor().deepEntityList()) {
    ComponentEntity actor=(ComponentEntity)obj;
    if (actor instanceof RemoteSink) {
      RemoteSink remoteSink=(RemoteSink)actor;
      remoteSink.setTokenPublisher(_tokenPublisher);
      _remoteSinkMap.put(remoteSink.getTargetEntityName(),remoteSink);
    }
 else     if (actor instanceof RemoteSource) {
      RemoteSource remoteSource=(RemoteSource)actor;
      RemoteSourceData remoteSourceData=new RemoteSourceData(remoteSource,this);
      remoteSource.setRemoteSourceData(remoteSourceData);
      getRemoteSourceMap().put(remoteSource.getTargetEntityName(),remoteSourceData);
    }
    Type type;
    for (    Object portObject : actor.portList()) {
      if (portObject instanceof TypedIOPort) {
        TypedIOPort port=(TypedIOPort)portObject;
        StringAttribute targetPortName=(StringAttribute)port.getAttribute("String_Node_Str");
        if (targetPortName != null) {
          type=modelTypes.get(targetPortName.getExpression());
          if (type != null) {
            port.setTypeEquals(type);
          }
          port.typeConstraints().clear();
        }
 else         if ((type=modelTypes.get(port.getFullName())) != null) {
          port.setTypeEquals(type);
          port.typeConstraints().clear();
        }
 else {
          throw new IllegalActionException(port,"String_Node_Str");
        }
      }
    }
    for (    Typeable attribute : actor.attributeList(Typeable.class)) {
      if ((type=modelTypes.get(((Nameable)attribute).getFullName())) != null) {
        attribute.setTypeEquals(type);
        attribute.typeConstraints().clear();
      }
    }
  }
  _initRemoteAttributes(_topLevelActor);
}