use of jadx.api.plugins.input.data.attributes.types.AnnotationDefaultClassAttr in project jadx by skylot.
the class DexAnnotationsConvert method convertSystemAnnotations.
@SuppressWarnings("unchecked")
private static void convertSystemAnnotations(@Nullable String cls, List<IJadxAttribute> attributes, IAnnotation annotation) {
switch(annotation.getAnnotationClass()) {
case "Ldalvik/annotation/Signature;":
attributes.add(new SignatureAttr(extractSignature(annotation)));
break;
case "Ldalvik/annotation/InnerClass;":
try {
String name = AnnotationsUtils.getValue(annotation, "name", EncodedType.ENCODED_STRING, null);
int accFlags = AnnotationsUtils.getValue(annotation, "accessFlags", EncodedType.ENCODED_INT, 0);
if (name != null || accFlags != 0) {
InnerClsInfo innerClsInfo = new InnerClsInfo(cls, null, name, accFlags);
attributes.add(new InnerClassesAttr(Collections.singletonMap(cls, innerClsInfo)));
}
} catch (Exception e) {
LOG.warn("Failed to parse annotation: " + annotation, e);
}
break;
case "Ldalvik/annotation/AnnotationDefault;":
EncodedValue annValue = annotation.getDefaultValue();
if (annValue != null && annValue.getType() == EncodedType.ENCODED_ANNOTATION) {
IAnnotation defAnnotation = (IAnnotation) annValue.getValue();
attributes.add(new AnnotationDefaultClassAttr(defAnnotation.getValues()));
}
break;
case "Ldalvik/annotation/Throws;":
try {
EncodedValue defaultValue = annotation.getDefaultValue();
if (defaultValue != null) {
List<String> excs = ((List<EncodedValue>) defaultValue.getValue()).stream().map(ev -> ((String) ev.getValue())).collect(Collectors.toList());
attributes.add(new ExceptionsAttr(excs));
}
} catch (Exception e) {
LOG.warn("Failed to convert dalvik throws annotation", e);
}
break;
case "Ldalvik/annotation/MethodParameters;":
try {
List<EncodedValue> names = AnnotationsUtils.getArray(annotation, "names");
List<EncodedValue> accFlags = AnnotationsUtils.getArray(annotation, "accessFlags");
if (!names.isEmpty() && names.size() == accFlags.size()) {
int size = names.size();
List<MethodParametersAttr.Info> list = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
String name = (String) names.get(i).getValue();
int accFlag = (int) accFlags.get(i).getValue();
list.add(new MethodParametersAttr.Info(accFlag, name));
}
attributes.add(new MethodParametersAttr(list));
}
} catch (Exception e) {
LOG.warn("Failed to parse annotation: " + annotation, e);
}
break;
}
}
Aggregations