예제 #1
0
  void prune(ConstPool cp) {
    LinkedList newAttributes = new LinkedList();

    AttributeInfo invisibleAnnotations = getAttribute(AnnotationsAttribute.invisibleTag);
    if (invisibleAnnotations != null) {
      invisibleAnnotations = invisibleAnnotations.copy(cp, null);
      newAttributes.add(invisibleAnnotations);
    }

    AttributeInfo visibleAnnotations = getAttribute(AnnotationsAttribute.visibleTag);
    if (visibleAnnotations != null) {
      visibleAnnotations = visibleAnnotations.copy(cp, null);
      newAttributes.add(visibleAnnotations);
    }

    AttributeInfo parameterInvisibleAnnotations =
        getAttribute(ParameterAnnotationsAttribute.invisibleTag);
    if (parameterInvisibleAnnotations != null) {
      parameterInvisibleAnnotations = parameterInvisibleAnnotations.copy(cp, null);
      newAttributes.add(parameterInvisibleAnnotations);
    }

    AttributeInfo parameterVisibleAnnotations =
        getAttribute(ParameterAnnotationsAttribute.visibleTag);
    if (parameterVisibleAnnotations != null) {
      parameterVisibleAnnotations = parameterVisibleAnnotations.copy(cp, null);
      newAttributes.add(parameterVisibleAnnotations);
    }

    AnnotationDefaultAttribute defaultAttribute =
        (AnnotationDefaultAttribute) getAttribute(AnnotationDefaultAttribute.tag);
    if (defaultAttribute != null) newAttributes.add(defaultAttribute);

    ExceptionsAttribute ea = getExceptionsAttribute();
    if (ea != null) newAttributes.add(ea);

    AttributeInfo signature = getAttribute(SignatureAttribute.tag);
    if (signature != null) {
      signature = signature.copy(cp, null);
      newAttributes.add(signature);
    }

    attribute = newAttributes;
    name = cp.addUtf8Info(getName());
    descriptor = cp.addUtf8Info(getDescriptor());
    constPool = cp;
  }
예제 #2
0
  static LinkedList copyAll(LinkedList list, ConstPool cp) {
    if (list == null) return null;

    LinkedList newList = new LinkedList();
    int n = list.size();
    for (int i = 0; i < n; ++i) {
      AttributeInfo attr = (AttributeInfo) list.get(i);
      newList.add(attr.copy(cp, null));
    }

    return newList;
  }
예제 #3
0
  /**
   * Constructs a copy of <code>Code_attribute</code>. Specified class names are replaced during the
   * copy.
   *
   * @param cp constant pool table.
   * @param src source Code attribute.
   * @param classnames pairs of replaced and substituted class names.
   */
  private CodeAttribute(ConstPool cp, CodeAttribute src, Map classnames) throws BadBytecode {
    super(cp, tag);

    maxStack = src.getMaxStack();
    maxLocals = src.getMaxLocals();
    exceptions = src.getExceptionTable().copy(cp, classnames);
    attributes = new ArrayList();
    List src_attr = src.getAttributes();
    int num = src_attr.size();
    for (int i = 0; i < num; ++i) {
      AttributeInfo ai = (AttributeInfo) src_attr.get(i);
      attributes.add(ai.copy(cp, classnames));
    }

    info = src.copyCode(cp, classnames, exceptions, this);
  }