-
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.
- Loading branch information
Showing
6 changed files
with
200 additions
and
83 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
37 changes: 37 additions & 0 deletions
37
...e/src/test/java/jadx/tests/integration/conditions/TestTernaryOneBranchInConstructor2.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,37 @@ | ||
package jadx.tests.integration.conditions; | ||
|
||
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.CoreMatchers.containsString; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class TestTernaryOneBranchInConstructor2 extends SmaliTest { | ||
|
||
// @formatter:off | ||
/* | ||
public class A { | ||
public A(String str, String str2, String str3, boolean z) {} | ||
public A(String str, String str2, String str3, boolean z, int i, int i2) { | ||
this(str, (i & 2) != 0 ? "" : str2, (i & 4) != 0 ? "" : str3, (i & 8) != 0 ? false : z); | ||
} | ||
} | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNodeFromSmali(); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("this(str, (i & 2) != 0 ? \"\" : str2," | ||
+ " (i & 4) != 0 ? \"\" : str3," | ||
+ " (i & 8) != 0 ? false : z);")); | ||
assertThat(code, not(containsString("//"))); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
jadx-core/src/test/smali/conditions/TestTernaryOneBranchInConstructor2.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,42 @@ | ||
.class public final Lconditions/TestTernaryOneBranchInConstructor2; | ||
.super Ljava/lang/Object; | ||
|
||
|
||
.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V | ||
.locals 1 | ||
|
||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | ||
|
||
return-void | ||
.end method | ||
|
||
.method public synthetic constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZII)V | ||
.locals 1 | ||
|
||
and-int/lit8 p6, p5, 0x2 | ||
|
||
const-string v0, "" | ||
|
||
if-eqz p6, :cond_0 | ||
|
||
move-object p2, v0 | ||
|
||
:cond_0 | ||
and-int/lit8 p6, p5, 0x4 | ||
|
||
if-eqz p6, :cond_1 | ||
|
||
move-object p3, v0 | ||
|
||
:cond_1 | ||
and-int/lit8 p5, p5, 0x8 | ||
|
||
if-eqz p5, :cond_2 | ||
|
||
const/4 p4, 0x0 | ||
|
||
:cond_2 | ||
invoke-direct {p0, p1, p2, p3, p4}, Lconditions/TestTernaryOneBranchInConstructor2;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V | ||
|
||
return-void | ||
.end method |