未验证 提交 5c75f249 编写于 作者: J Jonas Konrad 提交者: GitHub

fix: do not count nop instructions when considering methods for fallback mode...

fix: do not count nop instructions when considering methods for fallback mode printing (#1038) (PR #1039)
上级 02bfe632
......@@ -3,6 +3,8 @@ package jadx.core.codegen;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -290,7 +292,11 @@ public class MethodGen {
code.startLine("// Can't load method instructions.");
return;
}
if (insnArr.length > 100) {
long insnCountEstimate = Stream.of(insnArr)
.filter(Objects::nonNull)
.filter(insn -> insn.getType() != InsnType.NOP)
.count();
if (insnCountEstimate > 100) {
code.startLine("// Method dump skipped, instructions count: " + insnArr.length);
return;
}
......
package jadx.tests.integration.fallback;
import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
public class TestFallbackManyNops extends SmaliTest {
@Test
public void test() {
setFallback();
disableCompilation();
ClassNode cls = getClassNodeFromSmali();
String code = cls.getCode().toString();
assertThat(code, containsString("public static void test() {"));
assertThat(code, containsOne("return"));
assertThat(code, not(containsString("Method dump skipped")));
}
}
.class public Lfallback/TestFallbackManyNops;
.super Ljava/lang/Object;
.method public static test()V
.registers 1
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
return-void
.end method
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册