-
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: handle anonymous class self inlining (#604)
- Loading branch information
Showing
11 changed files
with
120 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
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
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
38 changes: 38 additions & 0 deletions
38
jadx-core/src/test/java/jadx/tests/integration/inner/TestIncorrectAnonymousClass.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,38 @@ | ||
package jadx.tests.integration.inner; | ||
|
||
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 jadx.tests.api.utils.JadxMatchers.countString; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class TestIncorrectAnonymousClass extends SmaliTest { | ||
|
||
// @formatter:off | ||
/* | ||
public static class TestCls { | ||
public final class 1 { | ||
public void invoke() { | ||
new 1(); // cause infinite self inline | ||
} | ||
} | ||
public void test() { | ||
new 1(); | ||
} | ||
} | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNodeFromSmaliFiles("TestCls"); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("public final class AnonymousClass1 {")); | ||
assertThat(code, countString(2, "new AnonymousClass1();")); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
jadx-core/src/test/smali/inner/TestIncorrectAnonymousClass/TestCls$1.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,24 @@ | ||
.class public final Linner/TestCls$1; | ||
.super Ljava/lang/Object; | ||
|
||
|
||
# direct methods | ||
.method public constructor <init>()V | ||
.registers 1 | ||
|
||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | ||
|
||
return-void | ||
.end method | ||
|
||
|
||
# virtual methods | ||
.method public invoke()V | ||
.registers 2 | ||
|
||
new-instance v0, Linner/TestCls$1; | ||
|
||
invoke-direct {v0}, Linner/TestCls$1;-><init>()V | ||
|
||
return-void | ||
.end method |
21 changes: 21 additions & 0 deletions
21
jadx-core/src/test/smali/inner/TestIncorrectAnonymousClass/TestCls.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,21 @@ | ||
.class public Linner/TestCls; | ||
.super Ljava/lang/Object; | ||
|
||
# direct methods | ||
.method public constructor <init>()V | ||
.registers 1 | ||
|
||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | ||
|
||
return-void | ||
.end method | ||
|
||
.method public test()V | ||
.registers 2 | ||
|
||
new-instance v0, Linner/TestCls$1; | ||
|
||
invoke-direct {v0}, Linner/TestCls$1;-><init>()V | ||
|
||
return-void | ||
.end method |