com.android.dx.rop.annotation.AnnotationsList Java Examples

The following examples show how to use com.android.dx.rop.annotation.AnnotationsList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationParser.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Parses a parameter annotation attribute.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotations
 * @return {@code non-null;} the parsed list of lists of annotations
 */
public AnnotationsList parseParameterAttribute(
        AnnotationVisibility visibility) {
    AnnotationsList result;

    try {
        result = parseAnnotationsList(visibility);

        if (input.available() != 0) {
            throw new ParseException("extra data in attribute");
        }
    } catch (IOException ex) {
        // ByteArray.MyDataInputStream should never throw.
        throw new RuntimeException("shouldn't happen", ex);
    }

    return result;
}
 
Example #2
Source File: AnnotationParser.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Parses a parameter annotation attribute.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotations
 * @return {@code non-null;} the parsed list of lists of annotations
 */
public AnnotationsList parseParameterAttribute(
        AnnotationVisibility visibility) {
    AnnotationsList result;

    try {
        result = parseAnnotationsList(visibility);

        if (input.available() != 0) {
            throw new ParseException("extra data in attribute");
        }
    } catch (IOException ex) {
        // ByteArray.MyDataInputStream should never throw.
        throw new RuntimeException("shouldn't happen", ex);
    }

    return result;
}
 
Example #3
Source File: BaseParameterAnnotations.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param attributeName {@code non-null;} the name of the attribute
 * @param parameterAnnotations {@code non-null;} the annotations
 * @param byteLength {@code >= 0;} attribute data length in the original
 * classfile (not including the attribute header)
 */
public BaseParameterAnnotations(String attributeName,
        AnnotationsList parameterAnnotations, int byteLength) {
    super(attributeName);

    try {
        if (parameterAnnotations.isMutable()) {
            throw new MutabilityException(
                    "parameterAnnotations.isMutable()");
        }
    } catch (NullPointerException ex) {
        // Translate the exception.
        throw new NullPointerException("parameterAnnotations == null");
    }

    this.parameterAnnotations = parameterAnnotations;
    this.byteLength = byteLength;
}
 
Example #4
Source File: BaseParameterAnnotations.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param attributeName {@code non-null;} the name of the attribute
 * @param parameterAnnotations {@code non-null;} the annotations
 * @param byteLength {@code >= 0;} attribute data length in the original
 * classfile (not including the attribute header)
 */
public BaseParameterAnnotations(String attributeName,
        AnnotationsList parameterAnnotations, int byteLength) {
    super(attributeName);

    try {
        if (parameterAnnotations.isMutable()) {
            throw new MutabilityException(
                    "parameterAnnotations.isMutable()");
        }
    } catch (NullPointerException ex) {
        // Translate the exception.
        throw new NullPointerException("parameterAnnotations == null");
    }

    this.parameterAnnotations = parameterAnnotations;
    this.byteLength = byteLength;
}
 
Example #5
Source File: BaseParameterAnnotations.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param attributeName {@code non-null;} the name of the attribute
 * @param parameterAnnotations {@code non-null;} the annotations
 * @param byteLength {@code >= 0;} attribute data length in the original
 * classfile (not including the attribute header)
 */
public BaseParameterAnnotations(String attributeName,
        AnnotationsList parameterAnnotations, int byteLength) {
    super(attributeName);

    try {
        if (parameterAnnotations.isMutable()) {
            throw new MutabilityException(
                    "parameterAnnotations.isMutable()");
        }
    } catch (NullPointerException ex) {
        // Translate the exception.
        throw new NullPointerException("parameterAnnotations == null");
    }

    this.parameterAnnotations = parameterAnnotations;
    this.byteLength = byteLength;
}
 
Example #6
Source File: AnnotationParser.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Parses a parameter annotation attribute.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotations
 * @return {@code non-null;} the parsed list of lists of annotations
 */
public AnnotationsList parseParameterAttribute(
        AnnotationVisibility visibility) {
    AnnotationsList result;

    try {
        result = parseAnnotationsList(visibility);

        if (input.available() != 0) {
            throw new ParseException("extra data in attribute");
        }
    } catch (IOException ex) {
        // ByteArray.MyDataInputStream should never throw.
        throw new RuntimeException("shouldn't happen", ex);
    }

    return result;
}
 
