Skip to content

Commit

Permalink
fix: resolve inherited method to use correct alias (#1582)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jul 24, 2022
1 parent 87e0e5b commit 8b4f8fb
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
6 changes: 5 additions & 1 deletion jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,11 @@ private void makeInvoke(InvokeNode insn, ICodeWriter code) throws CodegenExcepti
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ protected void disableCompilation() {

protected void enableDeobfuscation() {
args.setDeobfuscationOn(true);
args.setDeobfuscationMapFileMode(DeobfuscationMapFileMode.OVERWRITE);
args.setDeobfuscationMapFileMode(DeobfuscationMapFileMode.IGNORE);
args.setDeobfuscationMinLength(2);
args.setDeobfuscationMaxLength(64);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();");
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package jadx.tests.integration.names;

import java.util.List;

import org.junit.jupiter.api.Test;

import jadx.api.CommentsLevel;
Expand Down

0 comments on commit 8b4f8fb

Please sign in to comment.