Projects STRLCPY jadx Commits d5740c1b
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockFinallyExtract.java
    skipped 33 lines
    34 34  import org.slf4j.LoggerFactory;
    35 35   
    36 36  import static jadx.core.dex.visitors.blocksmaker.BlockSplitter.connect;
     37 +import static jadx.core.dex.visitors.blocksmaker.BlockSplitter.insertBlockBetween;
    37 38  import static jadx.core.dex.visitors.blocksmaker.BlockSplitter.removeConnection;
    38 39   
    39 40  public class BlockFinallyExtract extends AbstractVisitor {
    skipped 471 lines
    511 512   
    512 513   // redirect input edges
    513 514   for (BlockNode pred : new ArrayList<BlockNode>(remBlock.getPredecessors())) {
    514  - removeConnection(pred, remBlock);
    515  - connect(pred, startBlock);
    516  - addIgnoredEdge(pred, startBlock);
    517  - connect(pred, rOut);
     515 + BlockNode middle = insertBlockBetween(mth, pred, remBlock);
     516 + removeConnection(middle, remBlock);
     517 + connect(middle, startBlock);
     518 + addIgnoredEdge(middle, startBlock);
     519 + connect(middle, rOut);
    518 520   }
    519 521   
    520 522   // mark blocks for remove
    skipped 149 lines
  • ■ ■ ■ ■ ■ ■
    jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatchFinally5.java
     1 +package jadx.tests.integration.trycatch;
     2 + 
     3 +import jadx.core.dex.nodes.ClassNode;
     4 +import jadx.tests.api.IntegrationTest;
     5 + 
     6 +import java.util.ArrayList;
     7 +import java.util.List;
     8 + 
     9 +import org.junit.Test;
     10 + 
     11 +import static jadx.tests.api.utils.JadxMatchers.containsOne;
     12 +import static org.junit.Assert.assertThat;
     13 + 
     14 +public class TestTryCatchFinally5 extends IntegrationTest {
     15 + 
     16 + public static class TestCls {
     17 + private <E> List<E> test(A a, B<E> b) {
     18 + C c = p(a);
     19 + if (c == null) {
     20 + return null;
     21 + }
     22 + D d = b.f(c);
     23 + try {
     24 + if (!d.first()) {
     25 + return null;
     26 + }
     27 + List<E> list = new ArrayList<E>();
     28 + do {
     29 + list.add(b.load(d));
     30 + } while (d.toNext());
     31 + return list;
     32 + } finally {
     33 + d.close();
     34 + }
     35 + }
     36 + 
     37 + private C p(A a) {
     38 + return (C) a;
     39 + }
     40 + 
     41 + private interface A {
     42 + }
     43 + 
     44 + private interface B<T> {
     45 + D f(C c);
     46 + 
     47 + T load(D d);
     48 + }
     49 + 
     50 + private interface C {
     51 + }
     52 + 
     53 + private interface D {
     54 + boolean first();
     55 + 
     56 + boolean toNext();
     57 + 
     58 + void close();
     59 + }
     60 + }
     61 + 
     62 + @Test
     63 + public void test() {
     64 + ClassNode cls = getClassNode(TestCls.class);
     65 + String code = cls.getCode().toString();
     66 + 
     67 + assertThat(code, containsOne("} finally {"));
     68 + // TODO: remove duplicates on multiple paths
     69 +// assertThat(code, containsOne("d.close();"));
     70 + }
     71 +}
     72 + 
Please wait...
Page is in error, reload to recover