Example #7
Source File: BaseParameterAnnotations.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param attributeName {@code non-null;} the name of the attribute
 * @param parameterAnnotations {@code non-null;} the annotations
 * @param byteLength {@code >= 0;} attribute data length in the original
 * classfile (not including the attribute header)
 */
public BaseParameterAnnotations(String attributeName,
        AnnotationsList parameterAnnotations, int byteLength) {
    super(attributeName);

    try {
        if (parameterAnnotations.isMutable()) {
            throw new MutabilityException(
                    "parameterAnnotations.isMutable()");
        }
    } catch (NullPointerException ex) {
        // Translate the exception.
        throw new NullPointerException("parameterAnnotations == null");
    }

    this.parameterAnnotations = parameterAnnotations;
    this.byteLength = byteLength;
}
 
Example #8
Source File: AnnotationParser.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Parses a parameter annotation attribute.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotations
 * @return {@code non-null;} the parsed list of lists of annotations
 */
public AnnotationsList parseParameterAttribute(
        AnnotationVisibility visibility) {
    AnnotationsList result;

    try {
        result = parseAnnotationsList(visibility);

        if (input.available() != 0) {
            throw new ParseException("extra data in attribute");
        }
    } catch (IOException ex) {
        // ByteArray.MyDataInputStream should never throw.
        throw new RuntimeException("shouldn't happen", ex);
    }

    return result;
}
 
Example #9
Source File: StdAttributeFactory.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a {@code RuntimeInvisibleParameterAnnotations} attribute.
 */
private Attribute runtimeInvisibleParameterAnnotations(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    AnnotationsList list =
        ap.parseParameterAttribute(AnnotationVisibility.BUILD);

    return new AttRuntimeInvisibleParameterAnnotations(list, length);
}
 
Example #10
Source File: AnnotationParser.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a list of annotation lists.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotations
 * @return {@code non-null;} the list of annotation lists read from the attribute
 * data
 */
private AnnotationsList parseAnnotationsList(
        AnnotationVisibility visibility) throws IOException {
    int count = input.readUnsignedByte();

    if (observer != null) {
        parsed(1, "num_parameters: " + Hex.u1(count));
    }

    AnnotationsList outerList = new AnnotationsList(count);

    for (int i = 0; i < count; i++) {
        if (observer != null) {
            parsed(0, "parameter_annotations[" + i + "]:");
            changeIndent(1);
        }

        Annotations annotations = parseAnnotations(visibility);
        outerList.set(i, annotations);

        if (observer != null) {
            observer.changeIndent(-1);
        }
    }

    outerList.setImmutable();
    return outerList;
}
 
Example #11
Source File: StdAttributeFactory.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a {@code RuntimeInvisibleParameterAnnotations} attribute.
 */
private Attribute runtimeInvisibleParameterAnnotations(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    AnnotationsList list =
        ap.parseParameterAttribute(AnnotationVisibility.BUILD);

    return new AttRuntimeInvisibleParameterAnnotations(list, length);
}
 
Example #12
Source File: StdAttributeFactory.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a {@code RuntimeVisibleParameterAnnotations} attribute.
 */
private Attribute runtimeVisibleParameterAnnotations(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    AnnotationsList list =
        ap.parseParameterAttribute(AnnotationVisibility.RUNTIME);

    return new AttRuntimeVisibleParameterAnnotations(list, length);
}
 
Example #13
Source File: AttributeTranslator.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the parameter annotations out of a given method. This
 * combines both visible and invisible annotations into a single
 * result set.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of annotation sets, which may be
 * empty
 */
public static AnnotationsList getParameterAnnotations(Method method) {
    AttributeList attribs = method.getAttributes();
    AttRuntimeVisibleParameterAnnotations visible =
        (AttRuntimeVisibleParameterAnnotations)
        attribs.findFirst(
                AttRuntimeVisibleParameterAnnotations.ATTRIBUTE_NAME);
    AttRuntimeInvisibleParameterAnnotations invisible =
        (AttRuntimeInvisibleParameterAnnotations)
        attribs.findFirst(
                AttRuntimeInvisibleParameterAnnotations.ATTRIBUTE_NAME);

    if (visible == null) {
        if (invisible == null) {
            return AnnotationsList.EMPTY;
        }
        return invisible.getParameterAnnotations();
    }

    if (invisible == null) {
        return visible.getParameterAnnotations();
    }

    // Both are non-null, so combine them.

    return AnnotationsList.combine(visible.getParameterAnnotations(),
            invisible.getParameterAnnotations());
}
 
