use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class JavaClass method load.
private void load() {
JadxDecompiler rootDecompiler = getRootDecompiler();
int inClsCount = cls.getInnerClasses().size();
if (inClsCount != 0) {
List<JavaClass> list = new ArrayList<JavaClass>(inClsCount);
for (ClassNode inner : cls.getInnerClasses()) {
if (!inner.contains(AFlag.DONT_GENERATE)) {
JavaClass javaClass = new JavaClass(inner, this);
javaClass.load();
list.add(javaClass);
rootDecompiler.getClassesMap().put(inner, javaClass);
}
}
this.innerClasses = Collections.unmodifiableList(list);
}
int fieldsCount = cls.getFields().size();
if (fieldsCount != 0) {
List<JavaField> flds = new ArrayList<JavaField>(fieldsCount);
for (FieldNode f : cls.getFields()) {
if (!f.contains(AFlag.DONT_GENERATE)) {
JavaField javaField = new JavaField(f, this);
flds.add(javaField);
rootDecompiler.getFieldsMap().put(f, javaField);
}
}
this.fields = Collections.unmodifiableList(flds);
}
int methodsCount = cls.getMethods().size();
if (methodsCount != 0) {
List<JavaMethod> mths = new ArrayList<JavaMethod>(methodsCount);
for (MethodNode m : cls.getMethods()) {
if (!m.contains(AFlag.DONT_GENERATE)) {
JavaMethod javaMethod = new JavaMethod(this, m);
mths.add(javaMethod);
rootDecompiler.getMethodsMap().put(m, javaMethod);
}
}
Collections.sort(mths, new Comparator<JavaMethod>() {
@Override
public int compare(JavaMethod o1, JavaMethod o2) {
return o1.getName().compareTo(o2.getName());
}
});
this.methods = Collections.unmodifiableList(mths);
}
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestArgInline method test.
@Test
public void test() {
noDebugInfo();
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("i++;"));
assertThat(code, not(containsString("i = i + 1;")));
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestClassGen method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("public interface I {"));
assertThat(code, containsString(indent(2) + "int test();"));
assertThat(code, not(containsString("public int test();")));
assertThat(code, containsString(indent(2) + "int test3();"));
assertThat(code, containsString("public static abstract class A {"));
assertThat(code, containsString(indent(2) + "public abstract int test2();"));
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestFloatValue method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, not(containsString("1073741824")));
assertThat(code, containsString("0.55f"));
assertThat(code, containsString("fa[0] = fa[0] / 2.0f;"));
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestRedundantBrackets method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, not(containsString("(-1)")));
assertThat(code, not(containsString("return;")));
assertThat(code, containsString("return obj instanceof String ? ((String) obj).length() : 0;"));
assertThat(code, containsString("a + b < 10"));
assertThat(code, containsString("(a & b) != 0"));
assertThat(code, containsString("if (num == 4 || num == 6 || num == 8 || num == 10)"));
assertThat(code, containsString("a[1] = n * 2;"));
assertThat(code, containsString("a[n - 1] = 1;"));
// argument type not changed to String
assertThat(code, containsString("public int method2(Object obj) {"));
// cast not eliminated
assertThat(code, containsString("((String) obj).length()"));
}
Aggregations