未验证 提交 3f25f072 编写于 作者: J Jonas Konrad 提交者: GitHub

fix: properly traverse methods with synchronize blocks that have no clear exit (PR #1041)

上级 5c75f249
......@@ -594,6 +594,8 @@ public class RegionMaker {
List<BlockNode> list = BlockUtils.buildSimplePath(exitBlock);
if (list.isEmpty() || !list.get(list.size() - 1).getSuccessors().isEmpty()) {
stack.addExit(exitBlock);
// we can still try using this as an exit block to make sure it's visited.
exit = exitBlock;
}
}
}
......
......@@ -2,7 +2,6 @@ package jadx.tests.integration.loops;
import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
......@@ -34,7 +33,6 @@ public class TestSynchronizedInEndlessLoop extends IntegrationTest {
}
@Test
@NotYetImplemented
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
......
package jadx.tests.integration.synchronize;
import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.SmaliTest;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
public class TestSynchronized5 extends SmaliTest {
@Test
public void test() {
ClassNode cls = getClassNodeFromSmali();
String code = cls.getCode().toString();
assertThat(code, containsString("1 != 0"));
assertThat(code, containsString("System.gc();"));
}
}
.class public Lsynchronize/TestSynchronized5;
.super Ljava/lang/Object;
.method public final get()V
.registers 6
monitor-enter p0
:try_start_1
const/4 v0, 0
if-eqz v0, :cond_1
monitor-exit p0
return-void
:cond_1
monitor-exit p0
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_1
monitor-enter p0
:try_start_2
const/4 v1, 1
if-eqz v1, :cond_2
invoke-static {}, Ljava/lang/System;->gc()V
:cond_2
monitor-exit p0
:try_end_2
.catchall {:try_start_2 .. :try_end_2} :catchall_2
return-void
:catchall_2
move-exception v0
:try_start_3
monitor-exit p0
:try_end_3
.catchall {:try_start_3 .. :try_end_3} :catchall_2
throw v0
:catchall_1
move-exception v0
:try_start_4
monitor-exit p0
:try_end_4
.catchall {:try_start_4 .. :try_end_4} :catchall_1
throw v0
.end method
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册