fix: resolve inherited method to use correct alias (#1582)

This commit is contained in:
Skylot
2022-07-24 16:53:29 +01:00
parent 87e0e5bf16
commit 8b4f8fb572
4 changed files with 47 additions and 4 deletions
@@ -828,7 +828,11 @@ public class InsnGen {
if (insn.contains(AFlag.FORCE_RAW_NAME)) {
code.add(callMth.getName());
} else {
code.add(callMth.getAlias());
if (callMthNode != null) {
code.add(callMthNode.getAlias());
} else {
code.add(callMth.getAlias());
}
}
generateMethodArguments(code, insn, k, callMthNode);
}
@@ -555,7 +555,7 @@ public abstract class IntegrationTest extends TestUtils {
protected void enableDeobfuscation() {
args.setDeobfuscationOn(true);
args.setDeobfuscationMapFileMode(DeobfuscationMapFileMode.OVERWRITE);
args.setDeobfuscationMapFileMode(DeobfuscationMapFileMode.IGNORE);
args.setDeobfuscationMinLength(2);
args.setDeobfuscationMaxLength(64);
}
@@ -0,0 +1,41 @@
package jadx.tests.integration.deobf;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestInheritedMethodRename extends IntegrationTest {
public static class TestCls {
public static class A extends B {
}
public static class B {
public void call() {
System.out.println("call");
}
}
public void test(A a) {
// reference to A.call() not renamed,
// should be resolved to B.call() and use alias
a.call();
}
}
@Test
public void test() {
noDebugInfo();
enableDeobfuscation();
getArgs().setDeobfuscationMinLength(99);
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("public void m0call() {")
.doesNotContain(".call();")
.containsOne(".m0call();");
}
}
@@ -1,7 +1,5 @@
package jadx.tests.integration.names;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.api.CommentsLevel;