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/conditions/TestConditions11.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions11.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestConditions11 extends IntegrationTest { public static class TestCls { public void test(boolean a, int b) { if (a || b > 2) { f(); } } private void f() { } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("if (a || b > 2) {") .containsOne("f();") .doesNotContain("return") .doesNotContain("else"); } }
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/conditions/TestBooleanToInt2.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestBooleanToInt2.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; @SuppressWarnings("CommentedOutCode") public class TestBooleanToInt2 extends SmaliTest { // @formatter:off /* public static class TestCls { public void test() { boolean v = getValue(); use1(Integer.valueOf(v)); use2(v); } private boolean getValue() { return false; } private void use1(Integer v) { } private void use2(int v) { } } */ // @formatter:on @Test public void test() { assertThat(getClassNodeFromSmali()) .code() .containsOne("use1(Integer.valueOf(value ? 1 : 0));") .containsOne("use2(value ? 1 : 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/conditions/TestConditions16.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions16.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; import static org.assertj.core.api.Assertions.assertThat; public class TestConditions16 extends IntegrationTest { public static class TestCls { private static boolean test(int a, int b) { return a < 0 || b % 2 != 0 && a > 28 || b < 0; } public void check() { assertThat(test(-1, 1)).isTrue(); assertThat(test(1, -1)).isTrue(); assertThat(test(29, 3)).isTrue(); assertThat(test(2, 2)).isFalse(); } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("return a < 0 || (b % 2 != 0 && a > 28) || b < 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/conditions/TestIfCodeStyle.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestIfCodeStyle.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; /** * Issue #1455 */ public class TestIfCodeStyle extends SmaliTest { @SuppressWarnings({ "ConstantConditions", "FieldCanBeLocal", "unused" }) public static class TestCls { private String moduleName; private String modulePath; private String preinstalledModulePath; private long versionCode; private String versionName; private boolean isFactory; private boolean isActive; public void test(Parcel parcel) { int startPos = parcel.dataPosition(); int size = parcel.readInt(); if (size < 0) { if (startPos > Integer.MAX_VALUE - size) { throw new RuntimeException("Overflow in the size of parcelable"); } parcel.setDataPosition(startPos + size); return; } try { if (parcel.dataPosition() - startPos >= size) { if (startPos > Integer.MAX_VALUE - size) { throw new RuntimeException("Overflow in the size of parcelable"); } parcel.setDataPosition(startPos + size); return; } this.moduleName = parcel.readString(); if (parcel.dataPosition() - startPos >= size) { if (startPos > Integer.MAX_VALUE - size) { throw new RuntimeException("Overflow in the size of parcelable"); } parcel.setDataPosition(startPos + size); return; } this.modulePath = parcel.readString(); if (parcel.dataPosition() - startPos >= size) { if (startPos > Integer.MAX_VALUE - size) { throw new RuntimeException("Overflow in the size of parcelable"); } parcel.setDataPosition(startPos + size); return; } this.preinstalledModulePath = parcel.readString(); if (parcel.dataPosition() - startPos >= size) { if (startPos > Integer.MAX_VALUE - size) { throw new RuntimeException("Overflow in the size of parcelable"); } parcel.setDataPosition(startPos + size); return; } this.versionCode = parcel.readLong(); if (parcel.dataPosition() - startPos >= size) { if (startPos > Integer.MAX_VALUE - size) { throw new RuntimeException("Overflow in the size of parcelable"); } parcel.setDataPosition(startPos + size); return; } this.versionName = parcel.readString(); if (parcel.dataPosition() - startPos >= size) { if (startPos > Integer.MAX_VALUE - size) { throw new RuntimeException("Overflow in the size of parcelable"); } parcel.setDataPosition(startPos + size); return; } this.isFactory = parcel.readInt() != 0; if (parcel.dataPosition() - startPos >= size) { if (startPos > Integer.MAX_VALUE - size) { throw new RuntimeException("Overflow in the size of parcelable"); } parcel.setDataPosition(startPos + size); return; } this.isActive = parcel.readInt() != 0; if (startPos > Integer.MAX_VALUE - size) { throw new RuntimeException("Overflow in the size of parcelable"); } parcel.setDataPosition(startPos + size); } catch (Throwable e) { if (startPos <= Integer.MAX_VALUE - size) { parcel.setDataPosition(startPos + size); throw e; } throw new RuntimeException("Overflow in the size of parcelable"); } } private static class Parcel { public void setDataPosition(int i) { } public int dataPosition() { return 0; } public int readInt() { return 0; } public String readString() { return null; } public long readLong() { return 0; } } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() // allow one last 'else' .oneOf(c -> c.doesNotContain("else").countString(8, "return;"), c -> c.countString(1, "else").countString(7, "return;")) .containsLines(2, "if (i < 0) {", indent() + "if (iDataPosition > Integer.MAX_VALUE - i) {", indent(2) + "throw new RuntimeException(\"Overflow in the size of parcelable\");", indent() + "}", indent() + "parcel.setDataPosition(iDataPosition + i);", indent() + "return;", "}"); } @Test public void testSmali() { disableCompilation(); assertThat(getClassNodeFromSmali()) .code() // allow one last 'else' .oneOf(c -> c.doesNotContain("else").countString(8, "return;"), c -> c.countString(1, "else").countString(7, "return;")) .containsLines(2, "if (_aidl_parcelable_size < 0) {", indent() + "if (_aidl_start_pos > Integer.MAX_VALUE - _aidl_parcelable_size) {", indent(2) + "throw new RuntimeException(\"Overflow in the size of parcelable\");", indent() + "}", indent() + "_aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);", indent() + "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/conditions/TestConditions4.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions4.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestConditions4 extends IntegrationTest { public static class TestCls { public int test(int num) { boolean inRange = (num >= 59 && num <= 66); return inRange ? num + 1 : num; } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .contains("num >= 59 && num <= 66") .contains("? num + 1 : num;").doesNotContain("else"); } }
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/conditions/TestConditions15.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions15.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestConditions15 extends IntegrationTest { public static class TestCls { public static boolean test(final String name) { if (isEmpty(name)) { return false; } if ("1".equals(name) || "2".equals(name) || "3".equals(name) || "4".equals(name) || "5".equals(name) || "6".equals(name) || "7".equals(name) || "8".equals(name) || "9".equals(name) || "10".equals(name) || "11".equals(name) || "12".equals(name) || "13".equals(name) || "14".equals(name) || "15".equals(name) || "16".equals(name) || "17".equals(name) || "18".equals(name) || "19".equals(name) || "20".equals(name) || "22".equals(name) || "22".equals(name) || "23".equals(name) || "24".equals(name) || "25".equals(name) || "26".equals(name) || "27".equals(name) || "28".equals(name) || "29".equals(name) || "30".equals(name)) { return false; } else { return true; } } private static boolean isEmpty(String name) { return name.isEmpty(); } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("\"1\".equals(name)") .containsOne("\"30\".equals(name)"); } }
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/conditions/TestNestedIf2.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestNestedIf2.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestNestedIf2 extends IntegrationTest { public static class TestCls { static int executedCount = 0; static boolean finished = false; static int repeatCount = 2; static boolean test(float delta, Object object) { if (executedCount != repeatCount && isRun(delta, object)) { if (finished) { return true; } if (repeatCount == -1) { ++executedCount; action(); return false; } ++executedCount; if (executedCount >= repeatCount) { return true; } action(); } return false; } public static void action() { } public static boolean isRun(float delta, Object object) { return delta == 0; } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("if (executedCount != repeatCount && isRun(delta, object)) {") .containsOne("if (finished) {") .doesNotContain("else"); } }
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/conditions/TestSimpleConditions.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestSimpleConditions.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestSimpleConditions extends IntegrationTest { public static class TestCls { public boolean test1(boolean[] a) { return (a[0] && a[1] && a[2]) || (a[3] && a[4]); } public boolean test2(boolean[] a) { return a[0] || a[1] || a[2] || a[3]; } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .contains("return (a[0] && a[1] && a[2]) || (a[3] && a[4]);") .contains("return a[0] || a[1] || a[2] || a[3];"); } }
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/conditions/TestBitwiseOr.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestBitwiseOr.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestBitwiseOr extends IntegrationTest { public static class TestCls { private boolean a; private boolean b; public void test() { if ((a | b) != false) { test(); } } } @Test public void test() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("if (this.a || this.b) {"); } public static class TestCls2 { private boolean a; private boolean b; public void test() { if ((a | b) != true) { test(); } } } @Test public void test2() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls2.class)) .code() .containsOne("if (!this.a && !this.b) {"); } public static class TestCls3 { private boolean a; private boolean b; public void test() { if ((a | b) == false) { test(); } } } @Test public void test3() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls3.class)) .code() .containsOne("if (!this.a && !this.b) {"); } public static class TestCls4 { private boolean a; private boolean b; public void test() { if ((a | b) == true) { test(); } } } @Test public void test4() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls4.class)) .code() .containsOne("if (this.a || 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/conditions/TestInnerAssign2.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestInnerAssign2.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestInnerAssign2 extends IntegrationTest { public static class TestCls { private String field; private String swapField; @SuppressWarnings("checkstyle:InnerAssignment") public boolean test(String str) { String sub; return call(str) || ((sub = this.field) != null && sub.isEmpty()); } private boolean call(String str) { this.field = swapField; return str.isEmpty(); } public boolean testWrap(String str, String fieldValue) { this.field = null; this.swapField = fieldValue; return test(str); } public void check() { assertThat(testWrap("", null)).isTrue(); assertThat(testWrap("a", "")).isTrue(); assertThat(testWrap("b", null)).isFalse(); assertThat(testWrap("c", "d")).isFalse(); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("sub = this.field") .containsOne("return call(str) || ((sub = this.field) != null && sub.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/conditions/TestBooleanToDouble.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestBooleanToDouble.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestBooleanToDouble extends SmaliTest { // @formatter:off /* private boolean showConsent; public void write(double d) { } public void writeToParcel(TestBooleanToDouble testBooleanToDouble) { testBooleanToDouble.write(this.showConsent ? 1 : 0); } */ // @formatter:on @Test public void test() { assertThat(getClassNodeFromSmali()) .code() .containsOne("write(this.showConsent ? 1.0d : 0.0d);"); } }
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/conditions/TestConditions17.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions17.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestConditions17 extends IntegrationTest { public static class TestCls { public static final int SOMETHING = 2; public static void test(int a) { if ((a & SOMETHING) != 0) { print(1); } print(2); } public static void print(Object o) { } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne(" & "); } }
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/conditions/TestCast.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestCast.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestCast extends IntegrationTest { public static class TestCls { byte myByte; short myShort; public void test1(boolean a) { write(a ? (byte) 0 : 1); } public void test2(boolean a) { write(a ? 0 : myByte); } public void test3(boolean a) { write(a ? 0 : (byte) 127); } public void test4(boolean a) { write(a ? (short) 0 : 1); } public void test5(boolean a) { write(a ? myShort : 0); } public void test6(boolean a) { write(a ? Short.MIN_VALUE : 0); } public void write(byte b) { } public void write(short b) { } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .contains("write(a ? (byte) 0 : (byte) 1);") .contains("write(a ? (byte) 0 : this.myByte);") .contains("write(a ? (byte) 0 : (byte) 127);") .contains("write(a ? (short) 0 : (short) 1);") .contains("write(a ? this.myShort : (short) 0);") .contains("write(a ? Short.MIN_VALUE : (short) 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/conditions/TestTernary.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestTernary.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTernary extends IntegrationTest { public static class TestCls { public boolean test1(int a) { return a != 2; } public void test2(int a) { checkTrue(a == 3); } public int test3(int a) { return a > 0 ? a : (a + 2) * 3; } private static void checkTrue(boolean v) { } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("else") .contains("return a != 2;") .contains("checkTrue(a == 3)") .contains("return a > 0 ? a : (a + 2) * 3;"); } }
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/conditions/TestConditions9.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions9.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestConditions9 extends IntegrationTest { public static class TestCls { public void test(boolean a, int b) throws Exception { if (!a || (b >= 0 && b <= 11)) { System.out.println('1'); } else { System.out.println('2'); } } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("if (!a || (b >= 0 && b <= 11)) {") .containsOne("System.out.println('1');") .containsOne("} else {") .containsOne("System.out.println('2');") .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/conditions/TestTernary2.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestTernary2.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.NotYetImplemented; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTernary2 extends IntegrationTest { public static class TestCls { public void test() { checkFalse(f(1, 0) == 0); } private int f(int a, int b) { return a + b; } private void checkFalse(boolean b) { if (b) { throw new AssertionError("Must be false"); } } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("f(1, 0)"); } @Test @NotYetImplemented public void test2() { assertThat(getClassNode(TestCls.class)) .code() .contains("assertTrue(f(1, 0) == 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/conditions/TestIfCodeStyle2.java
jadx-core/src/test/java/jadx/tests/integration/conditions/TestIfCodeStyle2.java
package jadx.tests.integration.conditions; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; /** * Issue #2052 */ public class TestIfCodeStyle2 extends SmaliTest { @Test public void testSmali() { disableCompilation(); assertThat(getClassNodeFromSmali()) .code() .countString(1, "} else if (") .countString(1, "} else {") .countString(19, "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/fallback/TestFallbackMode.java
jadx-core/src/test/java/jadx/tests/integration/fallback/TestFallbackMode.java
package jadx.tests.integration.fallback; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestFallbackMode extends IntegrationTest { public static class TestCls { public int test(int a) { while (a < 10) { a++; } return a; } } @Test public void test() { useDexInput(); setFallback(); disableCompilation(); JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .contains("public int test(int r2) {") .containsOne("r1 = this;") .containsOne("L0:") .containsOne("L7:") .containsOne("int r2 = r2 + 1") .doesNotContain("throw new UnsupportedOperationException"); } }
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/fallback/TestFallbackManyNops.java
jadx-core/src/test/java/jadx/tests/integration/fallback/TestFallbackManyNops.java
package jadx.tests.integration.fallback; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestFallbackManyNops extends SmaliTest { @Test public void test() { setFallback(); disableCompilation(); assertThat(getClassNodeFromSmali()) .code() .contains("public static void test() {") .containsOne("return") .doesNotContain("Method dump skipped"); } }
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/debuginfo/TestVariablesNames.java
jadx-core/src/test/java/jadx/tests/integration/debuginfo/TestVariablesNames.java
package jadx.tests.integration.debuginfo; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestVariablesNames extends SmaliTest { // @formatter:off /* public static class TestCls { public void test(String s, int k) { f1(s); int i = k + 3; String s2 = "i" + i; f2(i, s2); double d = i * 5; String s3 = "d" + d; f3(d, s3); } private void f1(String s) { } private void f2(int i, String i2) { } private void f3(double d, String d2) { } } */ // @formatter:on /** * Parameter register reused in variables assign with different types and names * No variables names in debug info */ @Test public void test() { assertThat(getClassNodeFromSmaliWithPath("debuginfo", "TestVariablesNames")) .code() // TODO: don't use current variables naming in tests .containsOne("f1(str);") .containsOne("f2(i2, \"i\" + i2);") .containsOne("f3(d, \"d\" + d);"); } }
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/debuginfo/TestLineNumbers2.java
jadx-core/src/test/java/jadx/tests/integration/debuginfo/TestLineNumbers2.java
package jadx.tests.integration.debuginfo; import java.lang.ref.WeakReference; import jadx.core.dex.nodes.ClassNode; import jadx.tests.api.IntegrationTest; import jadx.tests.api.extensions.profiles.TestProfile; import jadx.tests.api.extensions.profiles.TestWithProfiles; import static org.assertj.core.api.Assertions.assertThat; public class TestLineNumbers2 extends IntegrationTest { public static class TestCls { private WeakReference<TestCls> f; // keep constructor at line 18 public TestCls(TestCls s) { } public TestCls test(TestCls s) { TestCls store = f != null ? f.get() : null; if (store == null) { store = new TestCls(s); f = new WeakReference<>(store); } return store; } public Object test2() { return new Object(); } } @TestWithProfiles({ TestProfile.DX_J8, TestProfile.JAVA8 }) public void test() { printLineNumbers(); ClassNode cls = getClassNode(TestCls.class); String linesMapStr = cls.getCode().getCodeMetadata().getLineMapping().toString(); if (isJavaInput()) { assertThat(linesMapStr).isEqualTo("{6=16, 9=17, 12=21, 13=22, 14=23, 15=24, 16=25, 18=27, 21=30, 22=31}"); } else { assertThat(linesMapStr).isEqualTo("{6=16, 9=17, 12=21, 13=22, 14=23, 15=24, 16=25, 17=27, 19=27, 22=30, 23=31}"); } } }
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/debuginfo/TestLineNumbers3.java
jadx-core/src/test/java/jadx/tests/integration/debuginfo/TestLineNumbers3.java
package jadx.tests.integration.debuginfo; import jadx.core.dex.nodes.ClassNode; 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 TestLineNumbers3 extends IntegrationTest { public static class TestCls extends Exception { public TestCls(final Object message) { super((message == null) ? "" : message.toString()); /* * comment to increase line number in return instruction * - * - * - * - * - * - * - * - * - * - */ } } @TestWithProfiles({ TestProfile.DX_J8, TestProfile.JAVA8 }) public void test() { ClassNode cls = getClassNode(TestCls.class); assertThat(cls).code().containsOne("super(message == null ? \"\" : message.toString());"); String linesMapStr = cls.getCode().getCodeMetadata().getLineMapping().toString(); assertThat(linesMapStr).isEqualTo("{4=13, 5=14, 6=15}"); } }
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/debuginfo/TestLineNumbers.java
jadx-core/src/test/java/jadx/tests/integration/debuginfo/TestLineNumbers.java
package jadx.tests.integration.debuginfo; import org.junit.jupiter.api.Test; import jadx.api.utils.CodeUtils; import jadx.core.dex.attributes.nodes.LineAttrNode; 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 TestLineNumbers extends IntegrationTest { public static class TestCls { int field; public void func() { } public static class Inner { int innerField; public void innerFunc() { } public void innerFunc2() { new Runnable() { @Override public void run() { } }.run(); } public void innerFunc3() { } } } @Test public void test() { printLineNumbers(); ClassNode cls = getClassNode(TestCls.class); String code = cls.getCode().toString(); FieldNode field = cls.searchFieldByName("field"); MethodNode func = cls.searchMethodByShortId("func()V"); ClassNode inner = cls.getInnerClasses().get(0); MethodNode innerFunc = inner.searchMethodByShortId("innerFunc()V"); MethodNode innerFunc2 = inner.searchMethodByShortId("innerFunc2()V"); MethodNode innerFunc3 = inner.searchMethodByShortId("innerFunc3()V"); FieldNode innerField = inner.searchFieldByName("innerField"); // check source lines (available only for instructions and methods) int testClassLine = 16; assertThat(testClassLine + 3).isEqualTo(func.getSourceLine()); assertThat(testClassLine + 9).isEqualTo(innerFunc.getSourceLine()); assertThat(testClassLine + 12).isEqualTo(innerFunc2.getSourceLine()); assertThat(testClassLine + 20).isEqualTo(innerFunc3.getSourceLine()); // check decompiled lines checkLine(code, field, "int field;"); checkLine(code, func, "public void func() {"); checkLine(code, inner, "public static class Inner {"); checkLine(code, innerField, "int innerField;"); checkLine(code, innerFunc, "public void innerFunc() {"); checkLine(code, innerFunc2, "public void innerFunc2() {"); checkLine(code, innerFunc3, "public void innerFunc3() {"); } private static void checkLine(String code, LineAttrNode node, String str) { String line = CodeUtils.getLineForPos(code, node.getDefPosition()); assertThat(line).contains(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/debuginfo/TestReturnSourceLine.java
jadx-core/src/test/java/jadx/tests/integration/debuginfo/TestReturnSourceLine.java
package jadx.tests.integration.debuginfo; import org.junit.jupiter.api.Test; import jadx.api.ICodeInfo; import jadx.api.utils.CodeUtils; import jadx.core.dex.attributes.nodes.LineAttrNode; 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; import static org.assertj.core.api.Assertions.assertThat; public class TestReturnSourceLine extends IntegrationTest { public static class TestCls { public int test1(boolean v) { if (v) { f(); return 1; } f(); return 0; } public int test2(int v) { if (v == 0) { f(); return v - 1; } f(); return v + 1; } public int test3(int v) { if (v == 0) { f(); return v; } f(); return v + 1; } private void f() { } } @Test public void test() { printLineNumbers(); ClassNode cls = getClassNode(TestCls.class); ICodeInfo codeInfo = cls.getCode(); String[] lines = codeInfo.getCodeStr().split("\\R"); MethodNode test1 = cls.searchMethodByShortId("test1(Z)I"); checkLine(lines, codeInfo, test1, 3, "return 1;"); MethodNode test2 = cls.searchMethodByShortId("test2(I)I"); checkLine(lines, codeInfo, test2, 3, "return v - 1;"); checkLine(lines, codeInfo, test2, 6, "return v + 1;"); MethodNode test3 = cls.searchMethodByShortId("test3(I)I"); if (isJavaInput()) { // dx lost line number for this return checkLine(lines, codeInfo, test3, 3, "return v;"); } checkLine(lines, codeInfo, test3, 6, "return v + 1;"); } private static void checkLine(String[] lines, ICodeInfo cw, LineAttrNode node, int offset, String str) { int nodeDefLine = CodeUtils.getLineNumForPos(cw.getCodeStr(), node.getDefPosition(), "\n"); int decompiledLine = nodeDefLine + offset; assertThat(lines[decompiledLine - 1]).containsOne(str); Integer sourceLine = cw.getCodeMetadata().getLineMapping().get(decompiledLine); assertThat(sourceLine).isNotNull(); assertThat((int) sourceLine).isEqualTo(node.getSourceLine() + offset); } }
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/arrays/TestArrays2.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrays2.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestArrays2 extends IntegrationTest { public static class TestCls { private static Object test4(int type) { if (type == 1) { return new int[] { 1, 2 }; } else if (type == 2) { return new float[] { 1, 2 }; } else if (type == 3) { return new short[] { 1, 2 }; } else if (type == 4) { return new byte[] { 1, 2 }; } else { return null; } } public void check() { assertThat(test4(4)).isInstanceOf(byte[].class); } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("new int[]{1, 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/arrays/TestArrays4.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrays4.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestArrays4 extends IntegrationTest { public static class TestCls { char[] payload; public TestCls(byte[] bytes) { char[] a = toChars(bytes); this.payload = new char[a.length]; System.arraycopy(a, 0, this.payload, 0, bytes.length); } private static char[] toChars(byte[] bArr) { return new char[bArr.length]; } } @Test public void testArrayTypeInference() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("char[] chars = toChars(bArr);"); } }
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/arrays/TestArrayFillNegative.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayFillNegative.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestArrayFillNegative extends IntegrationTest { public static class TestCls { public int[] test() { int[] arr = new int[3]; arr[0] = 1; arr[1] = arr[0] + 1; arr[2] = arr[1] + 1; return arr; } public void check() { assertThat(test()).isEqualTo(new int[] { 1, 2, 3 }); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("int[] arr = {1, ") .containsOne("int[] arr = new int[3];") .containsOne("arr[1] = arr[0] + 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/arrays/TestArrayInit.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayInit.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestArrayInit extends IntegrationTest { public static class TestCls { byte[] bytes; @SuppressWarnings("unused") public void test() { byte[] arr = new byte[] { 10, 20, 30 }; } public void test2() { bytes = new byte[] { 10, 20, 30 }; } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .contains("= {10, 20, 30};") .contains("this.bytes = new byte[]{10, 20, 30};"); } }
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/arrays/TestArrayFill3.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayFill3.java
package jadx.tests.integration.arrays; 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 TestArrayFill3 extends IntegrationTest { public static class TestCls { public byte[] test() { return new byte[] { 0, 1, 2 }; } } @TestWithProfiles({ TestProfile.ECJ_J8, TestProfile.ECJ_DX_J8 }) public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("return new byte[]{0, 1, 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/arrays/TestArrays3.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrays3.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestArrays3 extends IntegrationTest { public static class TestCls { private Object test(byte[] bArr) { return new Object[] { bArr }; } public void check() { byte[] inputArr = { 1, 2 }; Object result = test(inputArr); assertThat(result).isInstanceOf(Object[].class); assertThat(((Object[]) result)[0]).isEqualTo(inputArr); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("return new Object[]{bArr};"); } @Test public void testNoDebug() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("return new Object[]{bArr};"); } }
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/arrays/TestArrayFillWithMove.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayFillWithMove.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestArrayFillWithMove extends SmaliTest { @Test public void test() { assertThat(getClassNodeFromSmaliFiles("TestCls")) .code() .doesNotContain("// fill-array-data instruction") .doesNotContain("arr[0] = 0;") .contains("return new long[]{0, 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/arrays/TestArrayFill4.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayFill4.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestArrayFill4 extends IntegrationTest { public static class TestCls { // replaced constant break filled array creation private static final int ARRAY_SIZE = 4; public long[] test() { return new long[] { 0, 1, Long.MAX_VALUE, Long.MIN_VALUE + 1 }; } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("new long[ARRAY_SIZE];") .containsOne("return new long[]{0, 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/arrays/TestArrayFill.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayFill.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestArrayFill extends IntegrationTest { public static class TestCls { public String[] method() { return new String[] { "1", "2", "3" }; } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .contains("return new String[]{\"1\", \"2\", \"3\"};"); } }
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/arrays/TestArrays.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrays.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestArrays extends IntegrationTest { public static class TestCls { public int test1(int i) { int[] a = new int[] { 1, 2, 3, 5 }; return a[i]; } public int test2(int i) { int[][] a = new int[i][i + 1]; return a.length; } } @Test public void test() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("return new int[]{1, 2, 3, 5}[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/arrays/TestArrayFill2.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayFill2.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.NotYetImplemented; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestArrayFill2 extends IntegrationTest { public static class TestCls { public int[] test(int a) { return new int[] { 1, a + 1, 2 }; } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .contains("return new int[]{1, a + 1, 2};"); } public static class TestCls2 { public int[] test2(int a) { return new int[] { 1, a++, a * 2 }; } } @Test @NotYetImplemented public void test2() { JadxAssertions.assertThat(getClassNode(TestCls2.class)) .code() .contains("return new int[]{1, a++, a * 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/arrays/TestArrayFillConstReplace.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayFillConstReplace.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestArrayFillConstReplace extends IntegrationTest { public static class TestCls { public static final int CONST_INT = 0xffff; public int[] test() { return new int[] { 127, 129, CONST_INT }; } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne(" int CONST_INT = 65535;") .containsOne("return new int[]{127, 129, CONST_INT};"); } }
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/arrays/TestMultiDimArrayFill.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestMultiDimArrayFill.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestMultiDimArrayFill extends IntegrationTest { public static class TestCls { public static Obj test(int a, int b) { return new Obj( new int[][] { { 1 }, { 2 }, { 3 }, { 4, 5 }, new int[0] }, new int[] { a, a, a, a, b }); } private static class Obj { public Obj(int[][] ints, int[] ints2) { } } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .contains("return new Obj(" + "new int[][]{new int[]{1}, new int[]{2}, new int[]{3}, new int[]{4, 5}, new int[0]}, " + "new int[]{a, a, a, a, 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/arrays/TestArrayInitField2.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayInitField2.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestArrayInitField2 extends SmaliTest { @Test public void test() { forceDecompiledCheck(); assertThat(getClassNodeFromSmali()) .code() .containsOne("static long[] myArr = {1282979400, 0, 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/arrays/TestArrayInitField.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestArrayInitField.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestArrayInitField extends IntegrationTest { public static class TestCls { static byte[] a = new byte[] { 10, 20, 30 }; byte[] b = new byte[] { 40, 50, 60 }; } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("static byte[] a = {10, 20, 30};") .containsOne("byte[] b = {40, 50, 60};"); } }
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/arrays/TestFillArrayData.java
jadx-core/src/test/java/jadx/tests/integration/arrays/TestFillArrayData.java
package jadx.tests.integration.arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestFillArrayData extends SmaliTest { @Test public void test() { assertThat(getClassNodeFromSmaliFiles("TestCls")) .code() .contains("jArr[0] = 1;") .contains("jArr[1] = 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/types/TestGenerics.java
jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestGenerics extends IntegrationTest { public static class TestCls<T> { public T data; public TestCls<T> data(T t) { this.data = t; return this; } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("TestCls<T> data(T t) {"); } @Test public void test2() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("TestCls<T> data(T t) {"); } }
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/types/TestPrimitiveConversion2.java
jadx-core/src/test/java/jadx/tests/integration/types/TestPrimitiveConversion2.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestPrimitiveConversion2 extends SmaliTest { @Test public void test() { disableCompilation(); assertThat(getClassNodeFromSmali()) .code() .containsOne("boolean z2 = !convertedPrice2.code.equals(itemCurrency.code);") .doesNotContain("z2 == 0") .doesNotContain("z2 | 2") .containsOne("(z2 ? 1 : 0) | 2") .containsOne("if (z2 && currency != null) {") .containsOne("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/types/TestTypeResolver8.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver8.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.NotYetImplemented; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver8 extends SmaliTest { // @formatter:off /* public class A {} public class B { public B(A a) { } } public static class TestCls { private A f; public void test() { A x = this.f; if (x != null) { x = new B(x); // different types, type of 'x' can't be resolved } use(x); } private void use(B b) {} } */ // @formatter:on @Test @NotYetImplemented public void test() { assertThat(getClassNodeFromSmaliFiles("types", "TestTypeResolver8", "TestCls")) .code() .containsOne("use(a != null ? new B(a) : 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/types/TestTypeResolver16.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver16.java
package jadx.tests.integration.types; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.function.Function; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; import static java.util.Collections.emptyList; /** * Issue 1002 * Insertion of additional cast (at use place) needed for successful type inference */ public class TestTypeResolver16 extends SmaliTest { @SuppressWarnings("unchecked") public static class TestCls { public final <T, K> List<T> test(List<? extends T> list, Set<? extends T> set, Function<? super T, ? extends K> function) { if (set != null) { List<? extends T> union = list != null ? union(list, set, function) : null; if (union != null) { list = union; } } return list != null ? (List<T>) list : emptyList(); } public static <T, K> List<T> union( Collection<? extends T> collection, Iterable<? extends T> iterable, Function<? super T, ? extends K> function) { return null; } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("(List<T>) listUnion"); } @Test public void testSmali() { assertThat(getClassNodeFromSmali()) .code() .containsOne("(List<T>) listUnion"); } }
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/types/TestTypeResolver3.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver3.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver3 extends IntegrationTest { @SuppressWarnings("UseCompareMethod") public static class TestCls { public int test(String s1, String s2) { int cmp = s2.compareTo(s1); if (cmp != 0) { return cmp; } return s1.length() == s2.length() ? 0 : s1.length() < s2.length() ? -1 : 1; } } @Test public void test() { useJavaInput(); assertThat(getClassNode(TestCls.class)) .code() .containsOneOf( "return s1.length() == s2.length() ? 0 : s1.length() < s2.length() ? -1 : 1;", "return s1.length() < s2.length() ? -1 : 1;"); } @Test public void test2() { 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/types/TestTypeResolver15.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver15.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; /** * Issue 921 (second case) */ public class TestTypeResolver15 extends SmaliTest { public static class TestCls { private void test(boolean z) { useInt(z ? 0 : 8); useInt(!z ? 1 : 0); // replaced with xor in smali test } private void useInt(int i) { } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() // .containsOne("useInt(!z ? 1 : 0);") // TODO: convert to ternary .containsOne("useInt(z ? 0 : 8);"); } @Test public void testSmali() { assertThat(getClassNodeFromSmali()) .code() .containsOne("useInt(z ? 0 : 8);") .containsOne("useInt(!z ? 1 : 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/types/TestTypeResolver18.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver18.java
package jadx.tests.integration.types; import java.io.Closeable; import java.io.IOException; import java.util.concurrent.atomic.AtomicReference; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver18 extends IntegrationTest { public static class TestCls<T> { private final AtomicReference<T> reference = new AtomicReference<>(); public void test() { T t = this.reference.get(); if (t instanceof Closeable) { try { ((Closeable) t).close(); } catch (IOException unused) { // ignore } } this.reference.set(null); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("((Closeable) t).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/types/TestTypeResolver11.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver11.java
package jadx.tests.integration.types; import java.util.Arrays; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver11 extends IntegrationTest { public static class TestCls { public Void test(Object... objects) { int val = (Integer) objects[0]; String str = (String) objects[1]; call(str, str, val, val); return null; } private void call(String a, String b, int... val) { } private boolean test2(String s1, String... args) { String str = Arrays.toString(args); return s1.length() + str.length() > 0; } public void check() { test(1, "str"); assertThat(test2("1", "2", "34")).isTrue(); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("(Integer) objects[0]") .containsOne("String str = (String) objects[1];"); } @Test public void testNoDebug() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("(Integer) objArr[0]") .containsOne("String str = (String) objArr[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/types/TestGenerics7.java
jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics7.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; /** * Issue https://github.com/skylot/jadx/issues/956 */ public class TestGenerics7 extends IntegrationTest { public static class TestCls<T> { private Object[] elements = new Object[1]; @SuppressWarnings("unchecked") public final T test(int i) { Object[] arr = this.elements; T obj = (T) arr[i]; arr[i] = null; if (obj == null) { throw new NullPointerException(); } return obj; } public void check() { this.elements = new Object[] { 1, "" }; assertThat(test(1)).isEqualTo(""); } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("T t = (T) objArr[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/types/TestTypeResolver19.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver19.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; /** * Issue 1407 */ public class TestTypeResolver19 extends SmaliTest { public static class TestCls { public static int[] test(byte[] bArr) { int[] iArr = new int[bArr.length]; for (int i = 0; i < bArr.length; i++) { iArr[i] = bArr[i]; } return iArr; } public static int[] test2(byte[] bArr) { int[] iArr = new int[bArr.length]; for (int i = 0; i < bArr.length; i++) { int i2 = bArr[i]; if (i2 < 0) { i2 = (int) ((long) i2 & 0xFFFF_FFFFL); } iArr[i] = i2; } return iArr; } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("iArr[i] = bArr[i];") .containsOne("iArr[i] = 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/types/TestTypeResolver17.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver17.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; /** * Issue 1197 */ public class TestTypeResolver17 extends SmaliTest { // @formatter:off /* private static String test(Context context, Uri uri, String str, String str2) { Cursor cursor = null; try { cursor = context.getContentResolver().query(uri, new String[]{str}, null, null, null); if (cursor.moveToFirst() && !cursor.isNull(0)) { return cursor.getString(0); } closeQuietly(cursor); return str2; } catch (Exception e) { Log.w("DocumentFile", "Failed query: " + e); return str2; } finally { closeQuietly(cursor); } } */ // @formatter:on @Test public void test() { disableCompilation(); assertThat(getClassNodeFromSmali()) .code() .containsOne("Cursor cursorQuery = null;") .doesNotContain("(AutoCloseable autoCloseable = "); } }
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/types/TestPrimitiveConversion.java
jadx-core/src/test/java/jadx/tests/integration/types/TestPrimitiveConversion.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestPrimitiveConversion extends SmaliTest { // @formatter:off /* public void test(long j, boolean z) { putByte(j, z ? (byte) 1 : (byte) 0); } private static void putByte(long j, byte z) { } */ // @formatter:on @Test public void test() { assertThat(getClassNodeFromSmali()) .code() .doesNotContain("putByte(j, z);") .containsOne("putByte(j, z ? (byte) 1 : (byte) 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/types/TestTypeResolver4.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver4.java
package jadx.tests.integration.types; import java.util.Arrays; 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 TestTypeResolver4 extends IntegrationTest { public static class TestCls { private static String test(byte[] strArray, int offset) { int len = strArray.length; int start = offset + f(strArray, offset); int end = start; while (end + 1 < len && (strArray[end] != 0 || strArray[end + 1] != 0)) { end += 2; } byte[] arr = Arrays.copyOfRange(strArray, start, end); return new String(arr); } private static int f(byte[] strArray, int offset) { return 0; } public void check() { String test = test(("1234" + "utfstr\0\0" + "4567").getBytes(), 4); assertThat(test).isEqualTo("utfstr"); } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("(strArray[end] != 0 || strArray[end + 1] != 0)"); } @Test public void test2() { 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/types/TestGenerics3.java
jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics3.java
package jadx.tests.integration.types; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestGenerics3 extends IntegrationTest { public static class TestCls { public static void test() { List<String> classes = getClasses(); Collections.sort(classes); int passed = 0; for (String cls : classes) { if (runTest(cls)) { passed++; } } int failed = classes.size() - passed; System.out.println("failed: " + failed); } private static boolean runTest(String clsName) { return false; } private static List<String> getClasses() { return new ArrayList<>(); } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("List<String> classes") .containsOne("for (String cls : classes) {"); } @Test public void testNoDebug() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("List<String> classes"); } }
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/types/TestGenerics2.java
jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics2.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestGenerics2 extends SmaliTest { // @formatter:off /* public void test() { Map<Integer, String> map = this.field; useInt(map.size()); for (Map.Entry<Integer, String> entry : map.entrySet()) { useInt(entry.getKey().intValue()); entry.getValue().trim(); } } */ // @formatter:on @Test public void test() { assertThat(getClassNodeFromSmali()) .code() .containsOne("for (Map.Entry<Integer, String> entry : map.entrySet()) {") .containsOne("useInt(entry.getKey().intValue());") // no Integer cast .containsOne("entry.getValue().trim();"); // no String cast } }
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/types/TestArrayTypes.java
jadx-core/src/test/java/jadx/tests/integration/types/TestArrayTypes.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestArrayTypes extends IntegrationTest { public static class TestCls { public void test() { Exception e = new Exception(); System.out.println(e); use(new Object[] { e }); } public void use(Object[] arr) { } public void check() { test(); } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("use(new Object[]{e});"); } @Test public void testNoDebug() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("use(new Object[]{exc});"); } }
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/types/TestTypeResolver13.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver13.java
package jadx.tests.integration.types; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.junit.jupiter.api.Test; import jadx.NotYetImplemented; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver13 extends IntegrationTest { @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") public static class TestCls { private static final Set<?> CONST = new HashSet<>(); private Map<Set<?>, List<?>> map = new HashMap<>(); @SuppressWarnings("unchecked") public <T> List<T> test(Set<T> type) { List<?> obj = this.map.get(type == null ? CONST : type); if (obj != null) { return (List<T>) obj; } return null; } } @NotYetImplemented("additional cast for generic types") @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("public <T> List<T> test(Set<T> type) {") .containsOne("return (List<T>) obj;"); } }
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/types/TestTypeResolver24.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver24.java
package jadx.tests.integration.types; 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 TestTypeResolver24 extends SmaliTest { @SuppressWarnings("DataFlowIssue") public static class TestCls { public void test() { ((T1) null).foo1(); ((T2) null).foo2(); } static class T1 { public void foo1() { } } static class T2 { public void foo2() { } } } @TestWithProfiles({ TestProfile.DX_J8, TestProfile.JAVA8 }) public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("((T1) null).foo1();") .containsOne("((T2) null).foo2();"); } @Test public void testSmali() { assertThat(searchCls(loadFromSmaliFiles(), "Test1")) .code() .containsOne("((T1) null).foo1();") .containsOne("((T2) null).foo2();") .doesNotContain("T1 ") .doesNotContain("T2 "); } }
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/types/TestTypeResolver22.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver22.java
package jadx.tests.integration.types; import java.io.IOException; import java.io.InputStream; 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 TestTypeResolver22 extends IntegrationTest { public static class TestCls { public void test(InputStream input, long count) throws IOException { long pos = input.skip(count); while (pos < count) { pos += input.skip(count - pos); } } } @TestWithProfiles({ TestProfile.JAVA8, TestProfile.DX_J8 }) public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("long pos = "); } }
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/types/TestTypeResolver14.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver14.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver14 extends SmaliTest { // @formatter:off /* public Date test() throws Exception { Date date = null; Long l = null; Cursor query = DBUtil.query(false, (CancellationSignal) null); try { if (query.moveToFirst()) { if (!query.isNull(0)) { l = Long.valueOf(query.getLong(0)); } date = this.this$0.toDate(l); } return date; } finally { query.close(); } } */ // @formatter:on @Test public void test() { disableCompilation(); assertThat(getClassNodeFromSmali()) .code() .doesNotContain("? r2"); } }
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/types/TestGenerics5.java
jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics5.java
package jadx.tests.integration.types; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestGenerics5 extends IntegrationTest { public static class TestCls { private InheritableThreadLocal<Map<String, String>> inheritableThreadLocal; public void test(String key, String val) { if (key == null) { throw new IllegalArgumentException("key cannot be null"); } Map<String, String> map = this.inheritableThreadLocal.get(); if (map == null) { map = new HashMap<>(); this.inheritableThreadLocal.set(map); } map.put(key, val); } public void remove(String key) { Map<String, String> map = this.inheritableThreadLocal.get(); if (map != null) { map.remove(key); } } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .countString(2, "Map<String, String> map = this.inheritableThreadLocal.get();"); } }
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/types/TestTypeResolver6a.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver6a.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestTypeResolver6a extends IntegrationTest { public static class TestCls implements Runnable { public final Runnable runnable; public TestCls(boolean b) { this.runnable = b ? this : makeRunnable(); } public Runnable makeRunnable() { return new Runnable() { @Override public void run() { // do nothing } }; } @Override public void run() { // do nothing } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("this.runnable = b ? this : makeRunnable();"); } @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/types/TestFieldCast.java
jadx-core/src/test/java/jadx/tests/integration/types/TestFieldCast.java
package jadx.tests.integration.types; 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.assertThat; /** * Issue #962 */ public class TestFieldCast extends IntegrationTest { public static class TestCls { public static class A { public boolean publicField; boolean packagePrivateField; protected boolean protectedField; private boolean privateField; } public static class B extends A { public void test() { ((A) this).publicField = false; ((A) this).protectedField = false; ((A) this).packagePrivateField = false; ((A) this).privateField = false; // cast to 'A' needed only here } } public static class C { public void test(B b) { ((A) b).publicField = false; ((A) b).protectedField = false; ((A) b).packagePrivateField = false; ((A) b).privateField = false; // cast to 'A' needed only here } } private static class D { public <T extends B> void test(T t) { ((A) t).publicField = false; ((A) t).protectedField = false; ((A) t).packagePrivateField = false; ((A) t).privateField = false; // cast to 'A' needed only here } } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("((A) this)") .containsOne("((A) b)") .containsOne("((A) t)") .doesNotContain("unused =") .doesNotContain("access modifiers changed"); } }
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/types/TestTypeResolver6.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver6.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestTypeResolver6 extends IntegrationTest { public static class TestCls { public final Object obj; public TestCls(boolean b) { this.obj = b ? this : makeObj(); } public Object makeObj() { return new Object(); } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("this.obj = b ? this : makeObj();"); } @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/types/TestGenerics8.java
jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics8.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestGenerics8 extends IntegrationTest { public static class TestCls<T> { public abstract static class Class2<S extends I1 & I2> extends Parent2<S> { public void test() { S s = get(); s.i1(); s.i2(); } } static class Parent2<T extends I1> { T t; protected T get() { return t; } } interface I1 { void i1(); } interface I2 { void i2(); } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("S s = get();") .containsOne("s.i1();") .containsOne("s.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/types/TestConstTypeInference.java
jadx-core/src/test/java/jadx/tests/integration/types/TestConstTypeInference.java
package jadx.tests.integration.types; 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.assertThat; public class TestConstTypeInference extends IntegrationTest { @SuppressWarnings({ "overrides", "EqualsHashCode" }) public static class TestCls { private final int a; public TestCls() { this(0); } public TestCls(int a) { this.a = a; } public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null) { if (getClass() == obj.getClass()) { TestCls other = (TestCls) obj; return this.a == other.a; } } return false; } public void check() { TestCls seven = new TestCls(7); assertThat(seven).isEqualTo(seven); assertThat(seven).isNotEqualTo(null); TestCls six = new TestCls(6); assertThat(six).isNotEqualTo(seven); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("obj == this") .containsOneOf("obj == null", "obj != null"); } @Test public void test2() { 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/types/TestGenericsInFullInnerCls.java
jadx-core/src/test/java/jadx/tests/integration/types/TestGenericsInFullInnerCls.java
package jadx.tests.integration.types; import java.util.List; import org.junit.jupiter.api.Test; import jadx.api.CommentsLevel; import jadx.core.dex.nodes.ClassNode; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestGenericsInFullInnerCls extends SmaliTest { @Test public void test() { getArgs().setCommentsLevel(CommentsLevel.WARN); List<ClassNode> classNodes = loadFromSmaliFiles(); assertThat(searchCls(classNodes, "types.FieldCls")) .code() .containsOne("private ba<n>.bb<n, n> a;"); assertThat(searchCls(classNodes, "types.test.ba")) .code() .containsOne("public final class ba<S> {") .containsOne("public final class bb<T, V extends n> {") .containsOne("private ba<S> b;") .containsOne("private ba<S>.bb<T, V>.bc<T, V> c;") .containsOne("public final class bc<T, V extends n> {") .containsOne("private ba<S> a;"); } @Test public void testWithDeobf() { enableDeobfuscation(); args.setDeobfuscationMinLength(100); // rename everything getArgs().setCommentsLevel(CommentsLevel.WARN); loadFromSmaliFiles(); // compilation should pass } @Test public void testWithFullNames() { getArgs().setUseImports(false); getArgs().setCommentsLevel(CommentsLevel.WARN); loadFromSmaliFiles(); // compilation 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/types/TestPrimitivesInIf.java
jadx-core/src/test/java/jadx/tests/integration/types/TestPrimitivesInIf.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestPrimitivesInIf extends IntegrationTest { public static class TestCls { public boolean test(String str) { short sh = Short.parseShort(str); int i = Integer.parseInt(str); System.out.println(sh + " vs " + i); return sh == i; } public void check() { assertThat(test("1")).isTrue(); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("short sh = Short.parseShort(str);") .containsOne("int i = Integer.parseInt(str);") .containsOne("return sh == i;"); } @Test public void test2() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("short s = Short.parseShort(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/types/TestConstInline.java
jadx-core/src/test/java/jadx/tests/integration/types/TestConstInline.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestConstInline extends SmaliTest { // @formatter:off /* private static String test(boolean b) { List<String> list; String str; if (b) { list = Collections.emptyList(); str = "1"; } else { list = null; str = list; // not correct assign in java but bytecode allow it } return use(list, str); } private static String use(List<String> list, String str) { return list + str; } */ // @formatter:on @Test public void test() { assertThat(getClassNodeFromSmaliWithPkg("types", "TestConstInline")) .code() .containsOne("list = null;") .containsOne("str = 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/types/TestGenerics4.java
jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics4.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.NotYetImplemented; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestGenerics4 extends IntegrationTest { public static class TestCls { public static class Inner<T> { public void overload(IList<? super T> list) { } public void overload(T t) { } } public interface IList<T> { void list(T t); } public static class ObjIList implements IList<Object> { @Override public void list(Object o) { } } public Inner<Object> test() { Inner<Object> inner = new Inner<>(); inner.overload(new ObjIList()); return inner; } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("public static class ObjIList implements IList<Object> {") .containsOne("Inner<Object> inner = new Inner<>();") .containsOne("inner.overload((IList<? super Object>) new ObjIList());"); } @NotYetImplemented @Test public void testOmitCast() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("inner.overload(new ObjIList());"); } }
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/types/TestTypeResolver.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestTypeResolver extends IntegrationTest { public static class TestCls { public TestCls(int b1, int b2) { // test 'this' move and constructor invocation on moved register this(b1, b2, 0, 0, 0); } public TestCls(int a1, int a2, int a3, int a4, int a5) { } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .contains("this(b1, b2, 0, 0, 0);") .doesNotContain("= this;"); } }
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/types/TestTypeResolver25.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver25.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver25 extends SmaliTest { @Test public void testSmali() { // TODO: type inference error not yet resolved // Check that no stack overflow in type inference for now allowWarnInCode(); disableCompilation(); assertThat(getClassNodeFromSmali()) .code() .oneOf(c -> c.containsOne("t = obj;"), c -> c.containsOne("t = (T) obj;")); } }
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/types/TestTypeResolver5.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver5.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver5 extends SmaliTest { @Test public void test() { disableCompilation(); assertThat(getClassNodeFromSmali()) .code() .doesNotContain("Object string2") .doesNotContain("r1v2"); } }
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/types/TestTypeResolver23.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver23.java
package jadx.tests.integration.types; 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 TestTypeResolver23 extends IntegrationTest { public static class TestCls { public long test(int a) { long v = 1L; if (a == 2) { v = 2L; } else if (a == 3) { v = 3L; } System.out.println(v); return v; } } @TestWithProfiles({ TestProfile.JAVA8, TestProfile.DX_J8 }) public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("long v"); } }
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/types/TestTypeResolver20.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver20.java
package jadx.tests.integration.types; import java.util.Arrays; import java.util.Iterator; import java.util.List; 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; /** * Issue 1238 */ public class TestTypeResolver20 extends SmaliTest { public static class TestCls { public interface Sequence<T> { Iterator<T> iterator(); } public static <T extends Comparable<? super T>> T max(Sequence<? extends T> seq) { Iterator<? extends T> it = seq.iterator(); if (!it.hasNext()) { return null; } T t = it.next(); while (it.hasNext()) { T next = it.next(); if (t.compareTo(next) < 0) { t = next; } } return t; } private static class ArraySeq<T> implements Sequence<T> { private final List<T> list; @SafeVarargs public ArraySeq(T... arr) { this.list = Arrays.asList(arr); } @Override public Iterator<T> iterator() { return list.iterator(); } } public void check() { assertThat(max(new ArraySeq<>(2, 5, 3, 4))).isEqualTo(5); } } @TestWithProfiles({ TestProfile.DX_J8, TestProfile.JAVA8 }) public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("next = next;") .containsOne("T next = it.next();"); } @Test public void testSmali() { assertThat(getClassNodeFromSmaliFiles()) .code() .containsOne("T next = it.next();") .containsOne("T next2 = it.next();"); } }
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/types/TestGenerics6.java
jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics6.java
package jadx.tests.integration.types; import java.util.Iterator; import java.util.Map; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestGenerics6 extends IntegrationTest { public static class TestCls<K, V> implements Iterable<Map.Entry<K, V>> { public V test(K key, V v) { Entry<K, V> entry = get(key); if (entry != null) { return entry.mValue; } put(key, v); return null; } protected Entry<K, V> get(K k) { return null; } protected Entry<K, V> put(K key, V v) { return null; } @Override public Iterator<Map.Entry<K, V>> iterator() { return null; } static class Entry<K, V> implements Map.Entry<K, V> { final V mValue; Entry(K key, V value) { this.mValue = value; } @Override public K getKey() { return null; } @Override public V getValue() { return null; } @Override public V setValue(V value) { return null; } } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("Entry entry = get(k);") .containsOne("Entry<K, V> entry = get(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/types/TestInterfacesCast.java
jadx-core/src/test/java/jadx/tests/integration/types/TestInterfacesCast.java
package jadx.tests.integration.types; import java.io.Closeable; import java.io.IOException; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestInterfacesCast extends IntegrationTest { public static class TestCls { public Runnable test(Closeable obj) throws IOException { return (Runnable) obj; } } @Test public void test() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .containsOne("return (Runnable) closeable;"); } }
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/types/TestTypeResolver2.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver2.java
package jadx.tests.integration.types; import java.io.IOException; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestTypeResolver2 extends IntegrationTest { public static class TestCls { public static boolean test(Object obj) throws IOException { if (obj != null) { return true; } throw new IOException(); } } @Test public void test() { noDebugInfo(); JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("if (obj != 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/types/TestTypeResolver12.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver12.java
package jadx.tests.integration.types; import java.lang.ref.WeakReference; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver12 extends IntegrationTest { public abstract static class TestCls<T> { private WeakReference<T> ref; public void test(String str) { T obj = this.ref.get(); if (obj != null) { call(obj, str); } } public abstract void call(T t, String str); } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("T obj = this.ref.get();"); } @Test public void testNoDebug() { noDebugInfo(); assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("Object obj") .containsOne("T t = this.ref.get();"); } }
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/types/TestTypeResolver9.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver9.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver9 extends IntegrationTest { public static class TestCls { public int test(byte b) { return 16777216 * b; } public int test2(byte[] array, int offset) { return array[offset] * 128 + (array[offset + 1] & 0xFF); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("return 16777216 * b;") .doesNotContain("Byte.MIN_VALUE"); } @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/types/TestTypeResolver10.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver10.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver10 extends SmaliTest { /* * Method argument assigned with different types in separate branches */ @Test public void test() { assertThat(getClassNodeFromSmali()) .code().containsOne("Object test(String str, String str2)") .doesNotContain("Object obj2 = 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/types/TestTypeResolver21.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver21.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.SmaliTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; /** * Issue 1527 */ @SuppressWarnings("CommentedOutCode") public class TestTypeResolver21 extends SmaliTest { // @formatter:off /* public Number test(Object objectArray) { Object[] arr = (Object[]) objectArray; return (Number) arr[0]; } */ // @formatter:on @Test public void test() { assertThat(getClassNodeFromSmali()) .code() .containsOne("Object[] arr = (Object[]) objectArray;"); } }
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/types/TestTypeInheritance.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeInheritance.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import jadx.tests.api.utils.assertj.JadxAssertions; public class TestTypeInheritance extends IntegrationTest { public static class TestCls { public interface IRoot { } public interface IBase extends IRoot { } public static class A implements IBase { } public static class B implements IBase { public void b() { } } public static void test(boolean z) { IBase impl; if (z) { impl = new A(); } else { B b = new B(); b.b(); impl = b; // this move is removed in no-debug byte-code } useBase(impl); useRoot(impl); } private static void useRoot(IRoot root) { } private static void useBase(IBase base) { } } @Test public void test() { JadxAssertions.assertThat(getClassNode(TestCls.class)) .code() .containsOne("IBase impl;") .containsOne("impl = new A();") .containsOne("B b = new B();") .containsOne("impl = b;"); } @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/types/TestTypeResolver7.java
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver7.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestTypeResolver7 extends IntegrationTest { public static class TestCls { public void test(boolean a, boolean b) { Object obj = null; if (a) { use(b ? (Exception) getObj() : (Exception) obj); } else { Runnable r = (Runnable) obj; if (b) { r = (Runnable) getObj(); } use(r); } } private Object getObj() { return null; } private void use(Exception e) { } private void use(Runnable r) { } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .oneOf(c -> c.containsOne("use(b ? (Exception) getObj() : null);"), c -> c.containsOne("use(b ? (Exception) getObj() : (Exception) null);")); } @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/types/TestFieldAccess.java
jadx-core/src/test/java/jadx/tests/integration/types/TestFieldAccess.java
package jadx.tests.integration.types; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestFieldAccess extends IntegrationTest { public static class TestCls { private String field; static <T extends TestCls> T testPut(T t) { ((TestCls) t).field = ""; return t; } static <T extends TestCls> T testGet(T t) { System.out.println(((TestCls) t).field); return t; } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("t.field"); } }
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/deobf/TestRenameOverriddenMethod3.java
jadx-core/src/test/java/jadx/tests/integration/deobf/TestRenameOverriddenMethod3.java
package jadx.tests.integration.deobf; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestRenameOverriddenMethod3 extends IntegrationTest { public static class TestCls { public abstract static class A { public abstract int call(); } public static class B extends A { @Override public final int call() { return 1; } } } @Test public void test() { addMthRename(TestCls.class.getName() + "$A", "call()I", "callRenamed"); assertThat(getClassNode(TestCls.class)) .code() .countString(1, "@Override") .countString(2, "int callRenamed()"); } }
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/deobf/TestFieldFromInnerClass.java
jadx-core/src/test/java/jadx/tests/integration/deobf/TestFieldFromInnerClass.java
package jadx.tests.integration.deobf; import java.util.List; import java.util.Queue; 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 TestFieldFromInnerClass extends IntegrationTest { public static class TestCls<T> { TestCls<T>.I f; public class I { Queue<T> a; Queue<TestCls<T>.I> b; public class X { List<TestCls<T>.I.X> c; } } } @Test public void test() { noDebugInfo(); enableDeobfuscation(); ClassNode cls = getClassNode(TestCls.class); assertThat(cls) .code() .doesNotContain("class I {") .doesNotContain(".I ") .doesNotContain(".I.X>"); } }
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/deobf/TestInheritedMethodRename.java
jadx-core/src/test/java/jadx/tests/integration/deobf/TestInheritedMethodRename.java
package jadx.tests.integration.deobf; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestInheritedMethodRename extends IntegrationTest { public static class TestCls { public static class A extends B { } public static class B { public void call() { System.out.println("call"); } } public void test(A a) { // reference to A.call() not renamed, // should be resolved to B.call() and use alias a.call(); } } @Test public void test() { noDebugInfo(); enableDeobfuscation(); getArgs().setDeobfuscationMinLength(99); assertThat(getClassNode(TestCls.class)) .code() .containsOne("public void m1call() {") .doesNotContain(".call();") .containsOne(".m1call();"); } }
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/deobf/TestMthRename.java
jadx-core/src/test/java/jadx/tests/integration/deobf/TestMthRename.java
package jadx.tests.integration.deobf; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestMthRename extends IntegrationTest { public static class TestCls { public abstract static class TestAbstractCls { public abstract void a(); } public void test(TestAbstractCls a) { a.a(); } } @Test public void test() { noDebugInfo(); enableDeobfuscation(); assertThat(getClassNode(TestCls.class)).code() .doesNotContain("public abstract void a();") .doesNotContain(".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/deobf/TestDontRenameClspOverriddenMethod.java
jadx-core/src/test/java/jadx/tests/integration/deobf/TestDontRenameClspOverriddenMethod.java
package jadx.tests.integration.deobf; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestDontRenameClspOverriddenMethod extends IntegrationTest { public static class TestCls { public static class A implements Runnable { @Override public void run() { } } public static class B extends A { @Override public void run() { } } } @Test public void test() { noDebugInfo(); enableDeobfuscation(); args.setDeobfuscationMinLength(100); // rename everything assertThat(getClassNode(TestCls.class)) .code() .countString(2, "public void run() {"); } }
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/deobf/TestRenameOverriddenMethod.java
jadx-core/src/test/java/jadx/tests/integration/deobf/TestRenameOverriddenMethod.java
package jadx.tests.integration.deobf; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestRenameOverriddenMethod extends IntegrationTest { public static class TestCls { public interface I { void m(); } public static class A implements I { @Override public void m() { } } public static class B extends A { @Override public void m() { } } } @Test public void test() { noDebugInfo(); enableDeobfuscation(); args.setDeobfuscationMinLength(100); // rename everything assertThat(getClassNode(TestCls.class)) .code() .countString(2, "@Override") .countString(3, "/* renamed from: m */") .containsOne("void mo0m();") .countString(2, "public void mo0m() {"); } }
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/deobf/TestRenameOverriddenMethod2.java
jadx-core/src/test/java/jadx/tests/integration/deobf/TestRenameOverriddenMethod2.java
package jadx.tests.integration.deobf; import org.junit.jupiter.api.Test; import jadx.core.dex.attributes.AType; import jadx.core.dex.nodes.ClassNode; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestRenameOverriddenMethod2 extends IntegrationTest { public static class TestCls { public interface I { int call(); } public static class A implements I { @Override public int call() { return 1; } } public static class B implements I { @Override public int call() { return 2; } } } @Test public void test() { enableDeobfuscation(); args.setDeobfuscationMinLength(100); // rename everything ClassNode cls = getClassNode(TestCls.class); assertThat(cls) .code() .countString(2, "@Override") .countString(3, "int mo0call()"); assertThat(searchCls(cls.getInnerClasses(), "I")).isNotNull() .extracting(c -> c.searchMethodByShortName("call")).isNotNull() .extracting(m -> m.get(AType.METHOD_OVERRIDE)).isNotNull() .satisfies(ovrdAttr -> { assertThat(ovrdAttr.getRelatedMthNodes()).hasSize(3); assertThat(ovrdAttr.getOverrideList()).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/deobf/a/TestNegativeRenameCondition.java
jadx-core/src/test/java/jadx/tests/integration/deobf/a/TestNegativeRenameCondition.java
package jadx.tests.integration.deobf.a; import java.util.Collections; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestNegativeRenameCondition extends IntegrationTest { public static class TestCls { @SuppressWarnings("checkstyle:TypeName") public interface a { @SuppressWarnings("checkstyle:MethodName") void a(); } public void test(a a) { a.a(); } } @Test public void test() { noDebugInfo(); enableDeobfuscation(); // disable rename by length args.setDeobfuscationMinLength(0); args.setDeobfuscationMaxLength(999); // disable all renaming options args.setRenameFlags(Collections.emptySet()); assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("renamed from") .containsOne("package jadx.tests.integration.deobf.a;") .containsOne("public interface 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/java8/TestLambdaInArray.java
jadx-core/src/test/java/jadx/tests/integration/java8/TestLambdaInArray.java
package jadx.tests.integration.java8; import java.util.Arrays; import java.util.List; import java.util.function.Function; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestLambdaInArray extends IntegrationTest { public static class TestCls { public List<Function<String, Integer>> test() { return Arrays.asList(this::call1, this::call2); } private Integer call1(String s) { return null; } private Integer call2(String s) { return null; } public void check() throws Exception { assertThat(test()).hasSize(2); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("return Arrays.asList(this::call1, this::call2);"); } }
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/java8/TestLambdaExtVar2.java
jadx-core/src/test/java/jadx/tests/integration/java8/TestLambdaExtVar2.java
package jadx.tests.integration.java8; import java.util.ArrayList; import java.util.Arrays; import java.util.List; 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 TestLambdaExtVar2 extends IntegrationTest { public static class TestCls { public void test(List<String> list) { String space = " "; list.removeIf(s -> s.equals(space) || s.contains(space)); } public void check() { List<String> list = new ArrayList<>(Arrays.asList("a", " ", "b", "r ")); test(list); assertThat(list).isEqualTo(Arrays.asList("a", "b")); } } @TestWithProfiles({ TestProfile.DX_J8, TestProfile.D8_J11, TestProfile.JAVA11 }) public void test() { assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("lambda$") .containsOne("String space = \" \";") .containsOne("s.equals(space) || s.contains(space)"); } }
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/java8/TestLambdaArgs.java
jadx-core/src/test/java/jadx/tests/integration/java8/TestLambdaArgs.java
package jadx.tests.integration.java8; import java.util.function.BiFunction; import java.util.function.Function; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestLambdaArgs extends IntegrationTest { public static class TestCls { public void test1() { call1(a -> -a); } public void test2() { call2((a, b) -> a - b); } private void call1(Function<Integer, Integer> func) { } private void call2(BiFunction<Integer, Integer, Integer> func) { } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .containsOne("call1(a ->") .containsOne("call2((a, 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/java8/TestLambdaInstance.java
jadx-core/src/test/java/jadx/tests/integration/java8/TestLambdaInstance.java
package jadx.tests.integration.java8; import java.util.function.Function; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestLambdaInstance extends IntegrationTest { @SuppressWarnings("Convert2MethodRef") public static class TestCls { public Function<String, Integer> test() { return str -> this.call(str); } public Function<String, Integer> testMthRef() { return this::call; } public Integer call(String str) { return Integer.parseInt(str); } public Function<Integer, String> test2() { return num -> num.toString(); } public Function<Integer, String> testMthRef2() { return Object::toString; } public void check() throws Exception { assertThat(test().apply("11")).isEqualTo(11); assertThat(testMthRef().apply("7")).isEqualTo(7); assertThat(test2().apply(15)).isEqualTo("15"); assertThat(testMthRef2().apply(13)).isEqualTo("13"); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("lambda$") .doesNotContain("renamed") .containsLines(2, "return str -> {", indent() + "return call(str);", "};") // .containsOne("return Object::toString;") // TODO .containsOne("return this::call;"); } @Test public void testNoDebug() { noDebugInfo(); getClassNode(TestCls.class); } @Test public void testFallback() { setFallback(); 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/java8/TestLambdaInstance2.java
jadx-core/src/test/java/jadx/tests/integration/java8/TestLambdaInstance2.java
package jadx.tests.integration.java8; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestLambdaInstance2 extends IntegrationTest { public static class TestCls { private String field; public Runnable test(String str, int i) { return () -> call(str, i); } public void call(String str, int i) { field = str + '=' + i; } public void check() throws Exception { field = ""; test("num", 7).run(); assertThat(field).isEqualTo("num=7"); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("lambda$") .containsOne("call(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/java8/TestLambdaInstance3.java
jadx-core/src/test/java/jadx/tests/integration/java8/TestLambdaInstance3.java
package jadx.tests.integration.java8; import java.util.function.Supplier; import org.junit.jupiter.api.Test; import jadx.tests.api.RaungTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; @SuppressWarnings("DataFlowIssue") public class TestLambdaInstance3 extends RaungTest { public interface TestCls<R> extends Supplier<R> { default TestCls<R> test() { return (TestCls<R> & Memoized) Lazy.of(this)::get; } } public static final class Lazy<T> implements Supplier<T> { public static <T> Lazy<T> of(Supplier<? extends T> supplier) { return null; } @Override public T get() { return null; } } interface Memoized { } @Test public void test() { // some java versions failed to compile usage of interface with '$' in name addClsRename("jadx.tests.integration.java8.TestLambdaInstance3$TestCls", "java8.TestCls"); assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("this::get") .containsOne("return (TestCls) lazyOf::get;"); // TODO: type inference set type for 'lazyOf' to Memoized and cast incorrectly removed // .containsOne("Memoized)"); } @Test public void testRaung() { disableCompilation(); assertThat(getClassNodeFromRaung()) .code() .doesNotContain("this::get") .containsOne(" lazyOf::get"); } }
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/java8/TestLambdaStatic.java
jadx-core/src/test/java/jadx/tests/integration/java8/TestLambdaStatic.java
package jadx.tests.integration.java8; import java.util.concurrent.Callable; import java.util.function.Function; import org.junit.jupiter.api.Test; import jadx.tests.api.IntegrationTest; import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; public class TestLambdaStatic extends IntegrationTest { public static class TestCls { public Callable<String> test1() { return () -> "test"; } public Callable<String> test2(String str) { return () -> str; } public Function<String, Integer> test3(String a) { return (b) -> Integer.parseInt(a) - Integer.parseInt(b); } public Function<String, Integer> test4() { return Integer::parseInt; } @SuppressWarnings("Convert2MethodRef") public Function<String, Integer> test4a() { return s -> Integer.parseInt(s); } public Function<String, Integer> test5() { String str = Integer.toString(3); return (s) -> Integer.parseInt(str) - Integer.parseInt(s); } public void check() throws Exception { assertThat(test1().call()).isEqualTo("test"); assertThat(test2("a").call()).isEqualTo("a"); assertThat(test3("3").apply("1")).isEqualTo(2); assertThat(test4().apply("5")).isEqualTo(5); assertThat(test4a().apply("7")).isEqualTo(7); assertThat(test5().apply("1")).isEqualTo(2); } } @Test public void test() { assertThat(getClassNode(TestCls.class)) .code() .doesNotContain("lambda$") .doesNotContain("renamed") .containsLines(2, "return () -> {", indent() + "return \"test\";", "};") .containsLines(2, "return () -> {", indent() + "return str;", "};") .containsOne("return Integer::parseInt;"); } @Test public void testNoDebug() { noDebugInfo(); getClassNode(TestCls.class); } @Test public void testFallback() { setFallback(); getClassNode(TestCls.class); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false