Search in sources :

Example 6 with Annotation

use of jadx.core.dex.attributes.annotations.Annotation in project jadx by skylot.

the class AnnotationsParser method readAnnotation.

public static Annotation readAnnotation(DexNode dex, Section s, boolean readVisibility) throws DecodeException {
    EncValueParser parser = new EncValueParser(dex, s);
    Visibility visibility = null;
    if (readVisibility) {
        byte v = s.readByte();
        visibility = VISIBILITIES[v];
    }
    int typeIndex = s.readUleb128();
    int size = s.readUleb128();
    Map<String, Object> values = new LinkedHashMap<String, Object>(size);
    for (int i = 0; i < size; i++) {
        String name = dex.getString(s.readUleb128());
        values.put(name, parser.parseValue());
    }
    ArgType type = dex.getType(typeIndex);
    Annotation annotation = new Annotation(visibility, type, values);
    if (!type.isObject()) {
        throw new DecodeException("Incorrect type for annotation: " + annotation);
    }
    return annotation;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) Visibility(jadx.core.dex.attributes.annotations.Annotation.Visibility) DecodeException(jadx.core.utils.exceptions.DecodeException) Annotation(jadx.core.dex.attributes.annotations.Annotation) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Annotation (jadx.core.dex.attributes.annotations.Annotation)6 AnnotationsList (jadx.core.dex.attributes.annotations.AnnotationsList)4 ArgType (jadx.core.dex.instructions.args.ArgType)3 Section (com.android.dex.Dex.Section)1 Visibility (jadx.core.dex.attributes.annotations.Annotation.Visibility)1 FieldInfo (jadx.core.dex.info.FieldInfo)1 DecodeException (jadx.core.utils.exceptions.DecodeException)1 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1