use of jadx.api.plugins.input.data.attributes.IJadxAttribute 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;
}
}
use of jadx.api.plugins.input.data.attributes.IJadxAttribute in project jadx by skylot.
the class DexClassData method getAttributes.
@Override
public List<IJadxAttribute> getAttributes() {
List<IJadxAttribute> list = new ArrayList<>();
String sourceFile = getSourceFile();
if (sourceFile != null && !sourceFile.isEmpty()) {
list.add(new SourceFileAttr(sourceFile));
}
DexAnnotationsConvert.forClass(getType(), list, getAnnotations());
return list;
}
use of jadx.api.plugins.input.data.attributes.IJadxAttribute in project jadx by skylot.
the class JavaClassData method getAttributes.
@Override
public List<IJadxAttribute> getAttributes() {
data.absPos(offsets.getAttributesOffset());
JavaAttrStorage attributes = attributesReader.load(data);
int size = attributes.size();
if (size == 0) {
return Collections.emptyList();
}
List<IJadxAttribute> list = new ArrayList<>(size);
Utils.addToList(list, JavaAnnotationsAttr.merge(attributes));
Utils.addToList(list, attributes.get(JavaAttrType.INNER_CLASSES));
Utils.addToList(list, attributes.get(JavaAttrType.SOURCE_FILE));
Utils.addToList(list, attributes.get(JavaAttrType.SIGNATURE));
return list;
}
use of jadx.api.plugins.input.data.attributes.IJadxAttribute in project jadx by skylot.
the class AttributeStorage method getAttributeStrings.
public List<String> getAttributeStrings() {
int size = flags.size() + attributes.size() + attributes.size();
if (size == 0) {
return Collections.emptyList();
}
List<String> list = new ArrayList<>(size);
for (AFlag a : flags) {
list.add(a.toString());
}
for (IJadxAttribute a : attributes.values()) {
list.add(a.toAttrString());
}
return list;
}
use of jadx.api.plugins.input.data.attributes.IJadxAttribute in project jadx by skylot.
the class AttributeStorage method remove.
public void remove(IJadxAttribute attr) {
if (!attributes.isEmpty()) {
IJadxAttrType<? extends IJadxAttribute> type = attr.getAttrType();
IJadxAttribute a = attributes.get(type);
if (a == attr) {
attributes.remove(type);
}
}
}
Aggregations