gui: add type and access info to classes tree

This commit is contained in:
Skylot
2013-07-26 23:04:42 +04:00
parent fa097cc6b2
commit 67eb55a95d
16 changed files with 193 additions and 45 deletions
@@ -91,7 +91,7 @@ public final class Decompiler {
return Collections.unmodifiableList(packages);
}
public ThreadPoolExecutor saveAll(File dir) throws InterruptedException {
public ThreadPoolExecutor saveAll(File dir) {
int threadsCount = args.getThreadsCount();
LOG.debug("processing threads count: {}", threadsCount);
@@ -1,7 +1,6 @@
package jadx.api;
import jadx.core.codegen.CodeWriter;
import jadx.core.dex.attributes.AttributeFlag;
import jadx.core.dex.info.AccessInfo;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.FieldNode;
@@ -51,7 +50,7 @@ public final class JavaClass {
} else {
List<JavaMethod> mths = new ArrayList<JavaMethod>(methodsCount);
for (MethodNode m : cls.getMethods()) {
if (!m.getAttributes().contains(AttributeFlag.DONT_GENERATE)) {
if (!m.getAccessFlags().isSynthetic()) {
mths.add(new JavaMethod(m));
}
}
@@ -1,6 +1,7 @@
package jadx.api;
import jadx.core.dex.info.AccessInfo;
import jadx.core.dex.instructions.args.ArgType;
import jadx.core.dex.nodes.FieldNode;
public class JavaField {
@@ -19,6 +20,10 @@ public class JavaField {
return field.getAccessFlags();
}
public ArgType getType() {
return field.getType();
}
public int getDecompiledLine() {
return field.getDecompiledLine();
}
@@ -2,8 +2,11 @@ package jadx.api;
import jadx.core.dex.info.AccessInfo;
import jadx.core.dex.info.MethodInfo;
import jadx.core.dex.instructions.args.ArgType;
import jadx.core.dex.nodes.MethodNode;
import java.util.List;
public class JavaMethod {
private final MethodNode mth;
@@ -25,6 +28,22 @@ public class JavaMethod {
return mth.getAccessFlags();
}
public List<ArgType> getArguments() {
return mth.getMethodInfo().getArgumentsTypes();
}
public ArgType getReturnType() {
return mth.getReturnType();
}
public boolean isConstructor() {
return mth.getMethodInfo().isConstructor();
}
public boolean isClassInit() {
return mth.getMethodInfo().isClassInit();
}
public int getDecompiledLine() {
return mth.getDecompiledLine();
}
@@ -481,7 +481,7 @@ public class InsnGen {
private void makeInvoke(InvokeNode insn, CodeWriter code) throws CodegenException {
MethodInfo callMth = insn.getCallMth();
// inline method if METHOD_INLINE attribute is attached
// inline method
MethodNode callMthNode = mth.dex().resolveMethod(callMth);
if (callMthNode != null
&& callMthNode.getAttributes().contains(AttributeType.METHOD_INLINE)) {
@@ -507,8 +507,10 @@ public class InsnGen {
case STATIC:
ClassInfo insnCls = mth.getParentClass().getClassInfo();
if (!insnCls.equals(callMth.getDeclClass()))
code.add(useClass(callMth.getDeclClass())).add('.');
ClassInfo declClass = callMth.getDeclClass();
if (!insnCls.equals(declClass)) {
code.add(useClass(declClass)).add('.');
}
break;
}
code.add(callMth.getName());
@@ -93,6 +93,18 @@ public class AccessInfo {
return (accFlags & AccessFlags.ACC_VARARGS) != 0;
}
public boolean isSynchronized() {
return (accFlags & (AccessFlags.ACC_SYNCHRONIZED | AccessFlags.ACC_DECLARED_SYNCHRONIZED)) != 0;
}
public boolean isTransient() {
return (accFlags & AccessFlags.ACC_TRANSIENT) != 0;
}
public boolean isVolatile() {
return (accFlags & AccessFlags.ACC_VOLATILE) != 0;
}
public int getFlags() {
return accFlags;
}
@@ -126,10 +138,7 @@ public class AccessInfo {
switch (type) {
case METHOD:
if ((accFlags & AccessFlags.ACC_SYNCHRONIZED) != 0)
code.append("synchronized ");
if ((accFlags & AccessFlags.ACC_DECLARED_SYNCHRONIZED) != 0)
if (isSynchronized())
code.append("synchronized ");
if (isBridge())
@@ -142,10 +151,10 @@ public class AccessInfo {
break;
case FIELD:
if ((accFlags & AccessFlags.ACC_VOLATILE) != 0)
if (isVolatile())
code.append("volatile ");
if ((accFlags & AccessFlags.ACC_TRANSIENT) != 0)
if (isTransient())
code.append("transient ");
break;
@@ -1,7 +1,7 @@
package jadx.core.dex.visitors;
import jadx.core.dex.attributes.AttributeFlag;
import jadx.core.dex.attributes.IAttribute;
import jadx.core.dex.attributes.AttributesList;
import jadx.core.dex.attributes.MethodInlineAttr;
import jadx.core.dex.info.AccessInfo;
import jadx.core.dex.instructions.InsnType;
@@ -43,8 +43,8 @@ public class MethodInlinerVisitor extends AbstractVisitor {
}
private static void addInlineAttr(MethodNode mth, InsnNode insn) {
IAttribute attr = new MethodInlineAttr(insn);
mth.getAttributes().add(attr);
mth.getAttributes().add(AttributeFlag.DONT_GENERATE);
AttributesList attributes = mth.getAttributes();
attributes.add(new MethodInlineAttr(insn));
attributes.add(AttributeFlag.DONT_GENERATE);
}
}
@@ -8,7 +8,6 @@ import jadx.core.utils.exceptions.CodegenException;
import java.io.File;
public class SaveCode extends AbstractVisitor {
private final File dir;
private final IJadxArgs args;
@@ -22,13 +21,10 @@ public class SaveCode extends AbstractVisitor {
CodeWriter clsCode = cls.getCode();
String fileName = cls.getClassInfo().getFullPath() + ".java";
if (isFallbackMode())
if (args.isFallbackMode()) {
fileName += ".jadx";
}
clsCode.save(dir, fileName);
return false;
}
public boolean isFallbackMode() {
return args.isFallbackMode();
}
}