-
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: correct inline/merge with overriden bridge method (#1580)
- Loading branch information
Showing
7 changed files
with
122 additions
and
9 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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
jadx-core/src/test/java/jadx/tests/integration/inline/TestOverrideBridgeMerge.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,45 @@ | ||
package jadx.tests.integration.inline; | ||
|
||
import java.util.function.Function; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.api.metadata.ICodeAnnotation; | ||
import jadx.api.metadata.annotations.NodeDeclareRef; | ||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestOverrideBridgeMerge extends SmaliTest { | ||
|
||
public static class TestCls implements Function<String, Integer> { | ||
@Override | ||
public /* bridge */ /* synthetic */ Integer apply(String str) { | ||
return test(str); | ||
} | ||
|
||
public Integer test(String str) { | ||
return str.length(); | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
assertThat(getClassNode(TestCls.class)) | ||
.code() | ||
.containsOne("Integer test(String str) {"); // not inlined | ||
} | ||
|
||
@Test | ||
public void testSmali() { | ||
ClassNode cls = getClassNodeFromSmali(); | ||
ICodeAnnotation mthDef = new NodeDeclareRef(getMethod(cls, "apply")); | ||
assertThat(cls) | ||
.checkCodeAnnotationFor("apply(String str) {", mthDef) | ||
.code() | ||
.containsOne("@Override") | ||
.containsOne("public Integer apply(String str) {") | ||
.doesNotContain("test(String str)"); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
jadx-core/src/test/smali/inline/TestOverrideBridgeMerge.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,39 @@ | ||
.class public Linline/TestOverrideBridgeMerge; | ||
.super Ljava/lang/Object; | ||
|
||
.implements Ljava/util/function/Function; | ||
|
||
.annotation system Ldalvik/annotation/Signature; | ||
value = { | ||
"Ljava/lang/Object;", | ||
"Ljava/util/function/Function", | ||
"<", | ||
"Ljava/lang/String;", | ||
"Ljava/lang/Integer;", | ||
">;" | ||
} | ||
.end annotation | ||
|
||
.method public constructor <init>()V | ||
.registers 1 | ||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | ||
return-void | ||
.end method | ||
|
||
.method public bridge synthetic apply(Ljava/lang/Object;)Ljava/lang/Object; | ||
.registers 3 | ||
check-cast p1, Ljava/lang/String; | ||
invoke-virtual {p0, p1}, Linline/TestOverrideBridgeMerge;->test(Ljava/lang/String;)Ljava/lang/Integer; | ||
move-result-object v0 | ||
return-object v0 | ||
.end method | ||
|
||
.method public test(Ljava/lang/String;)Ljava/lang/Integer; | ||
.registers 3 | ||
.param p1, "str" # Ljava/lang/String; | ||
invoke-virtual {p1}, Ljava/lang/String;->length()I | ||
move-result v0 | ||
invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer; | ||
move-result-object v0 | ||
return-object v0 | ||
.end method |