-
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: ignore NOPs in try-catch (#668)
- Loading branch information
Showing
4 changed files
with
79 additions
and
4 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
35 changes: 35 additions & 0 deletions
35
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatchLastInsn.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,35 @@ | ||
package jadx.tests.integration.trycatch; | ||
|
||
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 TestTryCatchLastInsn extends SmaliTest { | ||
|
||
// @formatter:off | ||
/* | ||
public Exception test() { | ||
? r1 = "result"; // String | ||
try { | ||
r1 = call(); // Exception | ||
} catch(Exception e) { | ||
System.out.println(r1); // String | ||
r1 = e; | ||
} | ||
return r1; | ||
} | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNodeFromSmali(); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("return call();")); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
jadx-core/src/test/smali/trycatch/TestTryCatchLastInsn.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,34 @@ | ||
.class public Ltrycatch/TestTryCatchLastInsn; | ||
.super Ljava/lang/Object; | ||
.source "TestTryCatchLastInsn.java" | ||
|
||
.method public test()Ljava/lang/Exception; | ||
.registers 6 | ||
|
||
.prologue | ||
const-string v1, "result" | ||
|
||
:try_start | ||
invoke-direct {p0}, Ltrycatch/TestTryCatchLastInsn;->call()Ljava/lang/Exception; | ||
move-result-object v1 | ||
:try_end | ||
.catch Ljava/lang/Exception; {:try_start .. :try_end} :catch | ||
|
||
:goto_return | ||
return-object v1 | ||
|
||
:catch | ||
move-exception v4 | ||
sget-object v3, Ljava/lang/System;->out:Ljava/io/PrintStream; | ||
invoke-virtual {v3, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V | ||
move-object v1, v4 | ||
goto :goto_return | ||
.end method | ||
|
||
|
||
.method private call()Ljava/lang/Exception; | ||
.registers 2 | ||
new-instance v0, Ljava/lang/Exception; | ||
invoke-direct {v0}, Ljava/lang/Exception;-><init>()V | ||
return-object v0 | ||
.end method |