Search in sources :

Example 66 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestReturnWrapping method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsString("return 255;"));
    assertThat(code, containsString("return arg0 + 1;"));
    assertThat(code, containsString("return i > 128 ? arg0.toString() + ret.toString() : Integer.valueOf(i);"));
    assertThat(code, containsString("return arg0 + 2;"));
    assertThat(code, containsString("arg0 -= 951;"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 67 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestVariables3 method test.

@Test
public void test() {
    ClassNode cls = getClassNode(TestCls.class);
    String code = cls.getCode().toString();
    assertThat(code, containsString("int i;"));
    assertThat(code, containsString("i = 2;"));
    assertThat(code, containsString("i = 3;"));
    assertThat(code, containsString("s = null;"));
    assertThat(code, containsString("return s + \" \" + i;"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IntegrationTest(jadx.tests.api.IntegrationTest) Test(org.junit.Test)

Example 68 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestArithConst method test.

@Test
public void test() {
    noDebugInfo();
    ClassNode cls = getClassNodeFromSmali("TestArithConst");
    String code = cls.getCode().toString();
    assertThat(code, containsOne("return i + CONST_INT;"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) Test(org.junit.Test) SmaliTest(jadx.tests.api.SmaliTest)

Example 69 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class TestInlineVarArg method test.

@Test
public void test() {
    noDebugInfo();
    ClassNode cls = getClassNodeFromSmali("TestInlineVarArg");
    String code = cls.getCode().toString();
    assertThat(code, containsOne("f(\"a\", \"b\", \"c\");"));
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) Test(org.junit.Test) SmaliTest(jadx.tests.api.SmaliTest)

Example 70 with ClassNode

use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.

the class RenameVisitor method checkClasses.

private void checkClasses(RootNode root) {
    Set<String> clsNames = new HashSet<String>();
    for (ClassNode cls : root.getClasses(true)) {
        checkClassName(cls);
        if (!CASE_SENSITIVE_FS) {
            ClassInfo classInfo = cls.getClassInfo();
            String clsFileName = classInfo.getAlias().getFullPath();
            if (!clsNames.add(clsFileName.toLowerCase())) {
                String newShortName = deobfuscator.getClsAlias(cls);
                String newFullName = classInfo.makeFullClsName(newShortName, true);
                classInfo.rename(cls.dex(), newFullName);
                clsNames.add(classInfo.getAlias().getFullPath().toLowerCase());
            }
        }
    }
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) HashSet(java.util.HashSet) ClassInfo(jadx.core.dex.info.ClassInfo)

Aggregations

ClassNode (jadx.core.dex.nodes.ClassNode)236 Test (org.junit.Test)201 IntegrationTest (jadx.tests.api.IntegrationTest)197 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)93 JadxMatchers.countString (jadx.tests.api.utils.JadxMatchers.countString)17 MethodNode (jadx.core.dex.nodes.MethodNode)12 FieldNode (jadx.core.dex.nodes.FieldNode)10 Matchers.containsString (org.hamcrest.Matchers.containsString)10 ConstClassNode (jadx.core.dex.instructions.ConstClassNode)7 InsnNode (jadx.core.dex.nodes.InsnNode)7 ClassInfo (jadx.core.dex.info.ClassInfo)6 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)6 DexNode (jadx.core.dex.nodes.DexNode)5 InsnArg (jadx.core.dex.instructions.args.InsnArg)4 ConstructorInsn (jadx.core.dex.instructions.mods.ConstructorInsn)4 SmaliTest (jadx.tests.api.SmaliTest)4 ArrayList (java.util.ArrayList)4 FieldReplaceAttr (jadx.core.dex.attributes.nodes.FieldReplaceAttr)3 FieldInfo (jadx.core.dex.info.FieldInfo)3 MethodInfo (jadx.core.dex.info.MethodInfo)3