Program: 160595
Project: 160595
Buggy source:
@Override protected boolean write(OutputStream outputStream) throws SerializerException {
  try {
    if (out == null) {
      out=new UTF8PrintWriter(outputStream);
    }
    if (mode == Mode.HEADER) {
      out.write("String_Node_Str");
      out.write("String_Node_Str");
      mode=Mode.BODY;
      iterator=getModel().iterator();
      return true;
    }
 else     if (mode == Mode.BODY) {
      if (iterator.hasNext()) {
        IdEObject object=iterator.next();
        if (object.eClass().getEAnnotation("String_Node_Str") == null) {
          if (!firstObject) {
            out.write("String_Node_Str");
          }
 else {
            firstObject=false;
          }
          if (((IdEObjectImpl)object).getLoadingState() != State.LOADED) {
            out.write("String_Node_Str");
            out.write("String_Node_Str" + object.getOid() + "String_Node_Str");
            out.write("String_Node_Str" + object.eClass().getName() + "String_Node_Str");
            out.write("String_Node_Str");
            out.write("String_Node_Str");
          }
 else {
            out.write("String_Node_Str");
            out.write("String_Node_Str" + object.getOid() + "String_Node_Str");
            out.write("String_Node_Str" + object.eClass().getName() + "String_Node_Str");
            out.write("String_Node_Str");
            boolean firstF=true;
            for (            EStructuralFeature eStructuralFeature : object.eClass().getEAllStructuralFeatures()) {
              if (eStructuralFeature.getEAnnotation("String_Node_Str") == null) {
                if (eStructuralFeature instanceof EReference) {
                  Object value=object.eGet(eStructuralFeature);
                  if (value != null) {
                    if (eStructuralFeature.isMany()) {
                      List<?> list=(List<?>)value;
                      if (serializerEmptyLists || !list.isEmpty()) {
                        if (firstF) {
                          firstF=false;
                        }
 else {
                          out.write("String_Node_Str");
                        }
                        int wrapped=0;
                        int referred=0;
                        for (                        Object o : list) {
                          if (((IdEObject)o).eClass().getEAnnotation("String_Node_Str") != null) {
                            wrapped++;
                          }
 else {
                            referred++;
                          }
                        }
                        if (wrapped == 0 && referred != 0) {
                          out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        }
 else                         if (wrapped != 0 && referred == 0) {
                          out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        }
 else                         if (wrapped == 0 && referred == 0) {
                        }
 else {
                          out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        }
                        boolean f=true;
                        for (                        Object o : list) {
                          if (!f) {
                            out.write("String_Node_Str");
                          }
 else {
                            f=false;
                          }
                          IdEObject ref=(IdEObject)o;
                          if (ref.getOid() == -1) {
                            writeObject(out,ref);
                          }
 else {
                            if (wrapped != 0 && referred != 0) {
                              out.write("String_Node_Str");
                              out.write("String_Node_Str");
                              out.write("String_Node_Str" + ref.getOid());
                              out.write("String_Node_Str");
                            }
 else {
                              out.write("String_Node_Str" + ref.getOid());
                            }
                          }
                        }
                        out.write("String_Node_Str");
                      }
                    }
 else {
                      if (firstF) {
                        firstF=false;
                      }
 else {
                        out.write("String_Node_Str");
                      }
                      IdEObject ref=(IdEObject)value;
                      if (ref instanceof IfcGloballyUniqueId) {
                        out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        writePrimitive(out,eStructuralFeature,((IfcGloballyUniqueId)ref).getWrappedValue());
                      }
 else                       if (((IdEObject)ref).eClass().getEAnnotation("String_Node_Str") != null) {
                        out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        writeObject(out,ref);
                      }
 else {
                        out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str"+ ref.getOid());
                      }
                    }
                  }
                }
 else {
                  Object value=object.eGet(eStructuralFeature);
                  if (value != null) {
                    if (eStructuralFeature.isMany()) {
                      List<?> list=(List<?>)value;
                      if (serializerEmptyLists || !list.isEmpty()) {
                        if (firstF) {
                          firstF=false;
                        }
 else {
                          out.write("String_Node_Str");
                        }
                        out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        boolean f=true;
                        for (                        Object o : list) {
                          if (!f) {
                            out.write("String_Node_Str");
                          }
 else {
                            f=false;
                          }
                          writePrimitive(out,eStructuralFeature,o);
                        }
                        out.write("String_Node_Str");
                      }
                    }
 else {
                      if (firstF) {
                        firstF=false;
                      }
 else {
                        out.write("String_Node_Str");
                      }
                      out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                      writePrimitive(out,eStructuralFeature,value);
                    }
                  }
                }
              }
            }
            out.write("String_Node_Str");
          }
        }
        return true;
      }
 else {
        mode=Mode.FOOTER;
        return true;
      }
    }
 else     if (mode == Mode.FOOTER) {
      out.write("String_Node_Str");
      out.write("String_Node_Str");
      out.flush();
      mode=Mode.DONE;
      return false;
    }
  }
 catch (  Throwable e) {
    throw new SerializerException(e);
  }
  return false;
}

