-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: comment out instructions before super call in constructor (#685)
- Loading branch information
Showing
6 changed files
with
128 additions
and
1 deletion.
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
41 changes: 41 additions & 0 deletions
41
jadx-core/src/test/java/jadx/tests/integration/others/TestInsnsBeforeSuper.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,41 @@ | ||
package jadx.tests.integration.others; | ||
|
||
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 org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class TestInsnsBeforeSuper extends SmaliTest { | ||
// @formatter:off | ||
/* | ||
public class A { | ||
public A(String s) { | ||
} | ||
} | ||
public class B extends A { | ||
public B(String str) { | ||
checkNull(str); | ||
super(str); | ||
} | ||
public void checkNull(Object o) { | ||
if (o == null) { | ||
throw new NullPointerException(); | ||
} | ||
} | ||
} | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNodeFromSmaliFiles("B"); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("// checkNull(str);")); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
jadx-core/src/test/smali/others/TestInsnsBeforeSuper/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,14 @@ | ||
.class public Lothers/A; | ||
.super Ljava/lang/Object; | ||
|
||
|
||
# direct methods | ||
.method public constructor <init>(Ljava/lang/String;)V | ||
.registers 3 | ||
|
||
.prologue | ||
|
||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | ||
|
||
return-void | ||
.end method |
30 changes: 30 additions & 0 deletions
30
jadx-core/src/test/smali/others/TestInsnsBeforeSuper/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,30 @@ | ||
.class public Lothers/B; | ||
.super Lothers/A; | ||
|
||
|
||
# direct methods | ||
.method public constructor <init>(Ljava/lang/String;)V | ||
.registers 3 | ||
|
||
.prologue | ||
invoke-static {p1}, Lothers/B;->checkNull(Ljava/lang/Object;)V | ||
|
||
invoke-direct {p0, p1}, Lothers/A;-><init>(Ljava/lang/String;)V | ||
|
||
return-void | ||
.end method | ||
|
||
|
||
.method public static checkNull(Ljava/lang/Object;)V | ||
.registers 3 | ||
|
||
.prologue | ||
if-nez p0, :cond_8 | ||
|
||
new-instance v0, Ljava/lang/NullPointerException; | ||
invoke-direct {v0}, Ljava/lang/NullPointerException;-><init>()V | ||
throw v0 | ||
|
||
:cond_8 | ||
return-void | ||
.end method |