use of org.jf.dexlib2.dexbacked.DexBackedClassDef in project smali by JesusFreke.
the class ClassDefinition method writeStaticFields.
private Set<String> writeStaticFields(IndentingWriter writer) throws IOException {
boolean wroteHeader = false;
Set<String> writtenFields = new HashSet<String>();
Iterable<? extends Field> staticFields;
if (classDef instanceof DexBackedClassDef) {
staticFields = ((DexBackedClassDef) classDef).getStaticFields(false);
} else {
staticFields = classDef.getStaticFields();
}
for (Field field : staticFields) {
if (!wroteHeader) {
writer.write("\n\n");
writer.write("# static fields");
wroteHeader = true;
}
writer.write('\n');
boolean setInStaticConstructor;
IndentingWriter fieldWriter = writer;
String fieldString = ReferenceUtil.getShortFieldDescriptor(field);
if (!writtenFields.add(fieldString)) {
writer.write("# duplicate field ignored\n");
fieldWriter = new CommentingIndentingWriter(writer);
System.err.println(String.format("Ignoring duplicate field: %s->%s", classDef.getType(), fieldString));
setInStaticConstructor = false;
} else {
setInStaticConstructor = fieldsSetInStaticConstructor.contains(fieldString);
}
FieldDefinition.writeTo(options, fieldWriter, field, setInStaticConstructor);
}
return writtenFields;
}
use of org.jf.dexlib2.dexbacked.DexBackedClassDef in project android by JetBrains.
the class DexParser method getDexStats.
@NotNull
private DexFileStats getDexStats() {
DexBackedDexFile dexFile;
try {
dexFile = myDexFileFuture.get();
} catch (Exception e) {
return new DexFileStats(-1, -1, -1);
}
int definedMethodCount = 0;
Set<? extends DexBackedClassDef> classes = dexFile.getClasses();
for (DexBackedClassDef dexBackedClassDef : classes) {
definedMethodCount += Iterables.size(dexBackedClassDef.getMethods());
}
return new DexFileStats(classes.size(), definedMethodCount, dexFile.getMethodCount());
}
Aggregations