示例#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());
  }
  /**
   * 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());
  }
示例#3
0
 int arrayMemberValue(int pos, int num) throws Exception {
   writer.arrayValue(num);
   return super.arrayMemberValue(pos, num);
 }
示例#4
0
 int annotationMemberValue(int pos) throws Exception {
   writer.annotationValue();
   return super.annotationMemberValue(pos);
 }
示例#5
0
 void classMemberValue(int pos, int index) throws Exception {
   writer.classInfoIndex(copyType(index));
   super.classMemberValue(pos, index);
 }
示例#6
0
 void enumMemberValue(int pos, int typeNameIndex, int constNameIndex) throws Exception {
   writer.enumConstValue(copyType(typeNameIndex), copy(constNameIndex));
   super.enumMemberValue(pos, typeNameIndex, constNameIndex);
 }
示例#7
0
 void constValueMember(int tag, int index) throws Exception {
   writer.constValueIndex(tag, copy(index));
   super.constValueMember(tag, index);
 }
示例#8
0
 int memberValuePair(int pos, int nameIndex) throws Exception {
   writer.memberValuePair(copy(nameIndex));
   return super.memberValuePair(pos, nameIndex);
 }
示例#9
0
 int annotation(int pos, int type, int numPairs) throws Exception {
   writer.annotation(copyType(type), numPairs);
   return super.annotation(pos, type, numPairs);
 }
示例#10
0
 int annotationArray(int pos, int num) throws Exception {
   writer.numAnnotations(num);
   return super.annotationArray(pos, num);
 }
示例#11
0
 void parameters(int numParam, int pos) throws Exception {
   writer.numParameters(numParam);
   super.parameters(numParam, pos);
 }
示例#12
0
 byte[] close() throws IOException {
   writer.close();
   return output.toByteArray();
 }
示例#13
0
 /** Writes the value. */
 public void write(AnnotationsWriter writer) throws IOException {
   writer.constValueIndex(getValue());
 }
示例#14
0
 @Override
 public void write(final AnnotationsWriter writer) throws IOException {
   writer.annotationValue();
   this.value.write(writer);
 }