/**
   * Changes the annotations represented by this object according to the given array of <code>
   * Annotation</code> objects.
   *
   * @param params the data structure representing the new annotations. Every element of this array
   *     is an array of <code>Annotation</code> and it represens annotations of each method
   *     parameter.
   */
  public void setAnnotations(Annotation[][] params) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    AnnotationsWriter writer = new AnnotationsWriter(output, constPool);
    try {
      int n = params.length;
      writer.numParameters(n);
      for (int i = 0; i < n; ++i) {
        Annotation[] anno = params[i];
        writer.numAnnotations(anno.length);
        for (int j = 0; j < anno.length; ++j) anno[j].write(writer);
      }

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

    set(output.toByteArray());
  }
예제 #2
0
 void parameters(int numParam, int pos) throws Exception {
   writer.numParameters(numParam);
   super.parameters(numParam, pos);
 }