Search in sources :

Example 16 with Attribute

use of com.android.dx.cf.iface.Attribute in project J2ME-Loader by nikita36078.

the class StdAttributeFactory method enclosingMethod.

/**
 * Parses an {@code EnclosingMethod} attribute.
 */
private Attribute enclosingMethod(DirectClassFile cf, int offset, int length, ParseObserver observer) {
    if (length != 4) {
        throwBadLength(4);
    }
    ByteArray bytes = cf.getBytes();
    ConstantPool pool = cf.getConstantPool();
    int idx = bytes.getUnsignedShort(offset);
    CstType type = (CstType) pool.get(idx);
    idx = bytes.getUnsignedShort(offset + 2);
    CstNat method = (CstNat) pool.get0Ok(idx);
    Attribute result = new AttEnclosingMethod(type, method);
    if (observer != null) {
        observer.parsed(bytes, offset, 2, "class: " + type);
        observer.parsed(bytes, offset + 2, 2, "method: " + DirectClassFile.stringOrNone(method));
    }
    return result;
}
Also used : CstNat(com.android.dx.rop.cst.CstNat) AttEnclosingMethod(com.android.dx.cf.attrib.AttEnclosingMethod) Attribute(com.android.dx.cf.iface.Attribute) ConstantPool(com.android.dx.rop.cst.ConstantPool) CstType(com.android.dx.rop.cst.CstType) ByteArray(com.android.dx.util.ByteArray)

Aggregations

Attribute (com.android.dx.cf.iface.Attribute)16 ByteArray (com.android.dx.util.ByteArray)14 ConstantPool (com.android.dx.rop.cst.ConstantPool)10 CstString (com.android.dx.rop.cst.CstString)5 AttSourceFile (com.android.dx.cf.attrib.AttSourceFile)4 AttributeList (com.android.dx.cf.iface.AttributeList)3 AttConstantValue (com.android.dx.cf.attrib.AttConstantValue)2 AttEnclosingMethod (com.android.dx.cf.attrib.AttEnclosingMethod)2 AttSignature (com.android.dx.cf.attrib.AttSignature)2 RawAttribute (com.android.dx.cf.attrib.RawAttribute)2 ParseException (com.android.dx.cf.iface.ParseException)2 StdAttributeList (com.android.dx.cf.iface.StdAttributeList)2 CstNat (com.android.dx.rop.cst.CstNat)2 CstType (com.android.dx.rop.cst.CstType)2 TypedConstant (com.android.dx.rop.cst.TypedConstant)2 AttSourceDebugExtension (com.android.dx.cf.attrib.AttSourceDebugExtension)1 BaseAnnotations (com.android.dx.cf.attrib.BaseAnnotations)1 ClassPathOpener (com.android.dx.cf.direct.ClassPathOpener)1 DirectClassFile (com.android.dx.cf.direct.DirectClassFile)1 File (java.io.File)1