Search in sources :

Example 1 with Section

use of com.android.dex.Dex.Section in project jadx by skylot.

the class AnnotationsParser method readAnnotationSet.

private AnnotationsList readAnnotationSet(int offset) throws DecodeException {
    if (offset == 0) {
        return AnnotationsList.EMPTY;
    }
    Section section = dex.openSection(offset);
    int size = section.readInt();
    if (size == 0) {
        return AnnotationsList.EMPTY;
    }
    List<Annotation> list = new ArrayList<Annotation>(size);
    for (int i = 0; i < size; i++) {
        Section anSection = dex.openSection(section.readInt());
        Annotation a = readAnnotation(dex, anSection, true);
        list.add(a);
    }
    return new AnnotationsList(list);
}
Also used : ArrayList(java.util.ArrayList) AnnotationsList(jadx.core.dex.attributes.annotations.AnnotationsList) Section(com.android.dex.Dex.Section) Annotation(jadx.core.dex.attributes.annotations.Annotation)

Example 2 with Section

use of com.android.dex.Dex.Section in project jadx by skylot.

the class AnnotationsParser method parse.

public void parse(int offset) throws DecodeException {
    Section section = dex.openSection(offset);
    // TODO read as unsigned int
    int classAnnotationsOffset = section.readInt();
    int fieldsCount = section.readInt();
    int annotatedMethodsCount = section.readInt();
    int annotatedParametersCount = section.readInt();
    if (classAnnotationsOffset != 0) {
        cls.addAttr(readAnnotationSet(classAnnotationsOffset));
    }
    for (int i = 0; i < fieldsCount; i++) {
        FieldNode f = cls.searchFieldById(section.readInt());
        f.addAttr(readAnnotationSet(section.readInt()));
    }
    for (int i = 0; i < annotatedMethodsCount; i++) {
        MethodNode m = cls.searchMethodById(section.readInt());
        m.addAttr(readAnnotationSet(section.readInt()));
    }
    for (int i = 0; i < annotatedParametersCount; i++) {
        MethodNode mth = cls.searchMethodById(section.readInt());
        // read annotation ref list
        Section ss = dex.openSection(section.readInt());
        int size = ss.readInt();
        MethodParameters params = new MethodParameters(size);
        for (int j = 0; j < size; j++) {
            params.getParamList().add(readAnnotationSet(ss.readInt()));
        }
        mth.addAttr(params);
    }
}
Also used : FieldNode(jadx.core.dex.nodes.FieldNode) MethodNode(jadx.core.dex.nodes.MethodNode) MethodParameters(jadx.core.dex.attributes.annotations.MethodParameters) Section(com.android.dex.Dex.Section)

Aggregations

Section (com.android.dex.Dex.Section)2 Annotation (jadx.core.dex.attributes.annotations.Annotation)1 AnnotationsList (jadx.core.dex.attributes.annotations.AnnotationsList)1 MethodParameters (jadx.core.dex.attributes.annotations.MethodParameters)1 FieldNode (jadx.core.dex.nodes.FieldNode)1 MethodNode (jadx.core.dex.nodes.MethodNode)1 ArrayList (java.util.ArrayList)1