Пример #1
0
  /**
   * Changes the annotations represented by this object according to the given array of <code>
   * Annotation</code> objects.
   *
   * @param annotations the data structure representing the new annotations.
   */
  public void setAnnotations(Annotation[] annotations) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    AnnotationsWriter writer = new AnnotationsWriter(output, constPool);
    try {
      int n = annotations.length;
      writer.numAnnotations(n);
      for (int i = 0; i < n; ++i) annotations[i].write(writer);

      writer.close();
    } catch (IOException e) {
      throw new RuntimeException(e); // should never reach here.
    }

    set(output.toByteArray());
  }
Пример #2
0
 byte[] close() throws IOException {
   writer.close();
   return output.toByteArray();
 }