Commit 7accc6e5 authored by Skylot's avatar Skylot

core: fix synchronized block processing (fix #46)

parent fa8f9ccf
......@@ -548,7 +548,7 @@ public class RegionMaker {
return;
}
}
for (BlockNode node : block.getCleanSuccessors()) {
for (BlockNode node : block.getSuccessors()) {
if (!visited.contains(node)) {
traverseMonitorExits(region, arg, node, exits, visited);
}
......
package jadx.tests.integration.trycatch;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
import org.junit.Test;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
public class TestTryCatch8 extends IntegrationTest {
public static class TestCls {
static class MyException extends Exception {
private static final long serialVersionUID = 7963400419047287279L;
MyException() {
}
MyException(String msg, Throwable cause) {
super(msg, cause);
}
}
MyException e = null;
public void test() {
synchronized (this) {
try {
throw new MyException();
} catch (MyException e) {
this.e = e;
} catch (Exception x) {
this.e = new MyException("MyExc", x);
}
}
}
public void check() {
test();
assertThat(e, notNullValue());
assertThat(e, isA(MyException.class));
assertThat(e.getMessage(), nullValue());
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("synchronized (this) {"));
assertThat(code, containsOne("throw new MyException();"));
assertThat(code, containsOne("} catch (MyException e) {"));
assertThat(code, containsOne("this.e = e;"));
assertThat(code, containsOne("} catch (Exception x) {"));
assertThat(code, containsOne("this.e = new MyException(\"MyExc\", x);"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment