-
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: process try/catch without move-exception instruction (#395)
- Loading branch information
Showing
4 changed files
with
141 additions
and
69 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
39 changes: 39 additions & 0 deletions
39
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatchNoMoveExc2.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,39 @@ | ||
package jadx.tests.integration.trycatch; | ||
|
||
import org.junit.Test; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.JadxMatchers.containsLines; | ||
import static jadx.tests.api.utils.JadxMatchers.containsOne; | ||
import static org.junit.Assert.assertThat; | ||
|
||
/** | ||
* Issue: https://github.com/skylot/jadx/issues/395 | ||
*/ | ||
public class TestTryCatchNoMoveExc2 extends SmaliTest { | ||
|
||
// private static void test(AutoCloseable closeable) { | ||
// if (closeable != null) { | ||
// try { | ||
// closeable.close(); | ||
// } catch (Exception unused) { | ||
// } | ||
// System.nanoTime(); | ||
// } | ||
// } | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNodeFromSmaliWithPath("trycatch", "TestTryCatchNoMoveExc2"); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("try {")); | ||
assertThat(code, containsLines(2, | ||
"} catch (Exception unused) {", | ||
"}", | ||
"System.nanoTime();" | ||
)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
jadx-core/src/test/smali/trycatch/TestTryCatchNoMoveExc2.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,16 @@ | ||
.class public LTestTryCatchNoMoveExc2; | ||
.super Ljava/lang/Object; | ||
|
||
.method private static test(Ljava/lang/AutoCloseable;)V | ||
.locals 0 | ||
|
||
:try_start_0 | ||
invoke-interface {p0}, Ljava/lang/AutoCloseable;->close()V | ||
:try_end_0 | ||
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0 | ||
|
||
:catch_0 | ||
invoke-static {}, Ljava/lang/System;->nanoTime()J | ||
|
||
return-void | ||
.end method |