core: fix return block split after try/catch (#295)
This commit is contained in:
@@ -454,7 +454,8 @@ public class BlockProcessor extends AbstractVisitor {
|
||||
}
|
||||
BlockNode exitBlock = mth.getExitBlocks().get(0);
|
||||
if (exitBlock.getInstructions().size() != 1
|
||||
|| exitBlock.contains(AFlag.SYNTHETIC)) {
|
||||
|| exitBlock.contains(AFlag.SYNTHETIC)
|
||||
|| exitBlock.contains(AType.SPLITTER_BLOCK)) {
|
||||
return false;
|
||||
}
|
||||
List<BlockNode> preds = exitBlock.getPredecessors();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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.containsOne;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class TestTryCatchNoMove extends SmaliTest {
|
||||
|
||||
// private static void test(AutoCloseable closeable) {
|
||||
// if (closeable != null) {
|
||||
// try {
|
||||
// closeable.close();
|
||||
// } catch (Exception ignored) {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
ClassNode cls = getClassNodeFromSmaliWithPath("trycatch", "TestTryCatchNoMove");
|
||||
String code = cls.getCode().toString();
|
||||
|
||||
assertThat(code, containsOne("if (autoCloseable != null) {"));
|
||||
assertThat(code, containsOne("try {"));
|
||||
assertThat(code, containsOne("autoCloseable.close();"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
.class public LTestTryCatchNoMove;
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
.method private static test(Ljava/lang/AutoCloseable;)V
|
||||
.locals 0
|
||||
|
||||
if-eqz p0, :cond_0
|
||||
|
||||
.line 187
|
||||
: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
|
||||
:cond_0
|
||||
return-void
|
||||
.end method
|
||||
Reference in New Issue
Block a user