Example #14
Source File: AnnotationsDirectoryItem.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a parameter annotations item to this instance.
 *
 * @param method {@code non-null;} method in question
 * @param list {@code non-null;} associated list of annotation sets to add
 * @param dexFile {@code non-null;} dex output
 */
public void addParameterAnnotations(CstMethodRef method,
        AnnotationsList list, DexFile dexFile) {
    if (parameterAnnotations == null) {
        parameterAnnotations = new ArrayList<ParameterAnnotationStruct>();
    }

    parameterAnnotations.add(new ParameterAnnotationStruct(method, list, dexFile));
}
 
Example #15
Source File: AnnotationsDirectoryItem.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the parameter annotations for a given method, if any. This is
 * meant for use by debugging / dumping code.
 *
 * @param method {@code non-null;} the method
 * @return {@code null-ok;} the parameter annotations, if any
 */
public AnnotationsList getParameterAnnotations(CstMethodRef method) {
    if (parameterAnnotations == null) {
        return null;
    }

    for (ParameterAnnotationStruct item : parameterAnnotations) {
        if (item.getMethod().equals(method)) {
            return item.getAnnotationsList();
        }
    }

    return null;
}
 
Example #16
Source File: ParameterAnnotationStruct.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param method {@code non-null;} the method in question
 * @param annotationsList {@code non-null;} the associated annotations list
 * @param dexFile {@code non-null;} dex output
 */
public ParameterAnnotationStruct(CstMethodRef method,
        AnnotationsList annotationsList, DexFile dexFile) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    if (annotationsList == null) {
        throw new NullPointerException("annotationsList == null");
    }

    this.method = method;
    this.annotationsList = annotationsList;

    /*
     * Construct an item for the annotations list. TODO: This
     * requires way too much copying; fix it.
     */

    int size = annotationsList.size();
    ArrayList<AnnotationSetRefItem> arrayList = new
        ArrayList<AnnotationSetRefItem>(size);

    for (int i = 0; i < size; i++) {
        Annotations annotations = annotationsList.get(i);
        AnnotationSetItem item = new AnnotationSetItem(annotations, dexFile);
        arrayList.add(new AnnotationSetRefItem(item));
    }

    this.annotationsItem = new UniformListItem<AnnotationSetRefItem>(
            ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList);
}
 
Example #17
Source File: AnnotationParser.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a list of annotation lists.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotations
 * @return {@code non-null;} the list of annotation lists read from the attribute
 * data
 */
private AnnotationsList parseAnnotationsList(
        AnnotationVisibility visibility) throws IOException {
    int count = input.readUnsignedByte();

    if (observer != null) {
        parsed(1, "num_parameters: " + Hex.u1(count));
    }

    AnnotationsList outerList = new AnnotationsList(count);

    for (int i = 0; i < count; i++) {
        if (observer != null) {
            parsed(0, "parameter_annotations[" + i + "]:");
            changeIndent(1);
        }

        Annotations annotations = parseAnnotations(visibility);
        outerList.set(i, annotations);

        if (observer != null) {
            observer.changeIndent(-1);
        }
    }

    outerList.setImmutable();
    return outerList;
}
 
Example #18
Source File: AnnotationsDirectoryItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a parameter annotations item to this instance.
 *
 * @param method {@code non-null;} method in question
 * @param list {@code non-null;} associated list of annotation sets to add
 * @param dexFile {@code non-null;} dex output
 */
public void addParameterAnnotations(CstMethodRef method,
        AnnotationsList list, DexFile dexFile) {
    if (parameterAnnotations == null) {
        parameterAnnotations = new ArrayList<ParameterAnnotationStruct>();
    }

    parameterAnnotations.add(new ParameterAnnotationStruct(method, list, dexFile));
}
 
Example #19
Source File: StdAttributeFactory.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a {@code RuntimeVisibleParameterAnnotations} attribute.
 */
private Attribute runtimeVisibleParameterAnnotations(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    AnnotationsList list =
        ap.parseParameterAttribute(AnnotationVisibility.RUNTIME);

    return new AttRuntimeVisibleParameterAnnotations(list, length);
}
 
