-
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: check block before insert additional move instruction for type i…
…nference
- Loading branch information
Showing
7 changed files
with
155 additions
and
7 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
38 changes: 38 additions & 0 deletions
38
jadx-core/src/test/java/jadx/tests/integration/conditions/TestComplexIf2.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.conditions; | ||
|
||
import org.junit.Test; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.JadxMatchers.containsOne; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class TestComplexIf2 extends SmaliTest { | ||
|
||
/* | ||
public void test() { | ||
if (this.isSaved) { | ||
throw new RuntimeException("Error"); | ||
} | ||
if (LoaderUtils.isContextLoaderAvailable()) { | ||
this.savedContextLoader = LoaderUtils.getContextClassLoader(); | ||
ClassLoader loader = this; | ||
if (this.project != null && "simple".equals(this.project)) { | ||
loader = getClass().getClassLoader(); | ||
} | ||
LoaderUtils.setContextClassLoader(loader); | ||
this.isSaved = true; | ||
} | ||
} | ||
*/ | ||
|
||
@Test | ||
public void test() { | ||
disableCompilation(); | ||
ClassNode cls = getClassNodeFromSmaliWithPkg("conditions", "TestComplexIf2"); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("if (this.project != null && \"simple\".equals(this.project)) {")); | ||
} | ||
} |
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,85 @@ | ||
.class public final Lconditions/TestComplexIf2; | ||
.super Ljava/lang/ClassLoader; | ||
|
||
|
||
# instance fields | ||
.field private isSaved:Z | ||
|
||
.field private project:Ljava/lang/String; | ||
|
||
|
||
.method public test()V | ||
.locals 4 | ||
|
||
.line 415 | ||
iget-boolean v0, p0, Lconditions/TestComplexIf2;->isSaved:Z | ||
|
||
if-eqz v0, :cond_0 | ||
|
||
.line 416 | ||
new-instance v0, Ljava/lang/RuntimeException; | ||
|
||
const-string v1, "Error" | ||
|
||
invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V | ||
|
||
throw v0 | ||
|
||
.line 418 | ||
:cond_0 | ||
invoke-static {}, Lorg/apache/tools/ant/util/LoaderUtils;->isContextLoaderAvailable()Z | ||
|
||
move-result v0 | ||
|
||
if-eqz v0, :cond_2 | ||
|
||
.line 419 | ||
invoke-static {}, Lorg/apache/tools/ant/util/LoaderUtils;->getContextClassLoader()Ljava/lang/ClassLoader; | ||
|
||
move-result-object v0 | ||
|
||
iput-object v0, p0, Lconditions/TestComplexIf2;->savedContextLoader:Ljava/lang/ClassLoader; | ||
|
||
.line 420 | ||
move-object v0, p0 | ||
|
||
.line 421 | ||
.local v0, "loader":Ljava/lang/ClassLoader; | ||
iget-object v1, p0, Lconditions/TestComplexIf2;->project:Ljava/lang/String; | ||
|
||
if-eqz v1, :cond_1 | ||
|
||
const-string v1, "simple" | ||
|
||
iget-object v2, p0, Lconditions/TestComplexIf2;->project:Ljava/lang/String; | ||
|
||
invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z | ||
|
||
move-result v1 | ||
|
||
if-eqz v1, :cond_1 | ||
|
||
.line 423 | ||
invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class; | ||
|
||
move-result-object v1 | ||
|
||
invoke-virtual {v1}, Ljava/lang/Class;->getClassLoader()Ljava/lang/ClassLoader; | ||
|
||
move-result-object v0 | ||
|
||
.line 425 | ||
:cond_1 | ||
invoke-static {v0}, Lorg/apache/tools/ant/util/LoaderUtils;->setContextClassLoader(Ljava/lang/ClassLoader;)V | ||
|
||
.line 426 | ||
const/4 v1, 0x1 | ||
|
||
iput-boolean v1, p0, Lconditions/TestComplexIf2;->isSaved:Z | ||
|
||
.line 428 | ||
.end local v0 # "loader":Ljava/lang/ClassLoader; | ||
:cond_2 | ||
return-void | ||
.end method | ||
|