Program: 74286
Project: 74286
Buggy source:
/** 
 * Get the NamedObj with the given name in the scope of the given container.  If the name contains the "::" scoping specifier, then an attribute more deeply in the hierarchy is searched for.
 * @param container The container to search upwards from.
 * @param name The object name to search for.
 * @return The NamedObj with the given name or null if the NamedObjdoes not exist.
 */
public static NamedObj getScopedObject(NamedObj container,String name){
  if (name.equals("String_Node_Str")) {
    return container;
  }
  String[] parts=name.replaceAll("String_Node_Str","String_Node_Str").split("String_Node_Str");
  NamedObj result=null;
  boolean lookup=true;
  for (  String part : parts) {
    result=null;
    while (container != null) {
      Attribute attribute=container.getAttribute(part);
      if (attribute != null) {
        result=attribute;
      }
 else {
        if (container instanceof Entity) {
          Port port=((Entity)container).getPort(part);
          if (port != null) {
            result=port;
          }
 else           if (container instanceof CompositeEntity) {
            ComponentEntity entity=((CompositeEntity)container).getEntity(part);
            if (entity != null) {
              result=entity;
            }
 else {
              ComponentRelation relation=((CompositeEntity)container).getRelation(part);
              if (relation != null) {
                result=relation;
              }
            }
          }
        }
      }
      if (lookup && result == null) {
        List attributes=(container).attributeList(ContainmentExtender.class);
        Iterator attrIterator=attributes.iterator();
        NamedObj extendedContainer=null;
        while (extendedContainer == null && attrIterator.hasNext()) {
          ContainmentExtender extender=(ContainmentExtender)attrIterator.next();
          try {
            extendedContainer=extender.getExtendedContainer();
          }
 catch (          IllegalActionException e) {
          }
        }
        if (extendedContainer == null) {
          container=container.getContainer();
        }
 else {
          container=extendedContainer;
        }
      }
 else {
        break;
      }
    }
    if (result == null) {
      break;
    }
    container=result;
    lookup=false;
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Get the NamedObj with the given name in the scope of the given container.  If the name contains the "::" scoping specifier, then an attribute more deeply in the hierarchy is searched for. If the specified container is lazy (implements LazyComposite), then references to its contained entities or relations will not resolve, so such references are disallowed.
 * @param container The container to search upwards from.
 * @param name The object name to search for.
 * @return The NamedObj with the given name or null if the NamedObjdoes not exist.
 */
public static NamedObj getScopedObject(NamedObj container,String name){
  if (name.equals("String_Node_Str")) {
    return container;
  }
  String[] parts=name.replaceAll("String_Node_Str","String_Node_Str").split("String_Node_Str");
  NamedObj result=null;
  boolean lookup=true;
  for (  String part : parts) {
    result=null;
    while (container != null) {
      Attribute attribute=container.getAttribute(part);
      if (attribute != null) {
        result=attribute;
      }
 else {
        if (container instanceof Entity) {
          Port port=((Entity)container).getPort(part);
          if (port != null) {
            result=port;
          }
 else           if (container instanceof CompositeEntity) {
            if (!(container instanceof LazyComposite)) {
              ComponentEntity entity=((CompositeEntity)container).getEntity(part);
              if (entity != null) {
                result=entity;
              }
 else {
                ComponentRelation relation=((CompositeEntity)container).getRelation(part);
                if (relation != null) {
                  result=relation;
                }
              }
            }
          }
        }
      }
      if (lookup && result == null) {
        List attributes=(container).attributeList(ContainmentExtender.class);
        Iterator attrIterator=attributes.iterator();
        NamedObj extendedContainer=null;
        while (extendedContainer == null && attrIterator.hasNext()) {
          ContainmentExtender extender=(ContainmentExtender)attrIterator.next();
          try {
            extendedContainer=extender.getExtendedContainer();
          }
 catch (          IllegalActionException e) {
          }
        }
        if (extendedContainer == null) {
          container=container.getContainer();
        }
 else {
          container=extendedContainer;
        }
      }
 else {
        break;
      }
    }
    if (result == null) {
      break;
    }
    container=result;
    lookup=false;
  }
  return result;
}