diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java b/jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java index ae2f95fb6a5a698e3dfacbbed4a6e2ae0d9750c7..64cd7c282a809eefd776fd6db315b89cd30e0e0d 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java @@ -113,12 +113,11 @@ public class BlockSplitter extends AbstractVisitor { } } } + if (insn.contains(AType.EXC_HANDLER)) { + processExceptionHandler(mth, curBlock, insn); + } if (insn.contains(AFlag.TRY_ENTER)) { curBlock = insertSplitterBlock(mth, blocksMap, curBlock, insn, startNew); - } else if (insn.contains(AType.EXC_HANDLER)) { - processExceptionHandler(mth, curBlock, insn); - blocksMap.put(insn.getOffset(), curBlock); - curBlock.getInstructions().add(insn); } else { blocksMap.put(insn.getOffset(), curBlock); curBlock.getInstructions().add(insn); diff --git a/jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryWithEmptyCatchTriple.java b/jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryWithEmptyCatchTriple.java new file mode 100644 index 0000000000000000000000000000000000000000..0abe33eb57821f4ad1712818e9c21304711dce39 --- /dev/null +++ b/jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryWithEmptyCatchTriple.java @@ -0,0 +1,21 @@ +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 TestTryWithEmptyCatchTriple extends SmaliTest { + @Test + public void test() { + ClassNode cls = getClassNodeFromSmaliWithPkg("trycatch", "TestTryWithEmptyCatchTriple"); + String code = cls.getCode().toString(); + + assertThat(code, containsOne("} catch (Error unused) {")); + assertThat(code, containsOne("} catch (Error unused2) {")); + assertThat(code, containsOne("} catch (Error unused3) {")); + } +} diff --git a/jadx-core/src/test/smali/trycatch/TestTryWithEmptyCatchTriple.smali b/jadx-core/src/test/smali/trycatch/TestTryWithEmptyCatchTriple.smali new file mode 100644 index 0000000000000000000000000000000000000000..3aefe6274420af90963d470d1f887534905c5aea --- /dev/null +++ b/jadx-core/src/test/smali/trycatch/TestTryWithEmptyCatchTriple.smali @@ -0,0 +1,53 @@ +.class public Ltrycatch/TestTryWithEmptyCatchTriple; +.super Ljava/lang/Object; + +.field static field:[I + +.method static test()V + .registers 3 + const/4 v0, 0x1 + + :try_start_1 + sget-object v1, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I + + const/4 v2, 0x0 + + aput v0, v1, v2 + + :try_end_1 + .catch Ljava/lang/Error; {:try_start_1 .. :try_end_1} :catch_1 + + :catch_1 + + sget-object v1, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I + + array-length v1, v1 + + new-array v1, v1, [I + + sput-object v1, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I + + :try_start_2 + sget-object v1, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I + + const/4 v2, 0x0 + + aput v0, v1, v2 + :try_end_2 + .catch Ljava/lang/Error; {:try_start_2 .. :try_end_2} :catch_2 + + :catch_2 + :try_start_3 + sget-object v0, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I + + const/4 v1, 0x0 + + const/4 v2, 0x2 + + aput v2, v0, v1 + :try_end_3 + .catch Ljava/lang/Error; {:try_start_3 .. :try_end_3} :catch_3 + + :catch_3 + return-void +.end method