Search in sources :

Example 1 with Visibility

use of jadx.core.dex.attributes.annotations.Annotation.Visibility 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)1 Visibility (jadx.core.dex.attributes.annotations.Annotation.Visibility)1 ArgType (jadx.core.dex.instructions.args.ArgType)1 DecodeException (jadx.core.utils.exceptions.DecodeException)1 LinkedHashMap (java.util.LinkedHashMap)1