core: fix synchronized block processing

This commit is contained in:
Skylot
2014-02-22 23:22:59 +04:00
parent c6f0c89cf6
commit b61daaed33
12 changed files with 168 additions and 21 deletions
@@ -0,0 +1,41 @@
package jadx.tests.internal;
import jadx.api.InternalJadxTest;
import jadx.core.dex.nodes.ClassNode;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
public class TestSynchronized extends InternalJadxTest {
public static class TestCls {
public boolean f = false;
public final Object o = new Object();
public int i = 7;
public synchronized boolean test1() {
return this.f;
}
public int test2() {
synchronized (this.o) {
return i;
}
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
System.out.println(code);
assertThat(code, not(containsString("synchronized (this) {")));
assertThat(code, containsString("public synchronized boolean test1() {"));
assertThat(code, containsString("return this.f"));
assertThat(code, containsString("synchronized (this.o) {"));
}
}
@@ -0,0 +1,35 @@
package jadx.tests.internal.inline;
import jadx.api.InternalJadxTest;
import jadx.core.dex.nodes.ClassNode;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
public class TestInline6 extends InternalJadxTest {
public static class TestCls {
public void f() {
}
public void test(int a, int b) {
long start = System.nanoTime();
f();
System.out.println(System.nanoTime() - start);
}
}
@Test
public void test() {
setOutputCFG();
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
System.out.println(code);
assertThat(code, containsString("System.out.println(System.nanoTime() - start);"));
assertThat(code, not(containsString("System.out.println(System.nanoTime() - System.nanoTime());")));
}
}