Search in sources :

Example 16 with ICodeInfo

use of jadx.api.ICodeInfo in project jadx by skylot.

the class JadxClassNodeAssertions method reloadCode.

public JadxCodeAssertions reloadCode(IntegrationTest testInstance) {
    isNotNull();
    ICodeInfo code = actual.reloadCode();
    Assertions.assertThat(code).isNotNull();
    String codeStr = code.getCodeStr();
    Assertions.assertThat(codeStr).isNotBlank();
    JadxCodeAssertions codeAssertions = new JadxCodeAssertions(codeStr);
    codeAssertions.print();
    testInstance.runChecks(actual);
    return codeAssertions;
}
Also used : ICodeInfo(jadx.api.ICodeInfo)

Example 17 with ICodeInfo

use of jadx.api.ICodeInfo in project jadx by skylot.

the class TestReturnSourceLine method test.

@Test
public void test() {
    printLineNumbers();
    ClassNode cls = getClassNode(TestCls.class);
    ICodeInfo codeInfo = cls.getCode();
    String[] lines = codeInfo.getCodeStr().split(ICodeWriter.NL);
    MethodNode test1 = cls.searchMethodByShortId("test1(Z)I");
    checkLine(lines, codeInfo, test1, 3, "return 1;");
    MethodNode test2 = cls.searchMethodByShortId("test2(I)I");
    checkLine(lines, codeInfo, test2, 3, "return v - 1;");
    checkLine(lines, codeInfo, test2, 6, "return v + 1;");
    MethodNode test3 = cls.searchMethodByShortId("test3(I)I");
    if (isJavaInput()) {
        // dx lost line number for this return
        checkLine(lines, codeInfo, test3, 3, "return v;");
    }
    checkLine(lines, codeInfo, test3, 6, "return v + 1;");
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) MethodNode(jadx.core.dex.nodes.MethodNode) ICodeInfo(jadx.api.ICodeInfo) Test(org.junit.jupiter.api.Test) IntegrationTest(jadx.tests.api.IntegrationTest)

Aggregations

ICodeInfo (jadx.api.ICodeInfo)17 ClassNode (jadx.core.dex.nodes.ClassNode)3 ICodeCache (jadx.api.ICodeCache)2 ICodeWriter (jadx.api.ICodeWriter)2 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)2 ResContainer (jadx.core.xmlgen.ResContainer)2 ValuesParser (jadx.core.xmlgen.entry.ValuesParser)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Nullable (org.jetbrains.annotations.Nullable)2 Package (com.android.aapt.Resources.Package)1 ResourceTable (com.android.aapt.Resources.ResourceTable)1 CodePosition (jadx.api.CodePosition)1 JadxDecompiler (jadx.api.JadxDecompiler)1 ResourceFile (jadx.api.ResourceFile)1 ResourceFileContent (jadx.api.ResourceFileContent)1 InsnCodeOffset (jadx.api.data.annotations.InsnCodeOffset)1 SimpleCodeWriter (jadx.api.impl.SimpleCodeWriter)1 JsonCodeLine (jadx.core.codegen.json.cls.JsonCodeLine)1 AFlag (jadx.core.dex.attributes.AFlag)1