repo stringclasses 1k values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1 value | license stringclasses 6 values | commit_sha stringclasses 1k values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2 classes |
|---|---|---|---|---|---|---|---|---|
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/loops/TestLoopDetection2.java | jadx-core/src/test/java/jadx/tests/integration/loops/TestLoopDetection2.java | package jadx.tests.integration.loops;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestLoopDetection2 extends IntegrationTest {
public static class TestCls {
public int test(int a, int b) {
int c = a + b;
for (int i = a; i < b; i++) {
if (i == 7) {
c += 2;
} else {
c *= 2;
}
}
c--;
return c;
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("int c = a + b;")
.containsOne("for (int i = a; i < b; i++) {")
.doesNotContain("c_2");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/loops/TestMultiEntryLoop.java | jadx-core/src/test/java/jadx/tests/integration/loops/TestMultiEntryLoop.java | package jadx.tests.integration.loops;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestMultiEntryLoop extends SmaliTest {
@Test
public void test() {
assertThat(getClassNodeFromSmali())
.code()
.containsOne("while (true) {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/loops/TestMultiEntryLoop2.java | jadx-core/src/test/java/jadx/tests/integration/loops/TestMultiEntryLoop2.java | package jadx.tests.integration.loops;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestMultiEntryLoop2 extends SmaliTest {
@Test
public void test() {
assertThat(getClassNodeFromSmali())
.code()
.containsOne("while (true) {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/loops/TestIterableForEach3.java | jadx-core/src/test/java/jadx/tests/integration/loops/TestIterableForEach3.java | package jadx.tests.integration.loops;
import java.util.Set;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestIterableForEach3 extends IntegrationTest {
public static class TestCls<T extends String> {
private Set<T> a;
private Set<T> b;
public void test(T str) {
Set<T> set = str.length() == 1 ? a : b;
for (T s : set) {
if (s.length() == str.length()) {
if (str.length() == 0) {
set.remove(s);
} else {
set.add(str);
}
return;
}
}
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("for (T s : set) {")
.containsOne("if (str.length() == 0) {");
// TODO move return outside 'if'
}
@Test
public void testNoDebug() {
noDebugInfo();
getClassNode(TestCls.class);
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/loops/TestSequentialLoops2.java | jadx-core/src/test/java/jadx/tests/integration/loops/TestSequentialLoops2.java | package jadx.tests.integration.loops;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestSequentialLoops2 extends IntegrationTest {
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
public static class TestCls {
private static char[] lowercases = new char[] { 'a' };
public static String asciiToLowerCase(String s) {
char[] c = null;
int i = s.length();
while (i-- > 0) {
char c1 = s.charAt(i);
if (c1 <= 127) {
char c2 = lowercases[c1];
if (c1 != c2) {
c = s.toCharArray();
c[i] = c2;
break;
}
}
}
while (i-- > 0) {
if (c[i] <= 127) {
c[i] = lowercases[c[i]];
}
}
return c == null ? s : new String(c);
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.countString(2, "while (")
.contains("break;")
.containsOne("return c")
.countString(2, "<= 127");
}
@Test
public void testNoDebug() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.countString(2, "while (")
.contains("break;")
.countString(2, "<= 127");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/loops/TestComplexWhileLoop.java | jadx-core/src/test/java/jadx/tests/integration/loops/TestComplexWhileLoop.java | package jadx.tests.integration.loops;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestComplexWhileLoop extends IntegrationTest {
public static class TestCls {
public static String test(String[] arr) {
int index = 0;
int length = arr.length;
String str;
while ((str = arr[index]) != null) {
if (str.length() == 1) {
return str.trim();
}
if (++index >= length) {
index = 0;
}
}
System.out.println("loop end");
return "";
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("for (int at = 0; at < len; at = endAt) {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/loops/TestBreakInLoop2.java | jadx-core/src/test/java/jadx/tests/integration/loops/TestBreakInLoop2.java | package jadx.tests.integration.loops;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestBreakInLoop2 extends IntegrationTest {
@SuppressWarnings({ "BusyWait", "ResultOfMethodCallIgnored" })
public static class TestCls {
public void test(List<Integer> data) throws Exception {
for (;;) {
try {
funcB(data);
break;
} catch (Exception ex) {
if (funcC()) {
throw ex;
}
data.clear();
}
Thread.sleep(100L);
}
}
private boolean funcB(List<Integer> data) {
return false;
}
private boolean funcC() {
return true;
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("while (true) {")
.containsOneOf("break;", "return;")
.containsOne("throw ex;")
.containsOne("data.clear();")
.containsOne("Thread.sleep(100L);");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestSyntheticConstructor.java | jadx-core/src/test/java/jadx/tests/integration/others/TestSyntheticConstructor.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestSyntheticConstructor extends SmaliTest {
// @formatter:off
/*
public class Test {
static {
new BuggyConstructor();
}
}
*/
// @formatter:on
@Test
public void test() {
disableCompilation();
assertThat(getClassNodeFromSmaliFiles("Test"))
.code()
.containsLine(2, "new BuggyConstructor();");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStringConstructor.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStringConstructor.java | package jadx.tests.integration.others;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestStringConstructor extends IntegrationTest {
public static class TestCls {
public String tag = new String(new byte[] { 'a', 'b', 'c' });
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("abc");
}
public static class TestCls2 {
public String tag = new String(new byte[] { 'a', 'b', 'c' }, StandardCharsets.UTF_8);
}
@Test
public void test2() {
JadxAssertions.assertThat(getClassNode(TestCls2.class))
.code()
.containsOne("new String(\"abc\".getBytes(), StandardCharsets.UTF_8)");
}
public static class TestCls3 {
public String tag = new String(new byte[] { 1, 2, 3, 'a', 'b', 'c' });
}
@Test
public void test3() {
JadxAssertions.assertThat(getClassNode(TestCls3.class))
.code()
.containsOne("\\u0001\\u0002\\u0003abc");
}
public static class TestCls4 {
public String tag = new String(new char[] { 1, 2, 3, 'a', 'b', 'c' });
}
@Test
public void test4() {
JadxAssertions.assertThat(getClassNode(TestCls4.class))
.code()
.containsOne("\\u0001\\u0002\\u0003abc");
}
public static class TestCls5 {
public String tag = new String(new char[] { 1, 2, 3, 'a', 'b' });
}
@Test
public void test5() {
JadxAssertions.assertThat(getClassNode(TestCls5.class))
.code()
.containsOne("{1, 2, 3, 'a', 'b'}");
}
public static class TestClsNegative {
public String tag = new String();
}
@Test
public void testNegative() {
JadxAssertions.assertThat(getClassNode(TestClsNegative.class))
.code()
.containsOne("tag = new String();");
}
public static class TestClsNegative2 {
public byte b = 32;
public String tag = new String(new byte[] { 31, b });
}
@Test
public void testNegative2() {
JadxAssertions.assertThat(getClassNode(TestClsNegative2.class))
.code()
.containsOne("tag = new String(new byte[]{31, this.b});");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestBadMethodAccessModifiers.java | jadx-core/src/test/java/jadx/tests/integration/others/TestBadMethodAccessModifiers.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestBadMethodAccessModifiers extends SmaliTest {
// @formatter:off
/*
public static class TestCls {
public abstract class A {
public abstract void test();
}
public class B extends A {
protected void test() {
}
}
}
*/
// @formatter:on
@Test
public void test() {
assertThat(getClassNodeFromSmaliFiles("others", "TestBadMethodAccessModifiers", "TestCls"))
.code()
.doesNotContain("protected void test() {")
.containsOne("public void test() {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInit3.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInit3.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestFieldInit3 extends IntegrationTest {
public static class TestCls {
public abstract static class A {
public int field = 4;
}
public static final class B extends A {
public B() {
// IPUT for A.field
super.field = 7;
}
}
public static final class C extends A {
public int other = 11;
public C() {
// IPUT for C.field not A.field !!!
this.field = 9;
}
}
public static final class D extends A {
}
public void check() {
assertThat(new B().field).isEqualTo(7);
assertThat(new C().field).isEqualTo(9);
assertThat(new C().other).isEqualTo(11);
assertThat(new D().field).isEqualTo(4);
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("public int field = 4;")
.containsOne("field = 7;")
.containsOne("field = 9;")
.containsOne("public int other = 11;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestOverridePrivateMethod.java | jadx-core/src/test/java/jadx/tests/integration/others/TestOverridePrivateMethod.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestOverridePrivateMethod extends IntegrationTest {
public static class TestCls {
public static class BaseClass {
private int a() {
return 1;
}
}
public static class MyClass extends BaseClass {
public int a() {
return 2;
}
}
public void check() {
assertThat(new MyClass().a()).isEqualTo(2);
assertThat(new BaseClass().a()).isEqualTo(1);
// TODO: assertThat(((BaseClass) new MyClass()).a()).isEqualTo(1);
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("@Override");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestSuperLoop.java | jadx-core/src/test/java/jadx/tests/integration/others/TestSuperLoop.java | package jadx.tests.integration.others;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
@SuppressWarnings("CommentedOutCode")
public class TestSuperLoop extends SmaliTest {
// @formatter:off
/*
public class A extends B {
public int a;
}
public class B extends A {
public int b;
}
*/
// @formatter:on
@Test
public void test() {
allowWarnInCode();
disableCompilation();
List<ClassNode> clsList = loadFromSmaliFiles();
assertThat(searchCls(clsList, "A"))
.code()
.containsOne("public class A extends B {");
assertThat(searchCls(clsList, "B"))
.code()
.containsOne("public class B extends A {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestInterfaceDefaultMethod.java | jadx-core/src/test/java/jadx/tests/integration/others/TestInterfaceDefaultMethod.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestInterfaceDefaultMethod extends IntegrationTest {
public static class TestCls {
@SuppressWarnings("UnnecessaryInterfaceModifier")
public interface ITest {
void test1();
default void test2() {
}
static void test3() {
}
abstract void test4();
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("static default")
.doesNotContain("abstract")
.containsOne("void test1();")
.containsOne("default void test2() {")
.containsOne("static void test3() {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestJavaDup2x2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestJavaDup2x2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.RaungTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestJavaDup2x2 extends RaungTest {
@Test
public void test() {
assertThat(getClassNodeFromRaung())
.code()
.containsOne("dArr[0] = 127.5d;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInit2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInit2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestFieldInit2 extends IntegrationTest {
public static class TestCls {
public interface BasicAbstract {
void doSomething();
}
public BasicAbstract x = new BasicAbstract() {
@Override
public void doSomething() {
y = 1;
}
};
public int y = 0;
public TestCls() {
}
public TestCls(int z) {
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("x = new BasicAbstract() {")
.containsOne("y = 0;")
.containsLines(1, "public TestFieldInit2$TestCls(int z) {", "}");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFieldAccessReorder.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldAccessReorder.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestFieldAccessReorder extends IntegrationTest {
public static class TestCls {
private long field = 10;
public final boolean test() {
long value = longCall();
long diff = value - this.field;
this.field = value;
return diff > 250;
}
public static long longCall() {
return 261L;
}
public void check() {
assertThat(test()).isTrue();
}
}
@Test
public void test() {
noDebugInfo();
getClassNode(TestCls.class);
// auto check should pass
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitInTryCatch.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitInTryCatch.java | package jadx.tests.integration.others;
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestFieldInitInTryCatch extends IntegrationTest {
public static class TestCls {
public static final URL A;
static {
try {
A = new URL("http://www.example.com/");
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}
public static class TestCls2 {
public static final URL[] A;
static {
try {
A = new URL[] { new URL("http://www.example.com/") };
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}
public static class TestCls3 {
public static final String[] A;
static {
try {
A = new String[] { "a" };
// Note: follow code will not be extracted:
// a = new String[]{new String("a")};
new URL("http://www.example.com/");
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("public static final URL A;")
.containsOne("A = new URL(\"http://www.example.com/\");")
.containsLines(2,
"try {",
indent(1) + "A = new URL(\"http://www.example.com/\");",
"} catch (MalformedURLException e) {");
}
@Test
public void test2() {
assertThat(getClassNode(TestCls2.class))
.code()
.containsLines(2,
"try {",
indent(1) + "A = new URL[]{new URL(\"http://www.example.com/\")};",
"} catch (MalformedURLException e) {");
}
@Test
public void test3() {
assertThat(getClassNode(TestCls3.class))
.code()
// don't move code from try/catch
.containsOne("public static final String[] A;")
.containsOne("A = new String[]{\"a\"};");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestInsnsBeforeSuper.java | jadx-core/src/test/java/jadx/tests/integration/others/TestInsnsBeforeSuper.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestInsnsBeforeSuper extends SmaliTest {
// @formatter:off
/*
public class A {
public A(String s) {
}
}
public class B extends A {
public B(String str) {
checkNull(str);
super(str);
}
public void checkNull(Object o) {
if (o == null) {
throw new NullPointerException();
}
}
}
*/
// @formatter:on
@Test
public void test() {
allowWarnInCode();
assertThat(getClassNodeFromSmaliFiles("B"))
.code()
.containsOne("checkNull(str);");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestShadowingSuperMember.java | jadx-core/src/test/java/jadx/tests/integration/others/TestShadowingSuperMember.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestShadowingSuperMember extends IntegrationTest {
public static class TestCls {
public static class C {
public C(String s) {
}
}
public static class A {
public int a00;
public A(String s) {
}
}
public static class B extends A {
public C a00;
public B(String str) {
super(str);
}
public int add(int b) {
return super.a00 + b;
}
public int sub(int b) {
return ((A) this).a00 - b;
}
}
public void check() {
B b = new B("");
((A) b).a00 = 2;
assertThat(b.add(3)).isEqualTo(5);
assertThat(b.sub(3)).isEqualTo(-1);
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("return super.a00 + b;")
.containsOne("return super.a00 - b;")
.containsOne("((A) b).a00 = 2;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestIncorrectFieldSignature.java | jadx-core/src/test/java/jadx/tests/integration/others/TestIncorrectFieldSignature.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestIncorrectFieldSignature extends SmaliTest {
@Test
public void test() {
assertThat(getClassNodeFromSmali())
.code()
.containsOne("public static boolean A;")
.containsOne("public static Boolean B;")
.countString(2, "/* JADX INFO: Incorrect field signature:");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestJavaDupInsn.java | jadx-core/src/test/java/jadx/tests/integration/others/TestJavaDupInsn.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.core.dex.instructions.args.RegisterArg;
import jadx.core.dex.instructions.args.SSAVar;
import jadx.core.dex.nodes.BlockNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestJavaDupInsn extends IntegrationTest {
public static class TestCls {
private MethodNode mth;
private BlockNode block;
private SSAVar[] vars;
private int[] versions;
public SSAVar test(RegisterArg regArg) {
int regNum = regArg.getRegNum();
int version = versions[regNum]++;
SSAVar ssaVar = mth.makeNewSVar(regNum, version, regArg);
vars[regNum] = ssaVar;
return ssaVar;
}
}
@Test
public void test() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code();
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestClassReGen.java | jadx-core/src/test/java/jadx/tests/integration/others/TestClassReGen.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestClassReGen extends IntegrationTest {
public static class TestCls {
private int intField = 5;
public static class A {
}
public int test() {
return 0;
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
assertThat(cls)
.code()
.containsOnlyOnce("private int intField = 5;")
.containsOnlyOnce("public static class A {")
.containsOnlyOnce("public int test() {");
cls.getInnerClasses().get(0).getClassInfo().changeShortName("ARenamed");
cls.searchMethodByShortName("test").getMethodInfo().setAlias("testRenamed");
cls.searchFieldByName("intField").getFieldInfo().setAlias("intFieldRenamed");
assertThat(cls)
.reloadCode(this)
.containsOnlyOnce("private int intFieldRenamed = 5;")
.containsOnlyOnce("public static class ARenamed {")
.containsOnlyOnce("public int testRenamed() {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestInlineVarArg.java | jadx-core/src/test/java/jadx/tests/integration/others/TestInlineVarArg.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestInlineVarArg extends SmaliTest {
@Test
public void test() {
noDebugInfo();
assertThat(getClassNodeFromSmali())
.code()
.containsOne("f(\"a\", \"b\", \"c\");");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestInvalidExceptions2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestInvalidExceptions2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
class TestInvalidExceptions2 extends SmaliTest {
@Test
void test() {
allowWarnInCode();
disableCompilation();
assertThat(getClassNodeFromSmali())
.code()
.containsOne("throwPossibleExceptionType() throws UnknownTypeHierarchyException {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestDeadBlockReferencesStart.java | jadx-core/src/test/java/jadx/tests/integration/others/TestDeadBlockReferencesStart.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestDeadBlockReferencesStart extends SmaliTest {
@Test
public void test() {
assertThat(getClassNodeFromSmali())
.code()
.countString(0, "throw");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestPrimitiveCasts.java | jadx-core/src/test/java/jadx/tests/integration/others/TestPrimitiveCasts.java | package jadx.tests.integration.others;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.extensions.profiles.TestProfile;
import jadx.tests.api.extensions.profiles.TestWithProfiles;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestPrimitiveCasts extends IntegrationTest {
public static class TestCls {
public void test() {
useShort((short) 0);
useShort((short) getInt());
useByte((byte) 0);
useByte((byte) getInt());
useChar((char) 0);
useChar((char) getInt());
useShort((short) 0L);
useShort((short) getLong());
useByte((byte) 0L);
useByte((byte) getLong());
useChar((char) 0L);
useChar((char) getLong());
useShort((short) ' ');
useShort((short) getChar());
useByte((byte) ' ');
useByte((byte) getChar());
useInt((byte) 7);
useInt((char) ' ');
useInt(getChar());
useInt((int) 2L);
useInt((int) getLong());
}
private long getLong() {
return 1L;
}
private char getChar() {
return ' ';
}
private int getInt() {
return 1;
}
private void useChar(char c) {
}
private void useByte(byte b) {
}
private void useShort(short s) {
}
private void useInt(int i) {
}
}
@TestWithProfiles({ TestProfile.DX_J8, TestProfile.JAVA8 })
public void test() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("(0)")
.doesNotContain(") ((int) getLong())");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestConstStringConcat.java | jadx-core/src/test/java/jadx/tests/integration/others/TestConstStringConcat.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestConstStringConcat extends IntegrationTest {
@SuppressWarnings("StringBufferReplaceableByString")
public static class TestCls {
public String test1(int value) {
return new StringBuilder().append("Value").append(" equals ").append(value).toString();
}
public String test2() {
return new StringBuilder().append("App ").append("version: ").append(1).append('.').append(2).toString();
}
public String test3(String name, int value) {
return "value " + name + " = " + value;
}
public void check() {
assertThat(test1(7)).isEqualTo("Value equals 7");
assertThat(test2()).isEqualTo("App version: 1.2");
assertThat(test3("v", 4)).isEqualTo("value v = 4");
}
}
@Test
public void test() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("return \"Value equals \" + ")
.containsOne("return \"App version: 1.2\";")
.containsOne("return \"value \" + str + \" = \" + i;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing5.java | jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing5.java | package jadx.tests.integration.others;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.extensions.profiles.TestProfile;
import jadx.tests.api.extensions.profiles.TestWithProfiles;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestDeboxing5 extends IntegrationTest {
@SuppressWarnings("WrapperTypeMayBePrimitive")
public static class TestCls {
private static String type;
public static void test(String[] args) {
Float f = (float) -47.99;
Boolean b = args.length == 0;
Object o = ((b) ? false : f);
call(o);
}
public static void call(Object o) {
if (o instanceof Boolean) {
type = "Boolean";
}
if (o instanceof Float) {
type = "Float";
}
}
private static void verify(String[] arr, String str) {
type = null;
test(arr);
assertThat(type).isEqualTo(str);
}
public void check() {
verify(new String[0], "Boolean");
verify(new String[] { "1" }, "Float");
}
}
@TestWithProfiles(TestProfile.D8_J11)
public void test() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("boolean valueOf");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestOverrideWithSameName.java | jadx-core/src/test/java/jadx/tests/integration/others/TestOverrideWithSameName.java | package jadx.tests.integration.others;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.core.dex.attributes.AType;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
@SuppressWarnings("CommentedOutCode")
public class TestOverrideWithSameName extends SmaliTest {
//@formatter:off
/*
interface A {
B a();
C a();
}
abstract class B implements A {
@Override
public C a() {
return null;
}
}
public class C extends B {
@Override
public B a() {
return null;
}
}
*/
//@formatter:on
@Test
public void test() {
List<ClassNode> clsNodes = loadFromSmaliFiles();
assertThat(searchCls(clsNodes, "test.A"))
.code()
.containsOne("C mo0a();") // assume second method was renamed
.doesNotContain("@Override");
ClassNode bCls = searchCls(clsNodes, "test.B");
assertThat(bCls)
.code()
.containsOne("C mo0a() {")
.containsOne("@Override");
assertThat(getMethod(bCls, "a").get(AType.METHOD_OVERRIDE).getOverrideList())
.singleElement()
.satisfies(mth -> assertThat(mth.getMethodInfo().getDeclClass().getShortName()).isEqualTo("A"));
ClassNode cCls = searchCls(clsNodes, "test.C");
assertThat(cCls)
.code()
.containsOne("B a() {")
.containsOne("@Override");
assertThat(getMethod(cCls, "a").get(AType.METHOD_OVERRIDE).getOverrideList())
.singleElement()
.satisfies(mth -> assertThat(mth.getMethodInfo().getDeclClass().getShortName()).isEqualTo("A"));
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestCodeMetadata3.java | jadx-core/src/test/java/jadx/tests/integration/others/TestCodeMetadata3.java | package jadx.tests.integration.others;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.api.ICodeInfo;
import jadx.api.JavaClass;
import jadx.api.JavaVariable;
import jadx.api.metadata.annotations.VarNode;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
/**
* Test variables refs in code metadata
*/
public class TestCodeMetadata3 extends IntegrationTest {
public static class TestCls {
public String test(String str) {
int k = str.length();
k++;
return str + ':' + k;
}
}
@Test
public void test() {
disableCompilation();
ClassNode cls = getClassNode(TestCls.class);
ICodeInfo codeInfo = cls.getCode();
System.out.println(codeInfo.getCodeMetadata());
MethodNode testMth = getMethod(cls, "test");
JavaClass javaClass = toJavaClass(cls);
List<VarNode> varNodes = testMth.collectArgNodes();
assertThat(varNodes).hasSize(1);
VarNode strVar = varNodes.get(0);
JavaVariable strJavaVar = toJavaVariable(strVar);
assertThat(strJavaVar.getName()).isEqualTo("str");
List<Integer> strUsePlaces = javaClass.getUsePlacesFor(codeInfo, strJavaVar);
assertThat(strUsePlaces).hasSize(2);
assertThat(codeInfo).code().countString(3, "str");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestConstructor.java | jadx-core/src/test/java/jadx/tests/integration/others/TestConstructor.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestConstructor extends SmaliTest {
// @formatter:off
/*
private SomeObject test(double r23, double r25, SomeObject r27) {
SomeObject r17 = new SomeObject
r0 = r17
r1 = r27
r0.<init>(r1)
return r17
}
*/
// @formatter:on
@Test
public void test() {
disableCompilation();
assertThat(getClassNodeFromSmali())
.code()
.containsOne("new SomeObject(arg3);")
.doesNotContain("= someObject");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestConstReplace.java | jadx-core/src/test/java/jadx/tests/integration/others/TestConstReplace.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.FieldNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestConstReplace extends IntegrationTest {
public static class TestCls {
public static final String CONST_VALUE = "string";
public String test() {
return CONST_VALUE;
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
MethodNode testMth = cls.searchMethodByShortName("test");
assertThat(testMth)
.code()
.print()
.containsOne("return CONST_VALUE;");
FieldNode constField = cls.searchFieldByName("CONST_VALUE");
assertThat(constField).isNotNull();
assertThat(constField.getUseIn()).containsExactly(testMth);
}
@Test
public void testWithoutReplace() {
getArgs().setReplaceConsts(false);
ClassNode cls = getClassNode(TestCls.class);
assertThat(cls).code().containsOne("return \"string\";");
FieldNode constField = cls.searchFieldByName("CONST_VALUE");
assertThat(constField).isNotNull();
assertThat(constField.getUseIn()).isEmpty();
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestNullInline.java | jadx-core/src/test/java/jadx/tests/integration/others/TestNullInline.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestNullInline extends IntegrationTest {
@SuppressWarnings({ "RedundantCast", "DataFlowIssue", "unused" })
public static class TestCls {
public static Long test(Double d1) {
T1<T2, Byte> t1 = (T1<T2, Byte>) null;
return t1.t2.l;
}
static class T2 {
public long l;
}
static class T1<H, P extends Byte> {
public T2 t2;
public T1(T2 t2) {
this.t2 = t2;
}
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("Long.valueOf(t1.t2.l);");
}
@Test
public void testNoDebug() {
noDebugInfo();
getClassNode(TestCls.class);
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestDefConstructorNotRemoved.java | jadx-core/src/test/java/jadx/tests/integration/others/TestDefConstructorNotRemoved.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestDefConstructorNotRemoved extends IntegrationTest {
public static class TestCls {
static {
// empty
}
public static class A {
public final String s;
public A() {
s = "a";
}
public A(String str) {
s = str;
}
}
public static class B extends A {
public B() {
super();
}
public B(String s) {
super(s);
}
}
public void check() {
new A();
new A("a");
new B();
new B("b");
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("super();")
.doesNotContain("static {")
.containsOne("public B() {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestInvalidExceptions.java | jadx-core/src/test/java/jadx/tests/integration/others/TestInvalidExceptions.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
class TestInvalidExceptions extends SmaliTest {
@Test
void test() {
allowWarnInCode();
assertThat(getClassNodeFromSmali())
.code()
.containsOne("invalidException() throws FileNotFoundException {")
.containsOne("Byte code manipulation detected: skipped illegal throws declaration")
.removeBlockComments()
.doesNotContain("String");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestMethodParametersAttribute.java | jadx-core/src/test/java/jadx/tests/integration/others/TestMethodParametersAttribute.java | package jadx.tests.integration.others;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Arrays;
import java.util.stream.Collectors;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.extensions.profiles.TestProfile;
import jadx.tests.api.extensions.profiles.TestWithProfiles;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestMethodParametersAttribute extends IntegrationTest {
public static class TestCls {
public String test(String paramStr, final int number) {
return paramStr + number;
}
public String paramNames() throws NoSuchMethodException {
Method testMethod = TestCls.class.getMethod("test", String.class, int.class);
return Arrays.stream(testMethod.getParameters())
.map(Parameter::getName)
.collect(Collectors.joining(", "));
}
public void check() throws NoSuchMethodException {
assertThat(paramNames()).isEqualTo("paramStr, number");
}
}
@TestWithProfiles({ TestProfile.JAVA8, TestProfile.D8_J11 })
public void test() {
getCompilerOptions().addArgument("-parameters");
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("public String test(String paramStr, final int number) {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestRedundantBrackets.java | jadx-core/src/test/java/jadx/tests/integration/others/TestRedundantBrackets.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestRedundantBrackets extends IntegrationTest {
public static class TestCls {
public boolean method(String str) {
return str.indexOf('a') != -1;
}
public int method2(Object obj) {
if (obj instanceof String) {
return ((String) obj).length();
}
return 0;
}
public int method3(int a, int b) {
if (a + b < 10) {
return a;
}
if ((a & b) != 0) {
return a * b;
}
return b;
}
public void method4(int num) {
if (num == 4 || num == 6 || num == 8 || num == 10) {
method2(null);
}
}
public void method5(int[] a, int n) {
a[1] = n * 2;
a[n - 1] = 1;
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("(-1)")
.doesNotContain("return;")
.contains("if (obj instanceof String) {")
.contains("return ((String) obj).length();")
.contains("a + b < 10")
.contains("(a & b) != 0")
.contains("if (num == 4 || num == 6 || num == 8 || num == 10)")
.contains("a[1] = n * 2;")
.contains("a[n - 1] = 1;")
.contains("public int method2(Object obj) {")
// argument type isn't changed to String
// cast not eliminated
.contains("((String) obj).length()");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestIfInTry.java | jadx-core/src/test/java/jadx/tests/integration/others/TestIfInTry.java | package jadx.tests.integration.others;
import java.io.File;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestIfInTry extends IntegrationTest {
public static class TestCls {
public File dir;
public int test() {
try {
int a = f();
if (a != 0) {
return a;
}
} catch (Exception e) {
// skip
}
try {
f();
return 1;
} catch (IOException e) {
return -1;
}
}
private int f() throws IOException {
return 0;
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("if (a != 0) {")
.containsOne("} catch (Exception e) {")
.countString(2, "try {")
.countString(3, "f()")
.containsOne("return 1;")
.containsOne("} catch (IOException e")
.containsOne("return -1;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestOverrideStaticMethod.java | jadx-core/src/test/java/jadx/tests/integration/others/TestOverrideStaticMethod.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestOverrideStaticMethod extends IntegrationTest {
public static class TestCls {
public static class BaseClass {
public static int a() {
return 1;
}
}
public static class MyClass extends BaseClass {
public static int a() {
return 2;
}
}
public void check() {
assertThat(BaseClass.a()).isEqualTo(1);
assertThat(MyClass.a()).isEqualTo(2);
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("@Override");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestAllNops.java | jadx-core/src/test/java/jadx/tests/integration/others/TestAllNops.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestAllNops extends SmaliTest {
@Test
public void test() {
disableCompilation();
assertThat(getClassNodeFromSmali())
.code()
.containsLines(1, "private boolean test() {", "}")
.containsLines(1, "private boolean testWithTryCatch() {", "}");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestJsonOutput.java | jadx-core/src/test/java/jadx/tests/integration/others/TestJsonOutput.java | package jadx.tests.integration.others;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
import static jadx.api.JadxArgs.OutputFormatEnum.JSON;
public class TestJsonOutput extends IntegrationTest {
public static class TestCls {
private final String prefix = "list: ";
static {
System.out.println("test");
}
public void test(boolean b, List<String> list) {
if (b) {
System.out.println(prefix + list);
}
}
public static class Inner implements Runnable {
@Override
public void run() {
System.out.println("run");
}
}
}
@Test
public void test() {
disableCompilation();
args.setOutputFormat(JSON);
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.contains("\"offset\": \"0x")
.containsOne("public static class Inner implements Runnable");
}
@Test
public void testFallback() {
disableCompilation();
setFallback();
args.setOutputFormat(JSON);
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.contains("\"offset\": \"0x")
.containsOne("public static class Inner implements java.lang.Runnable");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestWrongCode.java | jadx-core/src/test/java/jadx/tests/integration/others/TestWrongCode.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestWrongCode extends IntegrationTest {
public static class TestCls {
@SuppressWarnings("null")
public int test() {
int[] a = null;
return a.length;
}
public int test2(int a) {
if (a == 0) {
}
return a;
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("return false.length;")
.containsOne("int[] a = null;")
.containsOne("return a.length;")
.containsLines(2,
"if (a == 0) {",
"}",
"return a;");
}
@Test
public void testNoDebug() {
noDebugInfo();
getClassNode(TestCls.class);
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestMultipleNOPs.java | jadx-core/src/test/java/jadx/tests/integration/others/TestMultipleNOPs.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
public class TestMultipleNOPs extends SmaliTest {
@Test
public void test() {
disableCompilation();
// expected no errors
loadFromSmaliFiles();
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStaticFieldsInit.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStaticFieldsInit.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestStaticFieldsInit extends IntegrationTest {
public static class TestCls {
public static final String S1 = "1";
public static final String S2 = "12".substring(1);
public static final String S3 = null;
public static final String S4;
public static final String S5 = "5";
public static String s6 = "6";
static {
if (S5.equals("?")) {
S4 = "?";
} else {
S4 = "4";
}
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("public static final String S2 = null;")
.contains("public static final String S3 = null;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestRedundantReturn.java | jadx-core/src/test/java/jadx/tests/integration/others/TestRedundantReturn.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
public class TestRedundantReturn extends IntegrationTest {
public static class TestCls {
public void test(int num) {
if (num == 4) {
fail("");
}
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("return;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestJavaJSR.java | jadx-core/src/test/java/jadx/tests/integration/others/TestJavaJSR.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.RaungTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestJavaJSR extends RaungTest {
@Test
public void test() {
assertThat(getClassNodeFromRaung())
.code()
.containsLines(2,
"InputStream in = url.openStream();",
"try {",
indent() + "return call(in);",
"} finally {",
indent() + "in.close();",
"}");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestDuplicateCast.java | jadx-core/src/test/java/jadx/tests/integration/others/TestDuplicateCast.java | package jadx.tests.integration.others;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.core.dex.instructions.args.InsnWrapArg;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.InsnNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.tests.api.IntegrationTest;
import static jadx.core.dex.instructions.InsnType.CHECK_CAST;
import static jadx.core.dex.instructions.InsnType.RETURN;
import static jadx.core.utils.BlockUtils.collectAllInsns;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
/**
* Test duplicate 'check-cast' instruction produced because of bug in javac:
* http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6246854
*/
public class TestDuplicateCast extends IntegrationTest {
public static class TestCls {
public int[] method(Object o) {
return (int[]) o;
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
MethodNode mth = getMethod(cls, "method");
assertThat(cls)
.code()
.contains("return (int[]) o;");
List<InsnNode> insns = collectAllInsns(mth.getBasicBlocks());
assertThat(insns).hasSize(1);
InsnNode insnNode = insns.get(0);
assertThat(insnNode.getType()).isEqualTo(RETURN);
assertThat(insnNode.getArg(0).isInsnWrap()).isTrue();
InsnNode wrapInsn = ((InsnWrapArg) insnNode.getArg(0)).getWrapInsn();
assertThat(wrapInsn.getType()).isEqualTo(CHECK_CAST);
assertThat(wrapInsn.getArg(0).isInsnWrap()).isFalse();
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestIssue13b.java | jadx-core/src/test/java/jadx/tests/integration/others/TestIssue13b.java | package jadx.tests.integration.others;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestIssue13b extends IntegrationTest {
public static class TestCls {
private static final String PROPERTIES_FILE = "";
private static final String TAG = "";
private final CountDownLatch mInitializedLatch = new CountDownLatch(1);
public int mC2KServerPort = 0;
private String mSuplServerHost = "";
public int mSuplServerPort = 0;
private String mC2KServerHost = "";
public TestCls() {
Properties mProperties = new Properties();
try {
File file = new File(PROPERTIES_FILE);
FileInputStream stream = new FileInputStream(file);
mProperties.load(stream);
stream.close();
mSuplServerHost = mProperties.getProperty("SUPL_HOST");
String portString = mProperties.getProperty("SUPL_PORT");
if (mSuplServerHost != null && portString != null) {
try {
mSuplServerPort = Integer.parseInt(portString);
} catch (NumberFormatException e) {
Log.e(TAG, "unable to parse SUPL_PORT: " + portString);
}
}
mC2KServerHost = mProperties.getProperty("C2K_HOST");
portString = mProperties.getProperty("C2K_PORT");
if (mC2KServerHost != null && portString != null) {
try {
mC2KServerPort = Integer.parseInt(portString);
} catch (NumberFormatException e) {
Log.e(TAG, "unable to parse C2K_PORT: " + portString);
}
}
} catch (IOException e) {
Log.e(TAG, "Could not open GPS configuration file " + PROPERTIES_FILE);
}
Thread mThread = new Thread();
mThread.start();
while (true) {
try {
mInitializedLatch.await();
break;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
private static class Log {
public static void e(String tag, String s) {
}
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.countString(4, "} catch (")
.countString(3, "Log.e(")
.containsOne("Thread.currentThread().interrupt();");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestOverrideWithTwoBases2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestOverrideWithTwoBases2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestOverrideWithTwoBases2 extends IntegrationTest {
public static class TestCls {
public interface I {
int a();
}
public abstract static class BaseCls implements I {
}
public static class Cls extends BaseCls implements I {
@Override
public int a() {
return 2;
}
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("@Override");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestClassImplementsSignature.java | jadx-core/src/test/java/jadx/tests/integration/others/TestClassImplementsSignature.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.RaungTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestClassImplementsSignature extends RaungTest {
public static class TestCls {
public abstract static class A<T> implements Comparable<A<T>> {
T value;
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("public static abstract class A<T> implements Comparable<A<T>> {");
}
@Test
public void testRaung() {
allowWarnInCode();
assertThat(getClassNodeFromRaung())
.code()
.containsOne("public class TestClassImplementsSignature<T> {")
.containsOne("Unexpected interfaces in signature");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestReturnWrapping.java | jadx-core/src/test/java/jadx/tests/integration/others/TestReturnWrapping.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestReturnWrapping extends IntegrationTest {
public static class TestCls {
public static int f1(int arg0) {
switch (arg0) {
case 1:
return 255;
}
return arg0 + 1;
}
public static Object f2(Object arg0, int arg1) {
Object ret = null;
int i = arg1;
if (arg0 == null) {
return ret + Integer.toHexString(i);
}
i++;
try {
ret = new Object().getClass();
} catch (Exception e) {
ret = "Qwerty";
}
return i > 128 ? arg0.toString() + ret.toString() : i;
}
public static int f3(int arg0) {
while (arg0 > 10) {
int abc = 951;
if (arg0 == 255) {
return arg0 + 2;
}
arg0 -= abc;
}
return arg0;
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.contains("return 255;")
.contains("return arg0 + 1;").contains("return i > 128 ? arg0.toString() + ret.toString() : Integer.valueOf(i);")
.contains("return arg0 + 2;")
.contains("arg0 -= 951;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestJavaSwap.java | jadx-core/src/test/java/jadx/tests/integration/others/TestJavaSwap.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.RaungTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestJavaSwap extends RaungTest {
@SuppressWarnings("StringBufferReplaceableByString")
public static class TestCls {
private Iterable<String> field;
@Override
public String toString() {
String string = String.valueOf(this.field);
return new StringBuilder(8 + String.valueOf(string).length())
.append("concat(").append(string).append(")")
.toString();
}
}
@Test
public void testJava() {
useJavaInput();
assertThat(getClassNode(TestCls.class))
.code();
}
@Test
public void test() {
useJavaInput();
assertThat(getClassNodeFromRaung())
.code();
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestDefConstructorWithAnnotation.java | jadx-core/src/test/java/jadx/tests/integration/others/TestDefConstructorWithAnnotation.java | package jadx.tests.integration.others;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestDefConstructorWithAnnotation extends IntegrationTest {
public static class TestCls {
@AnnotationTest
public TestCls() {
}
@Target(ElementType.CONSTRUCTOR)
@Retention(RetentionPolicy.RUNTIME)
public @interface AnnotationTest {
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("@AnnotationTest");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination5.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination5.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestStringBuilderElimination5 extends IntegrationTest {
public static class TestCls {
@SuppressWarnings("StringConcatenationInLoop")
public static String test(long[] a) {
String s = "";
final char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
for (int i = a.length - 1; i >= 0; i--) {
s += hexChars[(int) (a[i] >>> 60) & 0x0f];
s += hexChars[(int) (a[i] >>> 56) & 0x0f];
s += hexChars[(int) (a[i] >>> 52) & 0x0f];
s += hexChars[(int) (a[i] >>> 48) & 0x0f];
s += hexChars[(int) (a[i] >>> 44) & 0x0f];
s += hexChars[(int) (a[i] >>> 40) & 0x0f];
s += hexChars[(int) (a[i] >>> 36) & 0x0f];
s += hexChars[(int) (a[i] >>> 32) & 0x0f];
s += hexChars[(int) (a[i] >>> 28) & 0x0f];
s += hexChars[(int) (a[i] >>> 24) & 0x0f];
s += hexChars[(int) (a[i] >>> 20) & 0x0f];
s += hexChars[(int) (a[i] >>> 16) & 0x0f];
s += hexChars[(int) (a[i] >>> 12) & 0x0f];
s += hexChars[(int) (a[i] >>> 8) & 0x0f];
s += hexChars[(int) (a[i] >>> 4) & 0x0f];
s += hexChars[(int) (a[i]) & 0x0f];
s += " ";
}
return s;
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain(".append(");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestCodeMetadata.java | jadx-core/src/test/java/jadx/tests/integration/others/TestCodeMetadata.java | package jadx.tests.integration.others;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.Test;
import jadx.api.JadxInternalAccess;
import jadx.api.JavaClass;
import jadx.api.JavaMethod;
import jadx.api.metadata.ICodeAnnotation;
import jadx.api.metadata.ICodeAnnotation.AnnType;
import jadx.api.metadata.ICodeMetadata;
import jadx.api.metadata.ICodeNodeRef;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.FieldNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestCodeMetadata extends IntegrationTest {
public static class TestCls {
public static class A {
public String str;
}
public String test() {
A a = new A();
a.str = call();
return a.str;
}
public static String call() {
return "str";
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
assertThat(cls).code().containsOne("return a.str;");
MethodNode testMth = getMethod(cls, "test");
MethodNode callMth = getMethod(cls, "call");
int callDefPos = callMth.getDefPosition();
assertThat(callDefPos).isNotZero();
JavaClass javaClass = JadxInternalAccess.convertClassNode(jadxDecompiler, cls);
JavaMethod callJavaMethod = JadxInternalAccess.convertMethodNode(jadxDecompiler, callMth);
List<Integer> callUsePlaces = javaClass.getUsePlacesFor(javaClass.getCodeInfo(), callJavaMethod);
assertThat(callUsePlaces).hasSize(1);
int callUse = callUsePlaces.get(0);
ICodeMetadata metadata = cls.getCode().getCodeMetadata();
System.out.println(metadata);
ICodeNodeRef callDef = metadata.getNodeAt(callUse);
assertThat(callDef).isSameAs(testMth);
AtomicInteger endPos = new AtomicInteger();
ICodeAnnotation testEnd = metadata.searchUp(callDefPos, (pos, ann) -> {
if (ann.getAnnType() == AnnType.END) {
endPos.set(pos);
return ann;
}
return null;
});
assertThat(testEnd).isNotNull();
int testEndPos = endPos.get();
ICodeAnnotation closest = metadata.getClosestUp(testEndPos);
assertThat(closest).isInstanceOf(FieldNode.class); // field reference from 'return a.str;'
ICodeNodeRef nodeBelow = metadata.getNodeBelow(testEndPos);
assertThat(nodeBelow).isSameAs(callMth);
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.core.dex.visitors.SimplifyVisitor;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
/**
* Test the StringBuilder simplification part of {@link SimplifyVisitor}
*
* @author Jan Peter Stotz
*/
@SuppressWarnings("StringBufferReplaceableByString")
public class TestStringBuilderElimination2 extends IntegrationTest {
public static class TestCls1 {
public String test() {
return new StringBuilder("[init]").append("a1").append('c').append(2).append(0L).append(1.0f).append(2.0d).append(true)
.toString();
}
}
@Test
public void test1() {
JadxAssertions.assertThat(getClassNode(TestCls1.class))
.code()
.contains("return \"[init]a1c201.02.0true\";");
}
public static class TestCls2 {
public String test() {
// A chain with non-final variables
String sInit = "[init]";
String s = "a1";
char c = 'c';
int i = 1;
long l = 2;
float f = 1.0f;
double d = 2.0d;
boolean b = true;
return new StringBuilder(sInit).append(s).append(c).append(i).append(l).append(f).append(d).append(b).toString();
}
}
@Test
public void test2() {
JadxAssertions.assertThat(getClassNode(TestCls2.class))
.code()
.contains("return \"[init]a1c121.02.0true\";");
}
public static class TestClsStringUtilsReverse {
/**
* Simplified version of org.apache.commons.lang3.StringUtils.reverse()
*/
public static String reverse(final String str) {
return new StringBuilder(str).reverse().toString();
}
}
@Test
public void test3() {
JadxAssertions.assertThat(getClassNode(TestClsStringUtilsReverse.class))
.code()
.contains("return new StringBuilder(str).reverse().toString();");
}
public static class TestClsChainWithDelete {
public String test() {
// a chain we can't simplify
return new StringBuilder("[init]").append("a1").delete(1, 2).toString();
}
}
@Test
public void testChainWithDelete() {
JadxAssertions.assertThat(getClassNode(TestClsChainWithDelete.class))
.code()
.contains("return new StringBuilder(\"[init]\").append(\"a1\").delete(1, 2).toString();");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestCastOfNull.java | jadx-core/src/test/java/jadx/tests/integration/others/TestCastOfNull.java | package jadx.tests.integration.others;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
@SuppressWarnings("unused")
public class TestCastOfNull extends IntegrationTest {
public static class TestCls {
public void test() {
m((long[]) null);
m((String) null);
m((List<String>) null);
}
public void m(long[] a) {
}
public void m(String s) {
}
public void m(List<String> list) {
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("m((long[]) null);")
.containsOne("m((String) null);")
.containsOne("m((List<String>) null);");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestCodeCommentsOverride.java | jadx-core/src/test/java/jadx/tests/integration/others/TestCodeCommentsOverride.java | package jadx.tests.integration.others;
import java.util.Arrays;
import org.junit.jupiter.api.Test;
import jadx.api.data.ICodeComment;
import jadx.api.data.IJavaNodeRef.RefType;
import jadx.api.data.impl.JadxCodeComment;
import jadx.api.data.impl.JadxCodeData;
import jadx.api.data.impl.JadxNodeRef;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestCodeCommentsOverride extends IntegrationTest {
public static class TestCls {
public interface I {
void mth();
}
public static class A implements I {
@Override
public void mth() {
System.out.println("mth");
}
}
}
@Test
public void test() {
String baseClsId = TestCls.class.getName();
JadxNodeRef iMthRef = new JadxNodeRef(RefType.METHOD, baseClsId + "$I", "mth()V");
ICodeComment iMthComment = new JadxCodeComment(iMthRef, "interface mth comment");
JadxNodeRef mthRef = new JadxNodeRef(RefType.METHOD, baseClsId + "$A", "mth()V");
ICodeComment mthComment = new JadxCodeComment(mthRef, "mth comment");
JadxCodeData codeData = new JadxCodeData();
codeData.setComments(Arrays.asList(iMthComment, mthComment));
getArgs().setCodeData(codeData);
ClassNode cls = getClassNode(TestCls.class);
assertThat(cls)
.decompile()
.checkCodeOffsets()
.code()
.containsOne("@Override")
.containsOne("// " + iMthComment.getComment())
.containsOne("// " + mthComment.getComment());
assertThat(cls)
.reloadCode(this)
.containsOne("@Override")
.containsOne("// " + iMthComment.getComment())
.containsOne("// " + mthComment.getComment());
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestOverrideWithTwoBases.java | jadx-core/src/test/java/jadx/tests/integration/others/TestOverrideWithTwoBases.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestOverrideWithTwoBases extends IntegrationTest {
public static class TestCls {
public abstract static class BaseClass {
public abstract int a();
}
public interface I {
int a();
}
public static class Cls extends BaseClass implements I {
@Override
public int a() {
return 2;
}
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("@Override");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestConstructorBranched3.java | jadx-core/src/test/java/jadx/tests/integration/others/TestConstructorBranched3.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
public class TestConstructorBranched3 extends SmaliTest {
@Test
public void test() {
disableCompilation();
assertThat(getClassNodeFromSmali())
.code()
.countString(2, "return new f(");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestCodeComments.java | jadx-core/src/test/java/jadx/tests/integration/others/TestCodeComments.java | package jadx.tests.integration.others;
import java.util.Arrays;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import jadx.api.data.ICodeComment;
import jadx.api.data.IJavaCodeRef;
import jadx.api.data.IJavaNodeRef.RefType;
import jadx.api.data.impl.JadxCodeComment;
import jadx.api.data.impl.JadxCodeData;
import jadx.api.data.impl.JadxCodeRef;
import jadx.api.data.impl.JadxNodeRef;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestCodeComments extends IntegrationTest {
@SuppressWarnings("FieldCanBeLocal")
public static class TestCls {
private int intField = 5;
public static class A {
}
public int test() {
System.out.println("Hello");
System.out.println("comment");
return intField;
}
}
@Test
public void test() {
String baseClsId = TestCls.class.getName();
ICodeComment clsComment = new JadxCodeComment(JadxNodeRef.forCls(baseClsId), "class comment");
ICodeComment innerClsComment = new JadxCodeComment(JadxNodeRef.forCls(baseClsId + "$A"), "inner class comment");
ICodeComment fldComment = new JadxCodeComment(new JadxNodeRef(RefType.FIELD, baseClsId, "intField:I"), "field comment");
JadxNodeRef mthRef = new JadxNodeRef(RefType.METHOD, baseClsId, "test()I");
ICodeComment mthComment = new JadxCodeComment(mthRef, "method comment");
IJavaCodeRef insnRef = JadxCodeRef.forInsn(isJavaInput() ? 13 : 11);
ICodeComment insnComment = new JadxCodeComment(mthRef, insnRef, "insn comment");
JadxCodeData codeData = new JadxCodeData();
getArgs().setCodeData(codeData);
codeData.setComments(Arrays.asList(clsComment, innerClsComment, fldComment, mthComment, insnComment));
ClassNode cls = getClassNode(TestCls.class);
assertThat(cls)
.decompile()
.checkCodeOffsets()
.code()
.containsOne("// class comment")
.containsOne("// inner class comment")
.containsOne("// field comment")
.containsOne("// method comment")
.containsOne("System.out.println(\"comment\"); // insn comment");
String code = cls.getCode().getCodeStr();
assertThat(cls)
.reloadCode(this)
.isEqualTo(code);
ICodeComment updInsnComment = new JadxCodeComment(mthRef, insnRef, "updated insn comment");
codeData.setComments(Collections.singletonList(updInsnComment));
jadxDecompiler.reloadCodeData();
assertThat(cls)
.reloadCode(this)
.containsOne("System.out.println(\"comment\"); // updated insn comment")
.doesNotContain("class comment")
.containsOne(" comment");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStringConcatJava11.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStringConcatJava11.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.RaungTest;
import jadx.tests.api.extensions.profiles.TestProfile;
import jadx.tests.api.extensions.profiles.TestWithProfiles;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestStringConcatJava11 extends RaungTest {
public static class TestCls {
public String test(final String s) {
return s + "test";
}
//@formatter:off
/* Dynamic call looks like this:
public String test(final String s) {
return java.lang.invoke.StringConcatFactory.makeConcatWithConstants(
java.lang.invoke.MethodHandles.lookup(),
"makeConcatWithConstants",
java.lang.invoke.MethodType.fromMethodDescriptorString("(Ljava/lang/String;)Ljava/lang/String;", this.getClass().getClassLoader()),
"\u0001test"
).dynamicInvoker().invoke(s);
}
*/
//@formatter:on
public String test2(final String s) {
return s + "test" + s + 7;
}
}
@Test
public void test() {
assertThat(getClassNodeFromRaung())
.code()
.containsOne("return str + \"test\";")
.containsOne("return str + \"test\" + str + 7;");
}
@Test
public void testJava8() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("return str + \"test\";")
.containsOneOf(
"return str + \"test\" + str + 7;",
"return str + \"test\" + str + \"7\";"); // dynamic concat add const to string recipe
}
@TestWithProfiles({ TestProfile.D8_J11, TestProfile.JAVA11 })
public void testJava11() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("return str + \"test\";")
.containsOne("return str + \"test\" + str + \"7\";");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitOrder2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitOrder2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestFieldInitOrder2 extends SmaliTest {
@SuppressWarnings({ "SpellCheckingInspection", "StaticVariableName" })
public static class TestCls {
static String ZPREFIX = "SOME_";
private static final String VALUE = ZPREFIX + "VALUE";
public void check() {
assertThat(VALUE).isEqualTo("SOME_VALUE");
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("private static final String VALUE = ZPREFIX + \"VALUE\";");
}
@Test
public void testSmali() {
assertThat(getClassNodeFromSmali())
.runDecompiledAutoCheck(this)
.code()
.containsOne("private static final String VALUE = ZPREFIX + \"VALUE\";");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestWrongCode2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestWrongCode2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestWrongCode2 extends IntegrationTest {
public static class TestCls {
@SuppressWarnings("ConstantConditions")
public String test() {
A a = null;
a.str = "";
return a.str;
}
@SuppressWarnings("ConstantConditions")
public int test2() {
int[] a = null;
a[1] = 2;
return a[0];
}
@SuppressWarnings({ "ConstantConditions", "SynchronizationOnLocalVariableOrMethodParameter" })
public boolean test3() {
A a = null;
synchronized (a) {
return true;
}
}
public boolean test4() {
return null instanceof A;
}
// everything is 'A' :)
@SuppressWarnings({ "MethodName", "LocalVariableName" }) // ignore checkstyle
public A A() {
A A = A();
A.A = A;
return A;
}
@SuppressWarnings("MemberName")
public static class A {
public String str;
public A A;
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("return a.str;");
}
@Test
public void testNoDebug() {
noDebugInfo();
getClassNode(TestCls.class);
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestCodeMetadata2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestCodeMetadata2.java | package jadx.tests.integration.others;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.api.JavaClass;
import jadx.api.JavaMethod;
import jadx.api.metadata.ICodeMetadata;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.tests.api.IntegrationTest;
import static jadx.api.JadxInternalAccess.convertClassNode;
import static jadx.api.JadxInternalAccess.convertMethodNode;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestCodeMetadata2 extends IntegrationTest {
public static class TestCls {
@SuppressWarnings("Convert2Lambda")
public Runnable test(boolean a) {
if (a) {
return new Runnable() {
@Override
public void run() {
System.out.println("test");
}
};
}
System.out.println("another");
return empty();
}
public static Runnable empty() {
return new Runnable() {
@Override
public void run() {
// empty
}
};
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
assertThat(cls).code().containsOne("return empty();");
MethodNode testMth = getMethod(cls, "test");
MethodNode emptyMth = getMethod(cls, "empty");
JavaClass javaClass = convertClassNode(jadxDecompiler, cls);
JavaMethod emptyJavaMethod = convertMethodNode(jadxDecompiler, emptyMth);
List<Integer> emptyUsePlaces = javaClass.getUsePlacesFor(javaClass.getCodeInfo(), emptyJavaMethod);
assertThat(emptyUsePlaces).hasSize(1);
int callUse = emptyUsePlaces.get(0);
ICodeMetadata metadata = cls.getCode().getCodeMetadata();
assertThat(metadata.getNodeAt(callUse)).isSameAs(testMth);
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestDeboxing2 extends IntegrationTest {
public static class TestCls {
public long test(Long l) {
if (l == null) {
l = 0L;
}
return l;
}
public void check() {
assertThat(test(null)).isEqualTo(0L);
assertThat(test(0L)).isEqualTo(0L);
assertThat(test(7L)).isEqualTo(7L);
}
}
@Test
public void test() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("long test(Long l)")
.containsOne("if (l == null) {")
.containsOne("l = 0L;")
.containsOne("test(null)")
.containsOne("test(0L)")
// checks for 'check' method
.countString(2, "isEqualTo(0L)")
.containsOne("test(7L)")
.containsOne("isEqualTo(7L)");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination3.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination3.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestStringBuilderElimination3 extends IntegrationTest {
public static class TestCls {
public static String test(String a) {
StringBuilder sb = new StringBuilder();
sb.append("result = ");
sb.append(a);
return sb.toString();
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.contains("return \"result = \" + a;")
.doesNotContain("new StringBuilder()");
}
public static class TestClsNegative {
private String f = "first";
public String test() {
StringBuilder sb = new StringBuilder();
sb.append("before = ");
sb.append(this.f);
updateF();
sb.append(", after = ");
sb.append(this.f);
return sb.toString();
}
private void updateF() {
this.f = "second";
}
public void check() {
assertThat(test()).isEqualTo("before = first, after = second");
}
}
@Test
public void testNegative() {
JadxAssertions.assertThat(getClassNode(TestClsNegative.class))
.code()
.contains("return sb.toString();")
.contains("new StringBuilder()");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestConstructor2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestConstructor2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
/**
* Constructor called on object instance is from Object not instance type
*/
public class TestConstructor2 extends SmaliTest {
@Test
public void test() {
assertThat(getClassNodeFromSmaliFiles())
.code()
.containsOne("A a = new A();")
.doesNotContain("return");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestN21.java | jadx-core/src/test/java/jadx/tests/integration/others/TestN21.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestN21 extends SmaliTest {
@Test
public void test() {
assertThat(getClassNodeFromSmali())
.code()
.countString(2, "while (");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestCodeComments2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestCodeComments2.java | package jadx.tests.integration.others;
import java.util.Arrays;
import org.junit.jupiter.api.Test;
import jadx.api.data.ICodeComment;
import jadx.api.data.IJavaCodeRef;
import jadx.api.data.IJavaNodeRef.RefType;
import jadx.api.data.impl.JadxCodeComment;
import jadx.api.data.impl.JadxCodeData;
import jadx.api.data.impl.JadxCodeRef;
import jadx.api.data.impl.JadxNodeRef;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestCodeComments2 extends IntegrationTest {
public static class TestCls {
public int test(boolean z) {
if (z) {
System.out.println("z");
return 1;
}
return 3;
}
}
@Test
public void test() {
printOffsets();
String baseClsId = TestCls.class.getName();
JadxNodeRef mthRef = new JadxNodeRef(RefType.METHOD, baseClsId, "test(Z)I");
IJavaCodeRef insnRef = JadxCodeRef.forInsn(isJavaInput() ? 13 : 10);
ICodeComment insnComment = new JadxCodeComment(mthRef, insnRef, "return comment");
IJavaCodeRef insnRef2 = JadxCodeRef.forInsn(isJavaInput() ? 15 : 11);
ICodeComment insnComment2 = new JadxCodeComment(mthRef, insnRef2, "another return comment");
JadxCodeData codeData = new JadxCodeData();
codeData.setComments(Arrays.asList(insnComment, insnComment2));
getArgs().setCodeData(codeData);
assertThat(getClassNode(TestCls.class))
.decompile()
.checkCodeOffsets()
.code()
.containsOne("return 1; // " + insnComment.getComment())
.containsOne("return 3; // " + insnComment2.getComment());
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestThrows.java | jadx-core/src/test/java/jadx/tests/integration/others/TestThrows.java | package jadx.tests.integration.others;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestThrows extends IntegrationTest {
public static class MissingThrowsTest extends Exception {
private void throwCustomException() throws MissingThrowsTest {
throw new MissingThrowsTest();
}
private void throwException() throws Exception {
throw new Exception();
}
private void throwRuntimeException1() {
throw new RuntimeException();
}
private void throwRuntimeException2() {
throw new NullPointerException();
}
private void throwError() {
throw new Error();
}
private void throwError2() {
throw new OutOfMemoryError();
}
@SuppressWarnings("checkstyle:illegalThrows")
private void throwThrowable() throws Throwable {
throw new Throwable();
}
private void exceptionSource() throws FileNotFoundException {
throw new FileNotFoundException("");
}
public void mergeThrownExceptions() throws IOException {
exceptionSource();
}
public void rethrowThrowable() {
try {
} catch (Throwable t) {
throw t;
}
}
public void doSomething1(int i) throws FileNotFoundException {
if (i == 1) {
doSomething2(i);
} else {
doSomething1(i);
}
}
public void doSomething2(int i) throws FileNotFoundException {
if (i == 1) {
exceptionSource();
} else {
doSomething1(i);
}
}
public void noThrownExceptions1(InputStream i1) {
try {
i1.close();
} catch (IOException ignore) {
}
}
public void noThrownExceptions2() {
try {
throw new FileNotFoundException("");
} catch (IOException ignore) {
}
}
}
@Test
public void test() {
assertThat(getClassNode(MissingThrowsTest.class))
.code()
.containsOne("throwCustomException() throws TestThrows$MissingThrowsTest {")
.containsOne("throwException() throws Exception {")
.containsOne("throwRuntimeException1() {")
.containsOne("throwRuntimeException2() {")
.containsOne("throwError() {")
.containsOne("throwError2() {")
.containsOne("throwThrowable() throws Throwable {")
.containsOne("exceptionSource() throws FileNotFoundException {")
.containsOne("mergeThrownExceptions() throws IOException {")
.containsOne("rethrowThrowable() {")
.containsOne("noThrownExceptions1(InputStream i1) {")
.containsOne("noThrownExceptions2() {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFloatValue.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFloatValue.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
import static org.assertj.core.api.Assertions.within;
public class TestFloatValue extends IntegrationTest {
public static class TestCls {
public float[] test() {
float[] fa = { 0.55f };
fa[0] /= 2;
return fa;
}
public void check() {
assertThat(test()[0]).isCloseTo(0.275f, within(0.0001f));
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("1073741824")
.containsOne("0.55f")
.containsOne("fa[0] = fa[0] / 2.0f;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestMoveInline.java | jadx-core/src/test/java/jadx/tests/integration/others/TestMoveInline.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
@SuppressWarnings("CommentedOutCode")
public class TestMoveInline extends SmaliTest {
// @formatter:off
/*
public final void Y(int i) throws k {
int i2 = 0;
while ((i & (-128)) != 0) {
this.h[i2] = (byte) ((i & 127) | 128);
i >>>= 7;
i2++;
}
byte[] bArr = this.h;
bArr[i2] = (byte) i;
this.a.k(bArr, 0, i2 + 1);
}
*/
// @formatter:on
@Test
public void test() {
assertThat(getClassNodeFromSmali())
.code()
// check operations order
.containsLines(3,
"i >>>= 7;",
"i2++;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFixClassAccessModifiers.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFixClassAccessModifiers.java | package jadx.tests.integration.others;
import java.util.List;
import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestFixClassAccessModifiers extends SmaliTest {
// @formatter:off
/*
// class others.TestCls
public Cls.InnerCls field;
// class others.Cls
public static class Cls {
private static class InnerCls {
}
}
*/
// @formatter:on
@Test
public void test() {
List<ClassNode> classes = loadFromSmaliFiles();
assertThat(searchCls(classes, "others.Cls"))
.code();
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestBadClassAccessModifiers.java | jadx-core/src/test/java/jadx/tests/integration/others/TestBadClassAccessModifiers.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestBadClassAccessModifiers extends SmaliTest {
// @formatter:off
/*
// class others.A
public class A {
public void call() {
B.BB.BBB.test();
}
}
// class others.B
public class B {
private static class BB {
public static class BBB {
public static void test() {
}
}
}
}
*/
@Test
public void test() {
assertThat(getClassNodeFromSmaliFiles("A"))
.code();
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestStringBuilderElimination extends IntegrationTest {
public static class MyException extends Exception {
private static final long serialVersionUID = 4245254480662372757L;
public MyException(String str, Exception e) {
super("msg:" + str, e);
}
public void method(int k) {
System.out.println("k=" + k);
}
}
@Test
public void test() {
assertThat(getClassNode(MyException.class))
.code()
.contains("MyException(String str, Exception e) {")
.contains("super(\"msg:\" + str, e);")
.doesNotContain("new StringBuilder")
.contains("System.out.println(\"k=\" + k);");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestCodeComments2a.java | jadx-core/src/test/java/jadx/tests/integration/others/TestCodeComments2a.java | package jadx.tests.integration.others;
import java.util.Arrays;
import java.util.Random;
import org.junit.jupiter.api.Test;
import jadx.api.data.ICodeComment;
import jadx.api.data.IJavaCodeRef;
import jadx.api.data.IJavaNodeRef.RefType;
import jadx.api.data.impl.JadxCodeComment;
import jadx.api.data.impl.JadxCodeData;
import jadx.api.data.impl.JadxCodeRef;
import jadx.api.data.impl.JadxNodeRef;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestCodeComments2a extends IntegrationTest {
@SuppressWarnings("unused")
public static class TestCls {
private int f;
public int test(boolean z) {
if (z) {
System.out.println("z");
return new Random().nextInt();
}
return f;
}
}
@Test
public void test() {
printOffsets();
String baseClsId = TestCls.class.getName();
JadxNodeRef mthRef = new JadxNodeRef(RefType.METHOD, baseClsId, "test(Z)I");
IJavaCodeRef insnRef = JadxCodeRef.forInsn(isJavaInput() ? 22 : 18);
ICodeComment insnComment = new JadxCodeComment(mthRef, insnRef, "return comment");
IJavaCodeRef insnRef2 = JadxCodeRef.forInsn(isJavaInput() ? 27 : 19);
ICodeComment insnComment2 = new JadxCodeComment(mthRef, insnRef2, "another return comment");
JadxCodeData codeData = new JadxCodeData();
codeData.setComments(Arrays.asList(insnComment, insnComment2));
getArgs().setCodeData(codeData);
assertThat(getClassNode(TestCls.class))
.decompile()
.checkCodeOffsets()
.code()
.containsOne("// " + insnComment.getComment())
.containsOne("// " + insnComment2.getComment());
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestArgInline.java | jadx-core/src/test/java/jadx/tests/integration/others/TestArgInline.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestArgInline extends IntegrationTest {
public static class TestCls {
public void test(int a) {
while (a < 10) {
int b = a + 1;
a = b;
}
}
}
@Test
public void test() {
noDebugInfo();
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.contains("i++;")
.doesNotContain("i = i + 1;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestConstructorBranched2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestConstructorBranched2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
public class TestConstructorBranched2 extends SmaliTest {
@Test
public void test() {
disableCompilation();
assertThat(getClassNodeFromSmali())
.code()
.countString(3, "new StringBuilder()");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStaticMethod.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStaticMethod.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestStaticMethod extends IntegrationTest {
public static class TestCls {
static {
f();
}
private static void f() {
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.contains("static {")
.contains("private static void f() {");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestIfTryInCatch.java | jadx-core/src/test/java/jadx/tests/integration/others/TestIfTryInCatch.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestIfTryInCatch extends IntegrationTest {
public static class TestCls {
public Exception exception;
private java.lang.Object data;
public java.lang.Object test(final Object obj) {
exception = null;
try {
return f();
} catch (Exception e) {
if (a(e) && b(obj)) {
try {
return f();
} catch (Exception exc) {
e = exc;
}
}
System.out.println("Exception" + e);
exception = e;
return data;
}
}
private static boolean b(Object obj) {
return obj == null;
}
private static boolean a(Exception e) {
return e instanceof RuntimeException;
}
private Object f() {
return null;
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.countString(2, "try {")
.containsOne("if (")
.countString(2, "return f();");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStringConcatWithoutResult.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStringConcatWithoutResult.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestStringConcatWithoutResult extends IntegrationTest {
private static final Logger LOG = LoggerFactory.getLogger(TestStringConcatWithoutResult.class);
public static class TestCls {
public static final boolean LOG_DEBUG = false;
public void test(int i) {
String msg = "Input arg value: " + i;
if (LOG_DEBUG) {
LOG.debug(msg);
}
}
}
@Test
public void test() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.containsOne(" = \"Input arg value: \" + i;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestLoopInTry.java | jadx-core/src/test/java/jadx/tests/integration/others/TestLoopInTry.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestLoopInTry extends IntegrationTest {
public static class TestCls {
private static boolean b = true;
public int test() {
try {
if (b) {
throw new Exception();
}
while (f()) {
s();
}
} catch (Exception e) {
System.out.println("exception");
return 1;
}
return 0;
}
private static void s() {
}
private static boolean f() {
return false;
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("try {")
.containsOne("if (b) {")
.containsOne("throw new Exception();")
.containsOne("while (f()) {")
.containsOne("s();")
.containsOne("} catch (Exception e) {")
.containsOne("return 1;")
.containsOne("return 0;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestIssue13a.java | jadx-core/src/test/java/jadx/tests/integration/others/TestIssue13a.java | package jadx.tests.integration.others;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestIssue13a extends IntegrationTest {
public static class TestCls {
private static final String TAG = "Parcel";
private static final Map<ClassLoader, Map<String, Parcelable.Creator<?>>> M_CREATORS = new HashMap<>();
@SuppressWarnings({ "unchecked", "ConstantConditions", "Java8MapApi", "rawtypes" })
public final <T extends Parcelable> T test(ClassLoader loader) {
String name = readString();
if (name == null) {
return null;
}
Parcelable.Creator<T> creator;
synchronized (M_CREATORS) {
Map<String, Parcelable.Creator<?>> map = M_CREATORS.get(loader);
if (map == null) {
map = new HashMap<>();
M_CREATORS.put(loader, map);
}
creator = (Parcelable.Creator<T>) map.get(name);
if (creator == null) {
try {
Class<?> c = loader == null ? Class.forName(name) : Class.forName(name, true, loader);
Field f = c.getField("CREATOR");
creator = (Parcelable.Creator) f.get(null);
} catch (IllegalAccessException e) {
Log.e(TAG, '1' + name + ", e: " + e);
throw new RuntimeException('2' + name);
} catch (ClassNotFoundException e) {
Log.e(TAG, '3' + name + ", e: " + e);
throw new RuntimeException('4' + name);
} catch (ClassCastException e) {
throw new RuntimeException('5' + name);
} catch (NoSuchFieldException e) {
throw new RuntimeException('6' + name);
}
if (creator == null) {
throw new RuntimeException('7' + name);
}
map.put(name, creator);
}
}
if (creator instanceof Parcelable.ClassLoaderCreator<?>) {
return ((Parcelable.ClassLoaderCreator<T>) creator).createFromParcel(this, loader);
}
return creator.createFromParcel(this);
}
private String readString() {
return "";
}
private class Parcelable {
public class Creator<T> {
public T createFromParcel(TestCls testCls) {
return null;
}
}
public class ClassLoaderCreator<T> extends Creator<T> {
public T createFromParcel(TestCls testCls, ClassLoader loader) {
return null;
}
}
}
private static class Log {
public static void e(String tag, String s) {
}
}
}
@Test
public void test() {
disableCompilation();
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
for (int i = 1; i <= 7; i++) {
assertThat(code).containsOne("'" + i + '\'');
}
// TODO: add additional checks
assertThat(code).doesNotContain("Throwable");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitNegative.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitNegative.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
/**
* Negative case for field initialization move (#1599).
* Can't reorder with other instance methods.
*/
public class TestFieldInitNegative extends IntegrationTest {
public static class TestCls {
StringBuilder sb;
int field;
public TestCls() {
initBuilder(new StringBuilder("sb"));
this.field = initField();
this.sb.append(this.field);
}
private void initBuilder(StringBuilder sb) {
this.sb = sb;
}
private int initField() {
return sb.length();
}
public String getStr() {
return sb.toString();
}
public void check() {
assertThat(new TestCls().getStr()).isEqualTo("sb2"); // no NPE
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("int field = initField();")
.containsOne("this.field = initField();");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestInsnsBeforeSuper2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestInsnsBeforeSuper2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestInsnsBeforeSuper2 extends SmaliTest {
// @formatter:off
/*
public class TestInsnsBeforeSuper2 extends java.lang.Exception {
private int mErrorType;
public TestInsnsBeforeSuper2(java.lang.String r9, int r10) {
r8 = this;
r0 = r8
r1 = r9
r2 = r10
r3 = r0
r4 = r1
r5 = r2
r6 = r1
r0.<init>(r6)
r7 = 0
r0.mErrorType = r7
r0.mErrorType = r2
return
}
}
*/
// @formatter:on
@Test
public void test() {
assertThat(getClassNodeFromSmali())
.code()
.containsOne("super(message);")
.containsOne("this.mErrorType = errorType;");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestCodeCommentsMultiline.java | jadx-core/src/test/java/jadx/tests/integration/others/TestCodeCommentsMultiline.java | package jadx.tests.integration.others;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import jadx.api.data.ICodeComment;
import jadx.api.data.IJavaCodeRef;
import jadx.api.data.IJavaNodeRef.RefType;
import jadx.api.data.impl.JadxCodeComment;
import jadx.api.data.impl.JadxCodeData;
import jadx.api.data.impl.JadxCodeRef;
import jadx.api.data.impl.JadxNodeRef;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestCodeCommentsMultiline extends IntegrationTest {
public static class TestCls {
public int test(boolean z) {
if (z) {
System.out.println("z");
return 1;
}
return 3;
}
}
@Test
public void test() {
printOffsets();
String baseClsId = TestCls.class.getName();
JadxNodeRef mthRef = new JadxNodeRef(RefType.METHOD, baseClsId, "test(Z)I");
IJavaCodeRef insnRef = JadxCodeRef.forInsn(isJavaInput() ? 15 : 11);
ICodeComment insnComment = new JadxCodeComment(mthRef, insnRef, "multi\nline\ncomment");
JadxCodeData codeData = new JadxCodeData();
codeData.setComments(Collections.singletonList(insnComment));
getArgs().setCodeData(codeData);
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("// multi")
.containsOne("// line")
.containsOne("// comment");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFieldUsageMove.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldUsageMove.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import jadx.tests.api.extensions.profiles.TestProfile;
import jadx.tests.api.extensions.profiles.TestWithProfiles;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestFieldUsageMove extends SmaliTest {
public static class TestCls {
public static void test(Object obj) {
if (obj instanceof Boolean) {
System.out.println("Boolean: " + obj);
}
if (obj instanceof Float) {
System.out.println("Float: " + obj);
}
}
}
@TestWithProfiles(TestProfile.D8_J11)
public void test() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("System.out.println(\"Boolean: \" +")
.containsOne("System.out.println(\"Float: \" +");
}
@Test
public void testSmali() {
assertThat(getClassNodeFromSmali())
.code()
.containsOne("System.out.println(\"Boolean: \" +")
.containsOne("System.out.println(\"Float: \" +");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestMissingExceptions.java | jadx-core/src/test/java/jadx/tests/integration/others/TestMissingExceptions.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
class TestMissingExceptions extends SmaliTest {
@Test
void test() {
assertThat(getClassNodeFromSmali())
.code()
.countString(6, "FileNotFoundException");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestConstructorBranched.java | jadx-core/src/test/java/jadx/tests/integration/others/TestConstructorBranched.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
@SuppressWarnings("CommentedOutCode")
public class TestConstructorBranched extends SmaliTest {
// @formatter:off
/*
public Set<String> test(Collection<String> collection) {
Set<String> set;
if (collection == null) {
set = new HashSet<>();
} else {
set = new HashSet<>(collection);
}
set.add("end");
return set;
}
*/
// @formatter:on
@Test
public void test() {
assertThat(getClassNodeFromSmali())
.code()
.containsOne("new HashSet()")
.containsOne("new HashSet(collection)");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing4.java | jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing4.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestDeboxing4 extends IntegrationTest {
public static class TestCls {
public boolean test(Integer i) {
return ((Integer) 1).equals(i);
}
public void check() {
assertThat(test(null)).isFalse();
assertThat(test(0)).isFalse();
assertThat(test(1)).isTrue();
}
}
@Test
public void test() {
noDebugInfo();
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("return 1.equals(num);");
}
@Test
@NotYetImplemented("Inline boxed types")
public void testInline() {
noDebugInfo();
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("return ((Integer) 1).equals(i);");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestInsnsBeforeThis.java | jadx-core/src/test/java/jadx/tests/integration/others/TestInsnsBeforeThis.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestInsnsBeforeThis extends SmaliTest {
// @formatter:off
/*
public class A {
public A(String str) {
checkNull(str);
this(str.length());
}
public A(int i) {
}
public void checkNull(Object o) {
if (o == null) {
throw new NullPointerException();
}
}
}
*/
// @formatter:on
@Test
public void test() {
allowWarnInCode();
assertThat(getClassNodeFromSmali())
.code()
.containsOne("checkNull(str);");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination4Neg.java | jadx-core/src/test/java/jadx/tests/integration/others/TestStringBuilderElimination4Neg.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestStringBuilderElimination4Neg extends IntegrationTest {
public static class TestCls<K, V> {
private K k;
private V v;
public String test() {
StringBuilder sb = new StringBuilder();
sb.append(k);
sb.append('=');
sb.append(v);
return sb.toString();
}
}
@Test
public void test() {
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.contains("sb.append('=');");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestUsageApacheHttpClient.java | jadx-core/src/test/java/jadx/tests/integration/others/TestUsageApacheHttpClient.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestUsageApacheHttpClient extends SmaliTest {
// @formatter:off
/*
package others;
import org.apache.http.client.HttpClient;
public class HttpClientTest {
private HttpClient httpClient;
}
*/
// @formatter:on
@Test
public void test() {
disableCompilation();
ClassNode cls = getClassNodeFromSmali();
assertThat(cls.root().getGradleInfoStorage().isUseApacheHttpLegacy()).isTrue();
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing3.java | jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing3.java | package jadx.tests.integration.others;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
public class TestDeboxing3 extends IntegrationTest {
public static class TestCls {
public static class Pair<F, S> {
public F first;
public S second;
}
private Map<String, Pair<Long, String>> cache = new HashMap<>();
public boolean test(String id, Long l) {
if (l == null) {
l = 900000L;
}
Pair<Long, String> pair = this.cache.get(id);
if (pair == null) {
return false;
}
return pair.first + l > System.currentTimeMillis();
}
}
@Test
public void test() {
noDebugInfo();
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("l = 900000L;");
}
@Test
@NotYetImplemented("Full deboxing and generics propagation")
public void testFull() {
noDebugInfo();
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("Pair<Long, String> pair = this.cache.get(id);")
.containsOne("return pair.first + l > System.currentTimeMillis();");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing.java | jadx-core/src/test/java/jadx/tests/integration/others/TestDeboxing.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import jadx.tests.api.utils.assertj.JadxAssertions;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestDeboxing extends IntegrationTest {
public static class TestCls {
public Object testInt() {
return 1;
}
public Object testBoolean() {
return true;
}
public Object testByte() {
return (byte) 2;
}
public Short testShort() {
return 3;
}
public Character testChar() {
return 'c';
}
public Long testLong() {
return 4L;
}
public void testConstInline() {
Boolean v = true;
use(v);
use(v);
}
private void use(Boolean v) {
}
public void check() {
// don't mind weird comparisons
// need to get primitive without using boxing or literal
// otherwise will get same result after decompilation
assertThat(testInt()).isEqualTo(Integer.sum(0, 1));
assertThat(testBoolean()).isEqualTo(Boolean.TRUE);
assertThat(testByte()).isEqualTo(Byte.parseByte("2"));
assertThat(testShort()).isEqualTo(Short.parseShort("3"));
assertThat(testChar()).isEqualTo("c".charAt(0));
assertThat(testLong()).isEqualTo(Long.valueOf("4"));
testConstInline();
}
}
@Test
public void test() {
noDebugInfo();
JadxAssertions.assertThat(getClassNode(TestCls.class))
.code()
.containsOne("return 1;")
.containsOne("return true;")
.containsOne("return (byte) 2;")
.containsOne("return (short) 3;")
.containsOne("return 'c';")
.containsOne("return 4L;")
.countString(2, "use(true);");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitOrderStatic.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitOrderStatic.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestFieldInitOrderStatic extends IntegrationTest {
@SuppressWarnings("ConstantName")
public static class TestCls {
private static final StringBuilder sb = new StringBuilder();
private static final String a = sb.append("a").toString();
private static final String b = sb.append("b").toString();
private static final String c = sb.append("c").toString();
private static final String result = sb.toString();
public void check() {
assertThat(result).isEqualTo("abc");
assertThat(a).isEqualTo("a");
assertThat(b).isEqualTo("ab");
assertThat(c).isEqualTo("abc");
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("static {")
.doesNotContain("String result;")
.containsOne("String result = sb.toString();");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestPrimitiveCasts2.java | jadx-core/src/test/java/jadx/tests/integration/others/TestPrimitiveCasts2.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
// Source: https://github.com/skylot/jadx/issues/1620
public class TestPrimitiveCasts2 extends IntegrationTest {
@SuppressWarnings("DataFlowIssue")
public static class TestCls {
long instanceCount;
{
float f = 50.231F;
instanceCount &= (long) f;
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code();
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
skylot/jadx | https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitOrder.java | jadx-core/src/test/java/jadx/tests/integration/others/TestFieldInitOrder.java | package jadx.tests.integration.others;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestFieldInitOrder extends IntegrationTest {
public static class TestCls {
private final StringBuilder sb = new StringBuilder();
private final String a = sb.append("a").toString();
private final String b = sb.append("b").toString();
private final String c = sb.append("c").toString();
private final String result = sb.toString();
public void check() {
assertThat(result).isEqualTo("abc");
assertThat(a).isEqualTo("a");
assertThat(b).isEqualTo("ab");
assertThat(c).isEqualTo("abc");
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("TestCls() {") // constructor removed
.doesNotContain("String result;")
.containsOne("String result = this.sb.toString();");
}
}
| java | Apache-2.0 | 7bbb58863b8a80c0b862425d2701d23be40aeae8 | 2026-01-04T14:45:57.033910Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.