com.android.dx.cf.attrib.AttExceptions Java Examples

The following examples show how to use com.android.dx.cf.attrib.AttExceptions. 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: StdAttributeFactory.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Parses an {@code Exceptions} attribute.
 */
private Attribute exceptions(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset); // number_of_exceptions

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                        "number_of_exceptions: " + Hex.u2(count));
    }

    offset += 2;
    length -= 2;

    if (length != (count * 2)) {
        throwBadLength((count * 2) + 2);
    }

    TypeList list = cf.makeTypeList(offset, count);
    return new AttExceptions(list);
}
 
Example #2
Source File: StdAttributeFactory.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Parses an {@code Exceptions} attribute.
 */
private Attribute exceptions(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset); // number_of_exceptions

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                        "number_of_exceptions: " + Hex.u2(count));
    }

    offset += 2;
    length -= 2;

    if (length != (count * 2)) {
        throwBadLength((count * 2) + 2);
    }

    TypeList list = cf.makeTypeList(offset, count);
    return new AttExceptions(list);
}
 
Example #3
Source File: StdAttributeFactory.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Parses an {@code Exceptions} attribute.
 */
private Attribute exceptions(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset); // number_of_exceptions

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                        "number_of_exceptions: " + Hex.u2(count));
    }

    offset += 2;
    length -= 2;

    if (length != (count * 2)) {
        throwBadLength((count * 2) + 2);
    }

    TypeList list = cf.makeTypeList(offset, count);
    return new AttExceptions(list);
}
 
Example #4
Source File: StdAttributeFactory.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Parses an {@code Exceptions} attribute.
 */
private Attribute exceptions(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset); // number_of_exceptions

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                        "number_of_exceptions: " + Hex.u2(count));
    }

    offset += 2;
    length -= 2;

    if (length != (count * 2)) {
        throwBadLength((count * 2) + 2);
    }

    TypeList list = cf.makeTypeList(offset, count);
    return new AttExceptions(list);
}
 
Example #5
Source File: AttributeTranslator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the list of thrown exceptions for a given method.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of thrown exceptions
 */
public static TypeList getExceptions(Method method) {
    AttributeList attribs = method.getAttributes();
    AttExceptions exceptions = (AttExceptions)
        attribs.findFirst(AttExceptions.ATTRIBUTE_NAME);

    if (exceptions == null) {
        return StdTypeList.EMPTY;
    }

    return exceptions.getExceptions();
}
 
Example #6
Source File: AttributeTranslator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the list of thrown exceptions for a given method.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of thrown exceptions
 */
public static TypeList getExceptions(Method method) {
    AttributeList attribs = method.getAttributes();
    AttExceptions exceptions = (AttExceptions)
        attribs.findFirst(AttExceptions.ATTRIBUTE_NAME);

    if (exceptions == null) {
        return StdTypeList.EMPTY;
    }

    return exceptions.getExceptions();
}
 
Example #7
Source File: AttributeTranslator.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the list of thrown exceptions for a given method.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of thrown exceptions
 */
public static TypeList getExceptions(Method method) {
    AttributeList attribs = method.getAttributes();
    AttExceptions exceptions = (AttExceptions)
        attribs.findFirst(AttExceptions.ATTRIBUTE_NAME);

    if (exceptions == null) {
        return StdTypeList.EMPTY;
    }

    return exceptions.getExceptions();
}
 
Example #8
Source File: AttributeTranslator.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the list of thrown exceptions for a given method.
 *
 * @param method {@code non-null;} the method in question
 * @return {@code non-null;} the list of thrown exceptions
 */
public static TypeList getExceptions(Method method) {
    AttributeList attribs = method.getAttributes();
    AttExceptions exceptions = (AttExceptions)
        attribs.findFirst(AttExceptions.ATTRIBUTE_NAME);

    if (exceptions == null) {
        return StdTypeList.EMPTY;
    }

    return exceptions.getExceptions();
}