Example #20
Source File: AttributeTranslator.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the parameter annotations out of a given method. This
 * combines both visible and invisible annotations into a single
 * result set.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of annotation sets, which may be
 * empty
 */
public static AnnotationsList getParameterAnnotations(Method method) {
    AttributeList attribs = method.getAttributes();
    AttRuntimeVisibleParameterAnnotations visible =
        (AttRuntimeVisibleParameterAnnotations)
        attribs.findFirst(
                AttRuntimeVisibleParameterAnnotations.ATTRIBUTE_NAME);
    AttRuntimeInvisibleParameterAnnotations invisible =
        (AttRuntimeInvisibleParameterAnnotations)
        attribs.findFirst(
                AttRuntimeInvisibleParameterAnnotations.ATTRIBUTE_NAME);

    if (visible == null) {
        if (invisible == null) {
            return AnnotationsList.EMPTY;
        }
        return invisible.getParameterAnnotations();
    }

    if (invisible == null) {
        return visible.getParameterAnnotations();
    }

    // Both are non-null, so combine them.

    return AnnotationsList.combine(visible.getParameterAnnotations(),
            invisible.getParameterAnnotations());
}
 
Example #21
Source File: AnnotationsDirectoryItem.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a parameter annotations item to this instance.
 *
 * @param method {@code non-null;} method in question
 * @param list {@code non-null;} associated list of annotation sets to add
 * @param dexFile {@code non-null;} dex output
 */
public void addParameterAnnotations(CstMethodRef method,
        AnnotationsList list, DexFile dexFile) {
    if (parameterAnnotations == null) {
        parameterAnnotations = new ArrayList<ParameterAnnotationStruct>();
    }

    parameterAnnotations.add(new ParameterAnnotationStruct(method, list, dexFile));
}
 
Example #22
Source File: AnnotationsDirectoryItem.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the parameter annotations for a given method, if any. This is
 * meant for use by debugging / dumping code.
 *
 * @param method {@code non-null;} the method
 * @return {@code null-ok;} the parameter annotations, if any
 */
public AnnotationsList getParameterAnnotations(CstMethodRef method) {
    if (parameterAnnotations == null) {
        return null;
    }

    for (ParameterAnnotationStruct item : parameterAnnotations) {
        if (item.getMethod().equals(method)) {
            return item.getAnnotationsList();
        }
    }

    return null;
}
 
Example #23
Source File: ParameterAnnotationStruct.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param method {@code non-null;} the method in question
 * @param annotationsList {@code non-null;} the associated annotations list
 * @param dexFile {@code non-null;} dex output
 */
public ParameterAnnotationStruct(CstMethodRef method,
        AnnotationsList annotationsList, DexFile dexFile) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    if (annotationsList == null) {
        throw new NullPointerException("annotationsList == null");
    }

    this.method = method;
    this.annotationsList = annotationsList;

    /*
     * Construct an item for the annotations list. TODO: This
     * requires way too much copying; fix it.
     */

    int size = annotationsList.size();
    ArrayList<AnnotationSetRefItem> arrayList = new
        ArrayList<AnnotationSetRefItem>(size);

    for (int i = 0; i < size; i++) {
        Annotations annotations = annotationsList.get(i);
        AnnotationSetItem item = new AnnotationSetItem(annotations, dexFile);
        arrayList.add(new AnnotationSetRefItem(item));
    }

    this.annotationsItem = new UniformListItem<AnnotationSetRefItem>(
            ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList);
}
 
Example #24
Source File: AnnotationParser.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a list of annotation lists.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotations
 * @return {@code non-null;} the list of annotation lists read from the attribute
 * data
 */
private AnnotationsList parseAnnotationsList(
        AnnotationVisibility visibility) throws IOException {
    int count = input.readUnsignedByte();

    if (observer != null) {
        parsed(1, "num_parameters: " + Hex.u1(count));
    }

    AnnotationsList outerList = new AnnotationsList(count);

    for (int i = 0; i < count; i++) {
        if (observer != null) {
            parsed(0, "parameter_annotations[" + i + "]:");
            changeIndent(1);
        }

        Annotations annotations = parseAnnotations(visibility);
        outerList.set(i, annotations);

        if (observer != null) {
            observer.changeIndent(-1);
        }
    }

    outerList.setImmutable();
    return outerList;
}
 
