-
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: merge const block before return (#699)
- Loading branch information
Showing
7 changed files
with
218 additions
and
41 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
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions21.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.MatcherAssert.assertThat; | ||
|
||
public class TestConditions21 extends SmaliTest { | ||
|
||
// @formatter:off | ||
/* | ||
public boolean check(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj instanceof List) { | ||
List list = (List) obj; | ||
if (!list.isEmpty() && list.contains(this)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNodeFromSmali(); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("!list.isEmpty() && list.contains(this)")); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
jadx-core/src/test/smali/conditions/TestConditions21.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,33 @@ | ||
.class public final Lconditions/TestConditions21; | ||
.super Ljava/lang/Object; | ||
|
||
.method public check(Ljava/lang/Object;)Z | ||
.locals 2 | ||
|
||
if-eq p0, p1, :ret_true | ||
|
||
instance-of v0, p1, Ljava/util/List; | ||
if-eqz v0, :ret_false | ||
|
||
check-cast p1, Ljava/util/List; | ||
|
||
invoke-interface {p1}, Ljava/util/List;->isEmpty()Z | ||
move-result v0 | ||
|
||
if-nez v0, :ret_false | ||
|
||
invoke-interface {p1, p0}, Ljava/util/List;->contains(Ljava/lang/Object;)Z | ||
move-result v0 | ||
|
||
if-eqz v0, :ret_false | ||
|
||
goto :ret_true | ||
|
||
:ret_false | ||
const/4 p1, 0x0 | ||
return p1 | ||
|
||
:ret_true | ||
const/4 p1, 0x1 | ||
return p1 | ||
.end method |