private void incrementArraySize() {
   if (attributeVisitors == null) {
     attributeVisitors = new AttributeVisitor[1];
   } else {
     AttributeVisitor[] newAttributeVisitors = new AttributeVisitor[attributeVisitors.length + 1];
     System.arraycopy(attributeVisitors, 0, newAttributeVisitors, 0, attributeVisitors.length);
     attributeVisitors = newAttributeVisitors;
   }
 }
示例#2
0
  /** Adds a given annotation to the annotations attribute. */
  public void addAnnotation(Annotation annotation) {
    int annotationsCount = targetAnnotationsAttribute.u2annotationsCount;
    Annotation[] annotations = targetAnnotationsAttribute.annotations;

    // Make sure there is enough space for the new annotation.
    if (annotations.length <= annotationsCount) {
      targetAnnotationsAttribute.annotations = new Annotation[annotationsCount + 1];
      System.arraycopy(annotations, 0, targetAnnotationsAttribute.annotations, 0, annotationsCount);
      annotations = targetAnnotationsAttribute.annotations;
    }

    // Add the annotation.
    annotations[targetAnnotationsAttribute.u2annotationsCount++] = annotation;
  }