-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: check full signature for search method override (#1743)
- Loading branch information
Showing
5 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
jadx-core/src/test/java/jadx/tests/integration/others/TestOverrideWithSameName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package jadx.tests.integration.others; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.core.dex.attributes.AType; | ||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
@SuppressWarnings("CommentedOutCode") | ||
public class TestOverrideWithSameName extends SmaliTest { | ||
|
||
//@formatter:off | ||
/* | ||
interface A { | ||
B a(); | ||
C a(); | ||
} | ||
abstract class B implements A { | ||
@Override | ||
public C a() { | ||
return null; | ||
} | ||
} | ||
public class C extends B { | ||
@Override | ||
public B a() { | ||
return null; | ||
} | ||
} | ||
*/ | ||
//@formatter:on | ||
|
||
@Test | ||
public void test() { | ||
List<ClassNode> clsNodes = loadFromSmaliFiles(); | ||
assertThat(searchCls(clsNodes, "test.A")) | ||
.code() | ||
.containsOne("C mo0a();") // assume second method was renamed | ||
.doesNotContain("@Override"); | ||
|
||
ClassNode bCls = searchCls(clsNodes, "test.B"); | ||
assertThat(bCls) | ||
.code() | ||
.containsOne("C mo0a() {") | ||
.containsOne("@Override"); | ||
|
||
assertThat(getMethod(bCls, "a").get(AType.METHOD_OVERRIDE).getOverrideList()) | ||
.singleElement() | ||
.satisfies(mth -> assertThat(mth.getMethodInfo().getDeclClass().getShortName()).isEqualTo("A")); | ||
|
||
ClassNode cCls = searchCls(clsNodes, "test.C"); | ||
assertThat(cCls) | ||
.code() | ||
.containsOne("B a() {") | ||
.containsOne("@Override"); | ||
|
||
assertThat(getMethod(cCls, "a").get(AType.METHOD_OVERRIDE).getOverrideList()) | ||
.singleElement() | ||
.satisfies(mth -> assertThat(mth.getMethodInfo().getDeclClass().getShortName()).isEqualTo("A")); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
jadx-core/src/test/smali/others/TestOverrideWithSameName/A.smali
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.class interface abstract Ltest/A; | ||
.super Ljava/lang/Object; | ||
|
||
.method public abstract a()Ltest/B; | ||
.end method | ||
|
||
.method public abstract a()Ltest/C; | ||
.end method |
10 changes: 10 additions & 0 deletions
10
jadx-core/src/test/smali/others/TestOverrideWithSameName/B.smali
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.class abstract Ltest/B; | ||
.super Ljava/lang/Object; | ||
|
||
.implements Ltest/A; | ||
|
||
.method public a()Ltest/C; | ||
.registers 2 | ||
const/4 v0, 0x0 | ||
return-object v0 | ||
.end method |
8 changes: 8 additions & 0 deletions
8
jadx-core/src/test/smali/others/TestOverrideWithSameName/C.smali
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.class public Ltest/C; | ||
.super Ltest/B; | ||
|
||
.method public a()Ltest/B; | ||
.registers 2 | ||
const/4 v0, 0x0 | ||
return-object v0 | ||
.end method |