未验证 提交 0f00fb9a 编写于 作者: S Skylot

fix: handle move-result after invoke-custom with string concat

上级 2d6f819c
......@@ -80,6 +80,13 @@ public class ProcessInstructionsVisitor extends AbstractVisitor {
}
break;
case STR_CONCAT:
// invoke-custom with string concatenation translated directly to STR_CONCAT, merge next move-result
if (insn.getResult() == null) {
mergeMoveResult(insnByOffset, offset, insn, ArgType.STRING);
}
break;
case FILLED_NEW_ARRAY:
ArgType arrType = ((FilledNewArrayNode) insn).getArrayType();
mergeMoveResult(insnByOffset, offset, insn, arrType);
......
......@@ -47,6 +47,7 @@ import jadx.core.utils.files.FileUtils;
import jadx.core.xmlgen.ResourceStorage;
import jadx.core.xmlgen.entry.ResourceEntry;
import jadx.tests.api.compiler.DynamicCompiler;
import jadx.tests.api.compiler.JavaUtils;
import jadx.tests.api.compiler.StaticCompiler;
import jadx.tests.api.utils.TestUtils;
......@@ -490,6 +491,7 @@ public abstract class IntegrationTest extends TestUtils {
}
protected void useTargetJavaVersion(int version) {
Assumptions.assumeTrue(JavaUtils.checkJavaVersion(version), "skip test for higher java version");
this.targetJavaVersion = version;
}
......
......@@ -3,6 +3,8 @@ package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.RaungTest;
import jadx.tests.api.extensions.inputs.InputPlugin;
import jadx.tests.api.extensions.inputs.TestWithInputPlugins;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
......@@ -40,7 +42,7 @@ public class TestStringConcatJava11 extends RaungTest {
}
@Test
public void testJava() {
public void testJava8() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
......@@ -49,4 +51,14 @@ public class TestStringConcatJava11 extends RaungTest {
"return str + \"test\" + str + 7;",
"return str + \"test\" + str + \"7\";"); // dynamic concat add const to string recipe
}
@TestWithInputPlugins({ InputPlugin.DEX, InputPlugin.JAVA })
public void testJava11() {
useTargetJavaVersion(11);
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("return str + \"test\";")
.containsOne("return str + \"test\" + str + \"7\";");
}
}
......@@ -158,9 +158,13 @@ public class JavaConvertLoader {
try {
DxConverter.run(path, tempDirectory);
} catch (Exception e) {
} catch (Throwable e) {
LOG.warn("DX convert failed, trying D8, path: {}", path);
D8Converter.run(path, tempDirectory);
try {
D8Converter.run(path, tempDirectory);
} catch (Throwable ex) {
LOG.error("D8 convert failed: {}", ex.getMessage());
}
}
LOG.debug("Converted to dex: {}", path.toAbsolutePath());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册