Program: 190830
Project: 190830
Buggy source:
/** 
 * Generate the proper schema fragment for the given element property into the specified schema compositor. The element property may or may not represent a collection and it may or may not be wrapped.
 * @param ep the element property
 * @param compositor the schema compositor (sequence or all)
 */
private void handleElementProp(ElementPropertyInfo<TypeT,ClassDeclT> ep,ExplicitGroup compositor){
  QName ename=ep.getXmlName();
  Occurs occurs=null;
  if (ep.isValueList()) {
    TypeRef t=ep.getTypes().get(0);
    LocalElement e=compositor.element();
    QName tn=t.getTagName();
    e.name(tn.getLocalPart());
    com.sun.xml.bind.v2.schemagen.xmlschema.List lst=e.simpleType().list();
    writeTypeRef(lst,t,"String_Node_Str");
    if (tn.getNamespaceURI().length() > 0)     e.form("String_Node_Str");
    return;
  }
  if (ep.isCollection()) {
    if (ename != null) {
      LocalElement e=compositor.element();
      if (ename.getNamespaceURI().length() > 0) {
        if (!ename.getNamespaceURI().equals(this.uri)) {
          e.ref(new QName(ename.getNamespaceURI(),ename.getLocalPart()));
          return;
        }
 else {
          e.form("String_Node_Str");
        }
      }
      ComplexType p=e.name(ename.getLocalPart()).complexType();
      if (ep.isCollectionNillable()) {
        e.nillable(true);
      }
 else {
        e.minOccurs(0);
      }
      if (ep.getTypes().size() == 1) {
        compositor=p.sequence();
      }
 else {
        compositor=p.choice();
        occurs=compositor;
      }
    }
 else {
      if (ep.getTypes().size() > 1) {
        compositor=compositor.choice();
        occurs=compositor;
      }
    }
  }
 else {
    if (ep.getTypes().size() > 1) {
      compositor=compositor.choice();
      occurs=compositor;
    }
  }
  boolean allNillable=true;
  for (  TypeRef t : ep.getTypes()) {
    LocalElement e=compositor.element();
    if (occurs == null)     occurs=e;
    QName tn=t.getTagName();
    e.name(tn.getLocalPart());
    writeTypeRef(e,t,"String_Node_Str");
    if (t.isNillable()) {
      e.nillable(true);
    }
 else {
      allNillable=false;
    }
    if (t.getDefaultValue() != null)     e._default(t.getDefaultValue());
    if (tn.getNamespaceURI().length() > 0)     e.form("String_Node_Str");
  }
  if (ep.isCollection()) {
    occurs.maxOccurs("String_Node_Str");
    occurs.minOccurs(0);
  }
 else {
    if (!ep.isRequired() && !allNillable) {
      occurs.minOccurs(0);
    }
  }
}

Fixed version (ground truth):
/** 
 * Generate the proper schema fragment for the given element property into the specified schema compositor. The element property may or may not represent a collection and it may or may not be wrapped.
 * @param ep the element property
 * @param compositor the schema compositor (sequence or all)
 */
private void handleElementProp(ElementPropertyInfo<TypeT,ClassDeclT> ep,ExplicitGroup compositor){
  QName ename=ep.getXmlName();
  Occurs occurs=null;
  if (ep.isValueList()) {
    TypeRef t=ep.getTypes().get(0);
    LocalElement e=compositor.element();
    QName tn=t.getTagName();
    e.name(tn.getLocalPart());
    com.sun.xml.bind.v2.schemagen.xmlschema.List lst=e.simpleType().list();
    writeTypeRef(lst,t,"String_Node_Str");
    if (tn.getNamespaceURI().length() > 0)     e.form("String_Node_Str");
    return;
  }
  if (ep.isCollection()) {
    if (ename != null) {
      LocalElement e=compositor.element();
      if (ename.getNamespaceURI().length() > 0) {
        if (!ename.getNamespaceURI().equals(this.uri)) {
          e.ref(new QName(ename.getNamespaceURI(),ename.getLocalPart()));
          return;
        }
 else {
          e.form("String_Node_Str");
        }
      }
      ComplexType p=e.name(ename.getLocalPart()).complexType();
      if (ep.isCollectionNillable()) {
        e.nillable(true);
      }
 else {
        e.minOccurs(0);
      }
      if (ep.getTypes().size() == 1) {
        compositor=p.sequence();
      }
 else {
        compositor=p.choice();
        occurs=compositor;
      }
    }
 else {
      if (ep.getTypes().size() > 1) {
        compositor=compositor.choice();
        occurs=compositor;
      }
    }
  }
 else {
    if (ep.getTypes().size() > 1) {
      compositor=compositor.choice();
      occurs=compositor;
    }
  }
  boolean allNillable=true;
  for (  TypeRef t : ep.getTypes()) {
    LocalElement e=compositor.element();
    if (occurs == null)     occurs=e;
    QName tn=t.getTagName();
    boolean useElementRef=false;
    if (t.getTarget() instanceof Element) {
      Element te=(Element)t.getTarget();
      QName targetTagName=te.getElementName();
      useElementRef=targetTagName != null && targetTagName.equals(tn);
    }
    if (t.isNillable() || t.getDefaultValue() != null)     useElementRef=false;
    if (useElementRef) {
      e.ref(tn);
    }
 else {
      e.name(tn.getLocalPart());
      writeTypeRef(e,t,"String_Node_Str");
      if (tn.getNamespaceURI().length() > 0)       e.form("String_Node_Str");
    }
    if (t.isNillable()) {
      e.nillable(true);
    }
 else {
      allNillable=false;
    }
    if (t.getDefaultValue() != null)     e._default(t.getDefaultValue());
  }
  if (ep.isCollection()) {
    occurs.maxOccurs("String_Node_Str");
    occurs.minOccurs(0);
  }
 else {
    if (!ep.isRequired() && !allNillable) {
      occurs.minOccurs(0);
    }
  }
}