Search in sources :

Example 1 with AttExceptions

use of com.taobao.android.dx.cf.attrib.AttExceptions in project atlas by alibaba.

the class StdAttributeFactory method exceptions.

/**
     * 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();
    // number_of_exceptions
    int count = bytes.getUnsignedShort(offset);
    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);
}
Also used : AttExceptions(com.taobao.android.dx.cf.attrib.AttExceptions) ByteArray(com.taobao.android.dx.util.ByteArray) TypeList(com.taobao.android.dx.rop.type.TypeList)

Example 2 with AttExceptions

use of com.taobao.android.dx.cf.attrib.AttExceptions in project atlas by alibaba.

the class AttributeTranslator method getExceptions.

/**
     * 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();
}
Also used : AttExceptions(com.taobao.android.dx.cf.attrib.AttExceptions) AttributeList(com.taobao.android.dx.cf.iface.AttributeList)

Aggregations

AttExceptions (com.taobao.android.dx.cf.attrib.AttExceptions)2 AttributeList (com.taobao.android.dx.cf.iface.AttributeList)1 TypeList (com.taobao.android.dx.rop.type.TypeList)1 ByteArray (com.taobao.android.dx.util.ByteArray)1