Program: 23100
Project: 23100
Buggy source:
private void generateCoreElemExtension(StringBuilder b,List<ElementDefinition> elements,ElementDefinition elem,List<ElementDefinition> children,int indent,String pathName,boolean asValue,TypeRefComponent type,boolean last,boolean complex) throws Exception {
  if (elem.getMax().equals("String_Node_Str"))   return;
  String name=tail(elem.getPath());
  String en=asValue ? "String_Node_Str" : name;
  if (en.contains("String_Node_Str"))   en=en.replace("String_Node_Str",upFirst(type.getCode()));
  boolean unbounded=elem.hasMax() && elem.getMax().equals("String_Node_Str");
  String indentS="String_Node_Str";
  for (int i=0; i < indent; i++) {
    indentS+="String_Node_Str";
  }
  b.append(indentS + "String_Node_Str");
  List<ElementDefinition> slices=getSlices(elem,children);
  int c=0;
  for (  ElementDefinition slice : slices) {
    String url=slice.getTypeFirstRep().getProfile().get(0).getValue();
    StructureDefinition sdExt=url == null ? null : context.fetchResource(StructureDefinition.class,url);
    b.append(indentS + "String_Node_Str");
    b.append("String_Node_Str");
    writeCardinality(unbounded,b,slice);
    b.append(Utilities.escapeXml(slice.getShort()) + "String_Node_Str");
    b.append("String_Node_Str");
    b.append(indentS + "String_Node_Str");
    if (sdExt == null)     b.append("String_Node_Str" + url + "String_Node_Str");
 else     b.append("String_Node_Str" + sdExt.getUserString("String_Node_Str") + "String_Node_Str"+ url+ "String_Node_Str");
    List<ElementDefinition> extchildren=getChildren(elements,slice);
    if (extchildren.isEmpty()) {
      if (sdExt == null)       b.append("String_Node_Str" + url + "String_Node_Str");
 else       extchildren=getChildren(sdExt.getSnapshot().getElement(),sdExt.getSnapshot().getElementFirstRep());
    }
    ElementDefinition value=getValue(extchildren);
    if (value != null) {
      if (value.getType().size() == 1)       generateCoreElem(b,elements,value,indent + 2,pathName + "String_Node_Str" + en,false,value.getType().get(0),true,false);
 else {
        b.append("String_Node_Str" + Utilities.escapeXml(value.getShort()) + "String_Node_Str"+ Integer.toString(value.getType().size())+ "String_Node_Str");
        for (        TypeRefComponent t : value.getType())         generateCoreElem(b,elements,value,indent + 2,pathName + "String_Node_Str" + en,false,t,t == value.getType().get(value.getType().size() - 1),false);
      }
    }
 else {
      b.append("String_Node_Str" + url + "String_Node_Str");
    }
    c++;
    b.append(indentS);
    if (c == slices.size())     b.append("String_Node_Str");
 else     b.append("String_Node_Str");
  }
  b.append(indentS);
  if (last)   b.append("String_Node_Str");
 else   b.append("String_Node_Str");
}

Fixed version (ground truth):
private void generateCoreElemExtension(StringBuilder b,List<ElementDefinition> elements,ElementDefinition elem,List<ElementDefinition> children,int indent,String pathName,boolean asValue,TypeRefComponent type,boolean last,boolean complex) throws Exception {
  if (elem.getMax().equals("String_Node_Str"))   return;
  String name=tail(elem.getPath());
  String en=asValue ? "String_Node_Str" : name;
  if (en.contains("String_Node_Str"))   en=en.replace("String_Node_Str",upFirst(type.getCode()));
  boolean unbounded=elem.hasMax() && elem.getMax().equals("String_Node_Str");
  String indentS="String_Node_Str";
  for (int i=0; i < indent; i++) {
    indentS+="String_Node_Str";
  }
  b.append(indentS + "String_Node_Str");
  List<ElementDefinition> slices=getSlices(elem,children);
  int c=0;
  for (  ElementDefinition slice : slices) {
    List<UriType> profiles=slice.getTypeFirstRep().getProfile();
    String url=profiles.isEmpty() ? null : profiles.get(0).getValue();
    StructureDefinition sdExt=url == null ? null : context.fetchResource(StructureDefinition.class,url);
    b.append(indentS + "String_Node_Str");
    b.append("String_Node_Str");
    writeCardinality(unbounded,b,slice);
    b.append(Utilities.escapeXml(slice.getShort()) + "String_Node_Str");
    b.append("String_Node_Str");
    b.append(indentS + "String_Node_Str");
    if (sdExt == null)     b.append("String_Node_Str" + url + "String_Node_Str");
 else     b.append("String_Node_Str" + sdExt.getUserString("String_Node_Str") + "String_Node_Str"+ url+ "String_Node_Str");
    List<ElementDefinition> extchildren=getChildren(elements,slice);
    if (extchildren.isEmpty()) {
      if (sdExt == null)       b.append("String_Node_Str" + url + "String_Node_Str");
 else       extchildren=getChildren(sdExt.getSnapshot().getElement(),sdExt.getSnapshot().getElementFirstRep());
    }
    ElementDefinition value=getValue(extchildren);
    if (value != null) {
      if (value.getType().size() == 1)       generateCoreElem(b,elements,value,indent + 2,pathName + "String_Node_Str" + en,false,value.getType().get(0),true,false);
 else {
        b.append("String_Node_Str" + Utilities.escapeXml(value.getShort()) + "String_Node_Str"+ Integer.toString(value.getType().size())+ "String_Node_Str");
        for (        TypeRefComponent t : value.getType())         generateCoreElem(b,elements,value,indent + 2,pathName + "String_Node_Str" + en,false,t,t == value.getType().get(value.getType().size() - 1),false);
      }
    }
 else {
      b.append("String_Node_Str" + url + "String_Node_Str");
    }
    c++;
    b.append(indentS);
    if (c == slices.size())     b.append("String_Node_Str");
 else     b.append("String_Node_Str");
  }
  b.append(indentS);
  if (last)   b.append("String_Node_Str");
 else   b.append("String_Node_Str");
}