Example #25
Source File: StdAttributeFactory.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a {@code RuntimeInvisibleParameterAnnotations} attribute.
 */
private Attribute runtimeInvisibleParameterAnnotations(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    AnnotationsList list =
        ap.parseParameterAttribute(AnnotationVisibility.BUILD);

    return new AttRuntimeInvisibleParameterAnnotations(list, length);
}
 
Example #26
Source File: StdAttributeFactory.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a {@code RuntimeVisibleParameterAnnotations} attribute.
 */
private Attribute runtimeVisibleParameterAnnotations(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    AnnotationsList list =
        ap.parseParameterAttribute(AnnotationVisibility.RUNTIME);

    return new AttRuntimeVisibleParameterAnnotations(list, length);
}
 
Example #27
Source File: StdAttributeFactory.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Parses a {@code RuntimeVisibleParameterAnnotations} attribute.
 */
private Attribute runtimeVisibleParameterAnnotations(DirectClassFile cf,
        int offset, int length, ParseObserver observer) {
    if (length < 2) {
        throwSeverelyTruncated();
    }

    AnnotationParser ap =
        new AnnotationParser(cf, offset, length, observer);
    AnnotationsList list =
        ap.parseParameterAttribute(AnnotationVisibility.RUNTIME);

    return new AttRuntimeVisibleParameterAnnotations(list, length);
}
 
Example #28
Source File: AttributeTranslator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the parameter annotations out of a given method. This
 * combines both visible and invisible annotations into a single
 * result set.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of annotation sets, which may be
 * empty
 */
public static AnnotationsList getParameterAnnotations(Method method) {
    AttributeList attribs = method.getAttributes();
    AttRuntimeVisibleParameterAnnotations visible =
        (AttRuntimeVisibleParameterAnnotations)
        attribs.findFirst(
                AttRuntimeVisibleParameterAnnotations.ATTRIBUTE_NAME);
    AttRuntimeInvisibleParameterAnnotations invisible =
        (AttRuntimeInvisibleParameterAnnotations)
        attribs.findFirst(
                AttRuntimeInvisibleParameterAnnotations.ATTRIBUTE_NAME);

    if (visible == null) {
        if (invisible == null) {
            return AnnotationsList.EMPTY;
        }
        return invisible.getParameterAnnotations();
    }

    if (invisible == null) {
        return visible.getParameterAnnotations();
    }

    // Both are non-null, so combine them.

    return AnnotationsList.combine(visible.getParameterAnnotations(),
            invisible.getParameterAnnotations());
}
 
Example #29
Source File: AnnotationsDirectoryItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the parameter annotations for a given method, if any. This is
 * meant for use by debugging / dumping code.
 *
 * @param method {@code non-null;} the method
 * @return {@code null-ok;} the parameter annotations, if any
 */
public AnnotationsList getParameterAnnotations(CstMethodRef method) {
    if (parameterAnnotations == null) {
        return null;
    }

    for (ParameterAnnotationStruct item : parameterAnnotations) {
        if (item.getMethod().equals(method)) {
            return item.getAnnotationsList();
        }
    }

    return null;
}
 
Example #30
Source File: ParameterAnnotationStruct.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param method {@code non-null;} the method in question
 * @param annotationsList {@code non-null;} the associated annotations list
 * @param dexFile {@code non-null;} dex output
 */
public ParameterAnnotationStruct(CstMethodRef method,
        AnnotationsList annotationsList, DexFile dexFile) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    if (annotationsList == null) {
        throw new NullPointerException("annotationsList == null");
    }

    this.method = method;
    this.annotationsList = annotationsList;

    /*
     * Construct an item for the annotations list. TODO: This
     * requires way too much copying; fix it.
     */

    int size = annotationsList.size();
    ArrayList<AnnotationSetRefItem> arrayList = new
        ArrayList<AnnotationSetRefItem>(size);

    for (int i = 0; i < size; i++) {
        Annotations annotations = annotationsList.get(i);
        AnnotationSetItem item = new AnnotationSetItem(annotations, dexFile);
        arrayList.add(new AnnotationSetRefItem(item));
    }

    this.annotationsItem = new UniformListItem<AnnotationSetRefItem>(
            ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList);
}