-
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: adjust insn reorder check in code shrink visitor (#695)
- Loading branch information
Showing
4 changed files
with
91 additions
and
49 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
37 changes: 37 additions & 0 deletions
37
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions18.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 TestConditions18 extends SmaliTest { | ||
|
||
// @formatter:off | ||
/* | ||
public static class TestConditions18 { | ||
private Map map; | ||
public boolean test(Object obj) { | ||
return this == obj || ((obj instanceof TestConditions18) && st(this.map, ((TestConditions18) obj).map)); | ||
} | ||
private static boolean st(Object obj, Object obj2) { | ||
return false; | ||
} | ||
} | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNodeFromSmali(); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("return this == obj" | ||
+ " || ((obj instanceof TestConditions18) && st(this.map, ((TestConditions18) obj).map));")); | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
jadx-core/src/test/java/jadx/tests/integration/inline/TestInlineInLoop.java
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
jadx-core/src/test/smali/conditions/TestConditions18.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,45 @@ | ||
.class public final Lconditions/TestConditions18; | ||
.super Ljava/lang/Object; | ||
|
||
.field private map:Ljava/util/Map; | ||
|
||
.method public test(Ljava/lang/Object;)Z | ||
.locals 1 | ||
|
||
if-eq p0, p1, :cond_1 | ||
|
||
instance-of v0, p1, Lconditions/TestConditions18; | ||
|
||
if-eqz v0, :cond_0 | ||
|
||
check-cast p1, Lconditions/TestConditions18; | ||
|
||
iget-object v0, p0, Lconditions/TestConditions18;->map:Ljava/util/Map; | ||
|
||
iget-object p1, p1, Lconditions/TestConditions18;->map:Ljava/util/Map; | ||
|
||
invoke-static {v0, p1}, Lconditions/TestConditions18;->st(Ljava/lang/Object;Ljava/lang/Object;)Z | ||
|
||
move-result p1 | ||
|
||
if-eqz p1, :cond_0 | ||
|
||
goto :goto_0 | ||
|
||
:cond_0 | ||
const/4 p1, 0x0 | ||
|
||
return p1 | ||
|
||
:cond_1 | ||
:goto_0 | ||
const/4 p1, 0x1 | ||
|
||
return p1 | ||
.end method | ||
|
||
.method private static st(Ljava/lang/Object;Ljava/lang/Object;)Z | ||
.locals 1 | ||
const/4 v0, 0x0 | ||
return v0 | ||
.end method |