public void writeAnnotation(
      TypeKey annotationType, Collection<? extends AnnotationElement> elements) throws IOException {
    writer.writeEncodedValueHeader(ValueType.ANNOTATION, 0);
    writer.writeUleb128(typeSection.getItemIndex(annotationType));
    writer.writeUleb128(elements.size());

    Collection<? extends AnnotationElement> sortedElements =
        Ordering.from(BaseAnnotationElement.BY_NAME).immutableSortedCopy(elements);

    for (AnnotationElement element : sortedElements) {
      writer.writeUleb128(stringSection.getItemIndex(annotationSection.getElementName(element)));
      writeEncodedValue(annotationSection.getElementValue(element));
    }
  }
 public void writeArray(Collection<? extends EncodedValue> elements) throws IOException {
   writer.writeEncodedValueHeader(ValueType.ARRAY, 0);
   writer.writeUleb128(elements.size());
   for (EncodedValue element : elements) {
     writeEncodedValue(element);
   }
 }