Search in sources :

Example 1 with JadxAnnotation

use of jadx.api.plugins.input.data.annotations.JadxAnnotation in project jadx by skylot.

the class JavaAnnotationsAttr method readAnnotation.

public static JadxAnnotation readAnnotation(AnnotationVisibility visibility, JavaClassData clsData, DataReader reader) {
    ConstPoolReader constPool = clsData.getConstPoolReader();
    String type = constPool.getUtf8(reader.readU2());
    int pairsCount = reader.readU2();
    Map<String, EncodedValue> pairs = new LinkedHashMap<>(pairsCount);
    for (int j = 0; j < pairsCount; j++) {
        String name = constPool.getUtf8(reader.readU2());
        EncodedValue value = EncodedValueReader.read(clsData, reader);
        pairs.put(name, value);
    }
    return new JadxAnnotation(visibility, type, pairs);
}
Also used : EncodedValue(jadx.api.plugins.input.data.annotations.EncodedValue) JadxAnnotation(jadx.api.plugins.input.data.annotations.JadxAnnotation) ConstPoolReader(jadx.plugins.input.java.data.ConstPoolReader) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with JadxAnnotation

use of jadx.api.plugins.input.data.annotations.JadxAnnotation in project jadx by skylot.

the class AnnotationsParser method readAnnotation.

public static IAnnotation readAnnotation(SectionReader in, SectionReader ext, boolean readVisibility) {
    AnnotationVisibility visibility = null;
    if (readVisibility) {
        int v = in.readUByte();
        visibility = getVisibilityValue(v);
    }
    int typeIndex = in.readUleb128();
    int size = in.readUleb128();
    Map<String, EncodedValue> values = new LinkedHashMap<>(size);
    for (int i = 0; i < size; i++) {
        String name = ext.getString(in.readUleb128());
        values.put(name, EncodedValueParser.parseValue(in, ext));
    }
    String type = ext.getType(typeIndex);
    return new JadxAnnotation(visibility, type, values);
}
Also used : AnnotationVisibility(jadx.api.plugins.input.data.annotations.AnnotationVisibility) EncodedValue(jadx.api.plugins.input.data.annotations.EncodedValue) JadxAnnotation(jadx.api.plugins.input.data.annotations.JadxAnnotation) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

EncodedValue (jadx.api.plugins.input.data.annotations.EncodedValue)2 JadxAnnotation (jadx.api.plugins.input.data.annotations.JadxAnnotation)2 LinkedHashMap (java.util.LinkedHashMap)2 AnnotationVisibility (jadx.api.plugins.input.data.annotations.AnnotationVisibility)1 ConstPoolReader (jadx.plugins.input.java.data.ConstPoolReader)1