Fixed version (ground truth):
@Override protected boolean write(OutputStream outputStream) throws SerializerException {
  try {
    if (out == null) {
      out=new UTF8PrintWriter(outputStream);
    }
    if (mode == Mode.HEADER) {
      out.write("String_Node_Str");
      out.write("String_Node_Str");
      mode=Mode.BODY;
      iterator=getModel().iterator();
      return true;
    }
 else     if (mode == Mode.BODY) {
      if (iterator.hasNext()) {
        IdEObject object=iterator.next();
        if (object.eClass().getEAnnotation("String_Node_Str") == null) {
          if (!firstObject) {
            out.write("String_Node_Str");
          }
 else {
            firstObject=false;
          }
          if (((IdEObjectImpl)object).getLoadingState() != State.LOADED) {
            out.write("String_Node_Str");
            out.write("String_Node_Str" + object.getOid() + "String_Node_Str");
            out.write("String_Node_Str" + object.eClass().getName() + "String_Node_Str");
            out.write("String_Node_Str");
            out.write("String_Node_Str");
          }
 else {
            out.write("String_Node_Str");
            out.write("String_Node_Str" + object.getOid() + "String_Node_Str");
            out.write("String_Node_Str" + object.eClass().getName() + "String_Node_Str");
            out.write("String_Node_Str");
            boolean firstF=true;
            for (            EStructuralFeature eStructuralFeature : object.eClass().getEAllStructuralFeatures()) {
              if (eStructuralFeature.getEAnnotation("String_Node_Str") == null && eStructuralFeature.getEAnnotation("String_Node_Str") == null) {
                if (eStructuralFeature instanceof EReference) {
                  Object value=object.eGet(eStructuralFeature);
                  if (value != null) {
                    if (eStructuralFeature.isMany()) {
                      List<?> list=(List<?>)value;
                      if (serializerEmptyLists || !list.isEmpty()) {
                        if (firstF) {
                          firstF=false;
                        }
 else {
                          out.write("String_Node_Str");
                        }
                        int wrapped=0;
                        int referred=0;
                        for (                        Object o : list) {
                          if (((IdEObject)o).eClass().getEAnnotation("String_Node_Str") != null) {
                            wrapped++;
                          }
 else {
                            referred++;
                          }
                        }
                        if (wrapped == 0 && referred != 0) {
                          out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        }
 else                         if (wrapped != 0 && referred == 0) {
                          out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        }
 else                         if (wrapped == 0 && referred == 0) {
                        }
 else {
                          out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        }
                        boolean f=true;
                        for (                        Object o : list) {
                          if (!f) {
                            out.write("String_Node_Str");
                          }
 else {
                            f=false;
                          }
                          IdEObject ref=(IdEObject)o;
                          if (ref.getOid() == -1) {
                            writeObject(out,ref);
                          }
 else {
                            if (wrapped != 0 && referred != 0) {
                              out.write("String_Node_Str");
                              out.write("String_Node_Str");
                              out.write("String_Node_Str" + ref.getOid());
                              out.write("String_Node_Str");
                            }
 else {
                              out.write("String_Node_Str" + ref.getOid());
                            }
                          }
                        }
                        out.write("String_Node_Str");
                      }
                    }
 else {
                      if (firstF) {
                        firstF=false;
                      }
 else {
                        out.write("String_Node_Str");
                      }
                      IdEObject ref=(IdEObject)value;
                      if (ref instanceof IfcGloballyUniqueId) {
                        out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        writePrimitive(out,eStructuralFeature,((IfcGloballyUniqueId)ref).getWrappedValue());
                      }
 else                       if (((IdEObject)ref).eClass().getEAnnotation("String_Node_Str") != null) {
                        out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        writeObject(out,ref);
                      }
 else {
                        out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str"+ ref.getOid());
                      }
                    }
                  }
                }
 else {
                  Object value=object.eGet(eStructuralFeature);
                  if (value != null) {
                    if (eStructuralFeature.isMany()) {
                      List<?> list=(List<?>)value;
                      if (serializerEmptyLists || !list.isEmpty()) {
                        if (firstF) {
                          firstF=false;
                        }
 else {
                          out.write("String_Node_Str");
                        }
                        out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                        boolean f=true;
                        for (                        Object o : list) {
                          if (!f) {
                            out.write("String_Node_Str");
                          }
 else {
                            f=false;
                          }
                          writePrimitive(out,eStructuralFeature,o);
                        }
                        out.write("String_Node_Str");
                      }
                    }
 else {
                      if (firstF) {
                        firstF=false;
                      }
 else {
                        out.write("String_Node_Str");
                      }
                      out.write("String_Node_Str" + eStructuralFeature.getName() + "String_Node_Str");
                      writePrimitive(out,eStructuralFeature,value);
                    }
                  }
                }
              }
            }
            out.write("String_Node_Str");
          }
        }
        return true;
      }
 else {
        mode=Mode.FOOTER;
        return true;
      }
    }
 else     if (mode == Mode.FOOTER) {
      out.write("String_Node_Str");
      out.write("String_Node_Str");
      out.flush();
      mode=Mode.DONE;
      return false;
    }
  }
 catch (  Throwable e) {
    throw new SerializerException(e);
  }
  return false;
}