Program: 177144
Project: 177144
Buggy source:
/** 
 * Load the qname of the referenced root element declaration.
 * @return the qname of the referenced root element declaration.
 */
protected QName loadRef(){
  TypeDeclaration declaration=null;
  String elementDeclaration;
  try {
    if ((xmlElementRef != null) && (xmlElementRef.type() != XmlElementRef.DEFAULT.class)) {
      Class typeClass=xmlElementRef.type();
      elementDeclaration=typeClass.getName();
      declaration=getEnv().getTypeDeclaration(typeClass.getName());
    }
 else {
      TypeMirror accessorType=getBareAccessorType();
      elementDeclaration=accessorType.toString();
      if (accessorType instanceof DeclaredType) {
        declaration=((DeclaredType)accessorType).getDeclaration();
      }
    }
  }
 catch (  MirroredTypeException e) {
    TypeMirror typeMirror=e.getTypeMirror();
    elementDeclaration=typeMirror.toString();
    if (typeMirror instanceof DeclaredType) {
      declaration=((DeclaredType)typeMirror).getDeclaration();
    }
  }
  QName refQName=null;
  if (declaration instanceof ClassDeclaration) {
    if (declaration.getQualifiedName().equals(JAXBElement.class.getName())) {
      String localName=xmlElementRef != null && !"String_Node_Str".equals(xmlElementRef.name()) ? xmlElementRef.name() : null;
      String namespace=xmlElementRef != null ? xmlElementRef.namespace() : "String_Node_Str";
      if (localName == null) {
        throw new ValidationException(getPosition(),"String_Node_Str" + getName() + "String_Node_Str"+ getTypeDefinition().getQualifiedName()+ "String_Node_Str");
      }
      refQName=new QName(namespace,localName);
    }
 else     if (declaration.getAnnotation(XmlRootElement.class) != null) {
      ClassDeclaration classDeclaration=(ClassDeclaration)declaration;
      RootElementDeclaration refElement=new RootElementDeclaration(classDeclaration,((EnunciateFreemarkerModel)FreemarkerModel.get()).findTypeDefinition(classDeclaration));
      refQName=new QName(refElement.getNamespace(),refElement.getName());
    }
  }
  if (refQName == null) {
    throw new ValidationException(getPosition(),"String_Node_Str" + getSimpleName() + "String_Node_Str"+ getTypeDefinition().getQualifiedName()+ "String_Node_Str"+ elementDeclaration+ "String_Node_Str");
  }
  return refQName;
}

Fixed version (ground truth):
/** 
 * Load the qname of the referenced root element declaration.
 * @return the qname of the referenced root element declaration.
 */
protected QName loadRef(){
  TypeDeclaration declaration=null;
  String elementDeclaration;
  DecoratedTypeMirror refType;
  try {
    if ((xmlElementRef != null) && (xmlElementRef.type() != XmlElementRef.DEFAULT.class)) {
      Class typeClass=xmlElementRef.type();
      elementDeclaration=typeClass.getName();
      declaration=getEnv().getTypeDeclaration(typeClass.getName());
      refType=(DecoratedTypeMirror)TypeMirrorDecorator.decorate(getEnv().getTypeUtils().getDeclaredType(declaration));
    }
 else {
      TypeMirror accessorType=getBareAccessorType();
      elementDeclaration=accessorType.toString();
      if (accessorType instanceof DeclaredType) {
        declaration=((DeclaredType)accessorType).getDeclaration();
      }
      refType=(DecoratedTypeMirror)TypeMirrorDecorator.decorate(accessorType);
    }
  }
 catch (  MirroredTypeException e) {
    TypeMirror typeMirror=e.getTypeMirror();
    elementDeclaration=typeMirror.toString();
    if (typeMirror instanceof DeclaredType) {
      declaration=((DeclaredType)typeMirror).getDeclaration();
    }
    refType=(DecoratedTypeMirror)TypeMirrorDecorator.decorate(typeMirror);
  }
  QName refQName=null;
  if (refType.isInstanceOf(JAXBElement.class.getName())) {
    String localName=xmlElementRef != null && !"String_Node_Str".equals(xmlElementRef.name()) ? xmlElementRef.name() : null;
    String namespace=xmlElementRef != null ? xmlElementRef.namespace() : "String_Node_Str";
    if (localName == null) {
      throw new ValidationException(getPosition(),"String_Node_Str" + getName() + "String_Node_Str"+ getTypeDefinition().getQualifiedName()+ "String_Node_Str");
    }
    refQName=new QName(namespace,localName);
  }
 else   if (declaration instanceof ClassDeclaration && declaration.getAnnotation(XmlRootElement.class) != null) {
    ClassDeclaration classDeclaration=(ClassDeclaration)declaration;
    RootElementDeclaration refElement=new RootElementDeclaration(classDeclaration,((EnunciateFreemarkerModel)FreemarkerModel.get()).findTypeDefinition(classDeclaration));
    refQName=new QName(refElement.getNamespace(),refElement.getName());
  }
  if (refQName == null) {
    throw new ValidationException(getPosition(),"String_Node_Str" + getSimpleName() + "String_Node_Str"+ getTypeDefinition().getQualifiedName()+ "String_Node_Str"+ elementDeclaration+ "String_Node_Str");
  }
  return refQName;
}