refactor: remove samples module

This commit is contained in:
Skylot
2021-08-09 17:58:16 +01:00
parent 1efdcd7b10
commit 12a66bd83e
34 changed files with 0 additions and 2690 deletions
-17
View File
@@ -16,12 +16,6 @@ allprojects {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
tasks.withType(JavaCompile) {
if (!"$it".contains(':jadx-samples:')) {
options.compilerArgs << '-Xlint' << '-Xlint:unchecked' << '-Xlint:deprecation'
}
}
compileJava {
options.encoding = "UTF-8"
}
@@ -57,11 +51,6 @@ allprojects {
mavenCentral()
google()
}
checkstyleMain {
// exclude all sources in samples module
exclude '**/samples/**'
}
}
spotless {
@@ -149,15 +138,9 @@ task dist {
}
}
task samples(dependsOn: 'jadx-samples:samples') {
group 'jadx'
}
task cleanBuildDir(type: Delete) {
group 'jadx'
delete buildDir
}
test.dependsOn(samples)
clean.dependsOn(cleanBuildDir)
-54
View File
@@ -1,54 +0,0 @@
project.ext {
mainSamplesClass = 'jadx.samples.RunTests'
samplesJadxSrcDir = "${buildDir}/samples-jadx/src"
samplesJadxOutDir = "${buildDir}/samples-jadx/output"
}
dependencies {
implementation(project(":jadx-cli"))
}
compileJava {
options.compilerArgs << '-g:none'
if (JavaVersion.current() > JavaVersion.VERSION_1_8) {
options.compilerArgs.addAll('--release 8'.split(' '))
}
}
task samplesRun(type: JavaExec, dependsOn: compileJava) {
classpath = sourceSets.main.output
main = mainSamplesClass
}
task samplesJar(type: Jar, dependsOn: samplesRun) {
archivesBaseName = 'samples'
from sourceSets.main.output
}
task samplesJadxCreate(type: JavaExec, dependsOn: samplesJar) {
classpath = sourceSets.main.output + configurations.runtimeClasspath
main = project(":jadx-cli").application.mainClass.get()
args = ['-v', '-d', samplesJadxSrcDir, samplesJar.archiveFile.get()]
}
task samplesJadxCompile(type: JavaCompile, dependsOn: samplesJadxCreate) {
classpath = configurations.runtimeClasspath
destinationDir = file(samplesJadxOutDir)
source = samplesJadxSrcDir
options.encoding = "UTF-8"
}
task samplesJadxRun(type: JavaExec, dependsOn: samplesJadxCompile) {
classpath = files(samplesJadxOutDir)
main = mainSamplesClass
}
task samples(dependsOn: samplesJadxRun) {
}
task cleanGeneratedFiles(type: Delete) {
delete samplesJadxSrcDir
delete samplesJadxOutDir
}
clean.dependsOn cleanGeneratedFiles
@@ -1,50 +0,0 @@
package jadx.samples;
public abstract class AbstractTest {
public abstract boolean testRun() throws Exception;
public static void assertTrue(boolean condition) {
if (!condition) {
throw new AssertionError();
}
}
public static void assertFalse(boolean condition) {
if (condition) {
throw new AssertionError();
}
}
public static void assertTrue(boolean condition, String msg) {
if (!condition) {
throw new AssertionError(msg);
}
}
public static void assertEquals(int a1, int a2) {
if (a1 != a2) {
throw new AssertionError(a1 + " != " + a2);
}
}
public static void assertEquals(float a1, float a2) {
if (Float.compare(a1, a2) != 0) {
throw new AssertionError(a1 + " != " + a2);
}
}
public static void assertEquals(Object a1, Object a2) {
if (a1 == null) {
if (a2 != null) {
throw new AssertionError(a1 + " != " + a2);
}
} else if (!a1.equals(a2)) {
throw new AssertionError(a1 + " != " + a2);
}
}
public static void fail() {
throw new AssertionError();
}
}
@@ -1,114 +0,0 @@
package jadx.samples;
import java.io.File;
import java.io.FilenameFilter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
public class RunTests {
public static void main(String[] args) {
ClassLoader clsLoader = ClassLoader.getSystemClassLoader();
List<String> clsList = getClasses(clsLoader, "jadx.samples");
if (clsList.isEmpty()) {
System.err.println("No tests found");
System.exit(1);
}
int timeout = 2 * clsList.size();
System.err.println("Set timeout to " + timeout + " seconds");
new Timer().schedule(new TerminateTask(), timeout * 1000);
Collections.sort(clsList);
int passed = 0;
for (String cls : clsList) {
if (runTest(cls)) {
passed++;
}
}
int failed = clsList.size() - passed;
System.err.println("---");
System.err.println("Total " + clsList.size()
+ ", Passed: " + passed
+ ", Failed: " + failed);
System.exit(failed);
}
private static boolean runTest(String clsName) {
try {
boolean pass = false;
String msg = null;
Throwable exc = null;
Class<?> cls = Class.forName(clsName);
if (cls.getSuperclass() == AbstractTest.class) {
Method mth = cls.getMethod("testRun");
try {
AbstractTest test = (AbstractTest) cls.getConstructor().newInstance();
pass = (Boolean) mth.invoke(test);
} catch (InvocationTargetException e) {
pass = false;
exc = e.getCause();
} catch (Throwable e) {
pass = false;
exc = e;
}
} else {
msg = "not extends AbstractTest";
}
System.err.println(">> "
+ (pass ? "PASS" : "FAIL") + '\t'
+ clsName
+ (msg == null ? "" : "\t - " + msg));
if (exc != null) {
exc.printStackTrace();
}
return pass;
} catch (ClassNotFoundException e) {
System.err.println("Class '" + clsName + "' not found");
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
private static class TerminateTask extends TimerTask {
@Override
public void run() {
System.err.println("Test timed out");
System.exit(1);
}
}
private static class TestFilter implements FilenameFilter {
@Override
public boolean accept(File dir, String name) {
return name.startsWith("Test") && name.endsWith(".class") && !name.contains("$");
}
}
private static List<String> getClasses(ClassLoader clsLoader, String packageName) {
List<String> clsList = new ArrayList<>();
URL resource = clsLoader.getResource(packageName.replace('.', '/'));
if (resource != null) {
File path = new File(resource.getFile());
if (path.exists() && path.isDirectory()) {
System.out.println("Test classes path: " + path.getAbsolutePath());
String[] files = path.list(new TestFilter());
for (String file : files) {
String clsName = packageName + '.' + file.replace(".class", "");
clsList.add(clsName);
}
}
}
return clsList;
}
}
@@ -1,106 +0,0 @@
package jadx.samples;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.util.Arrays;
public class TestAnnotations extends AbstractTest {
@Deprecated
public int a;
public void error() throws Exception {
throw new Exception("error");
}
@Deprecated
public static Object depr(String[] a) {
return Arrays.asList(a);
}
public @interface SimpleAnnotation {
boolean value();
}
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface MyAnnotation {
String name() default "a";
String str() default "str";
int num();
float value();
double[] doubles();
Class<?> cls();
SimpleAnnotation simple();
Thread.State state() default Thread.State.TERMINATED;
}
@MyAnnotation(
name = "b",
num = 7,
cls = Exception.class,
doubles = { 0.0, 1.1 },
value = 9.87f,
simple = @SimpleAnnotation(false)
)
public static Object test(String[] a) {
return Arrays.asList(a);
}
public static Object test2(@Deprecated String a, @SimpleAnnotation(value = false) Object b) {
@Deprecated
Object c = a;
return c;
}
public @interface ClassesAnnotation {
Class<?>[] value();
}
@ClassesAnnotation(
{
int.class, int[].class, int[][][].class,
String.class, String[].class, String[][].class
}
)
public static Object test3(Object b) {
return b.toString();
}
@Override
public boolean testRun() throws Exception {
Class<?> cls = TestAnnotations.class;
new Thread();
Method err = cls.getMethod("error");
assertTrue(err.getExceptionTypes().length > 0);
assertTrue(err.getExceptionTypes()[0] == Exception.class);
Method d = cls.getMethod("depr", String[].class);
assertTrue(d.getAnnotations().length > 0);
assertTrue(d.getAnnotations()[0].annotationType() == Deprecated.class);
Method ma = cls.getMethod("test", String[].class);
assertTrue(ma.getAnnotations().length > 0);
MyAnnotation a = (MyAnnotation) ma.getAnnotations()[0];
assertTrue(a.num() == 7);
assertTrue(a.state() == Thread.State.TERMINATED);
return true;
}
public static void main(String[] args) throws Exception {
new TestAnnotations().testRun();
}
}
@@ -1,42 +0,0 @@
package jadx.samples;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
public class TestAnnotationsParser extends AbstractTest {
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public static @interface A {
int i();
float f();
}
@A(i = -1, f = C1.FLOAT_CONST)
public static class C1 {
public static final float FLOAT_CONST = 3.14f;
}
@A(i = -1025, f = C2.FLOAT_CONST)
public static class C2 {
public static final float FLOAT_CONST = 0xFF0000;
}
public boolean testRun() {
A c1 = C1.class.getAnnotation(A.class);
assertEquals(c1.i(), -1);
assertEquals(c1.f(), C1.FLOAT_CONST);
A c2 = C2.class.getAnnotation(A.class);
assertEquals(c2.i(), -1025);
assertEquals(c2.f(), C2.FLOAT_CONST);
return true;
}
public static void main(String[] args) throws Exception {
new TestAnnotationsParser().testRun();
}
}
@@ -1,50 +0,0 @@
package jadx.samples;
public class TestArrays extends AbstractTest {
public int test1(int i) {
// fill-array-data
int[] a = new int[] { 1, 2, 3, 5 };
return a[i];
}
public int test2(int i) {
// filled-new-array
int[][] a = new int[i][i + 1];
return a.length;
}
public int test3(int i) {
// filled-new-array/range
boolean[][][][][][][][] a = new boolean[i][i][i][i][i][i][i][i];
return a.length;
}
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;
}
}
@Override
public boolean testRun() throws Exception {
assertEquals(test1(2), 3);
assertEquals(test2(2), 2);
assertEquals(test3(2), 2);
assertTrue(test4(4) instanceof byte[]);
return true;
}
public static void main(String[] args) throws Exception {
new TestArrays().testRun();
}
}
@@ -1,219 +0,0 @@
package jadx.samples;
public class TestCF extends AbstractTest {
public int test1(int a) {
if (a > 0) {
return 1;
} else {
a += 2;
return a * 3;
}
}
public int test1a(int a) {
if (a > 0) {
a++;
}
a *= 2;
return a + 3;
}
public int test1b(int a) {
if (a > 0) {
if (a < 5) {
a++;
} else {
a -= 2;
}
}
a *= 2;
return a + 3;
}
public int test1c(int a, int b) {
if (a > 0) {
long c = 5;
a = (int) (a + c);
} else {
double f = 7.7;
a *= f;
}
return a + b;
}
public int test2(int a, int b) {
int c = a + b;
for (int i = a; i < b; i++) {
c *= 2;
}
c--;
return c;
}
public int test2a(int a, int b) {
int c = a + b;
for (int i = a; i < b; i++) {
if (i == 7) {
c += 2;
} else {
c *= 2;
}
}
c--;
return c;
}
public int test3(int a, int b) {
int c = 0;
for (int i = a; i < b; i++) {
int z = a * i + 5;
if (i == 7) {
c += z + a;
} else {
c *= z + b;
}
}
return c;
}
public int test4(int a, int b) {
int c = 0;
for (int i = a; i < b; i++) {
int z = (i == 7 ? a : b);
c *= z + b;
if (i == 7) {
c += z + a;
} else {
c *= z + b;
}
}
return c;
}
public int test5(int a, int b) {
int c = b;
do {
int z = c + a;
if (z >= 7) {
break;
}
c = z;
} while (true);
return c;
}
public int test6(int a, int b) {
int c = b;
int z;
while ((z = c + a) >= 7) {
c = z;
}
return c;
}
public int test7(int a, int b) {
int c = b;
int z;
do {
z = c + a;
if (z >= 7) {
break;
}
c = z;
} while (true);
while ((z = c + a) >= 7) {
c = z;
}
return c;
}
public int testIfElse(String str) {
int r;
if (str.equals("a")) {
r = 1;
} else if (str.equals("b")) {
r = 2;
} else if (str.equals("3")) {
r = 3;
} else if (str.equals("$")) {
r = 4;
} else {
r = -1;
}
r = r * 10;
return Math.abs(r);
}
public int testIfElse2(String str) {
String a;
if (str.length() == 5) {
a = new String("1");
a.trim();
a.length();
}
a = new String("22");
a.toLowerCase();
return a.length();
}
public void testInfiniteLoop() {
while (true) {
System.out.println("test");
}
}
public static void testHello(String[] args) {
System.out.println("Hello world!");
}
public static void testPrint(String[] args) {
for (String arg : args) {
System.out.println(arg);
}
}
@Override
public boolean testRun() throws Exception {
TestCF c = new TestCF();
assertEquals(c.test1(1), 1);
assertEquals(c.test1(-1), 3);
assertEquals(c.test1a(12), 29);
assertEquals(c.test1b(-1), 1);
assertEquals(c.test1b(3), 11);
assertEquals(c.test1b(12), 23);
assertEquals(c.test1c(-1, 1), -6);
assertEquals(c.test1c(3, 2), 10);
assertEquals(c.test2(2, 4), 23);
assertEquals(c.test2(6, 4), 9);
assertEquals(c.test2a(5, 9), 115);
assertEquals(c.test2a(8, 23), 1015807);
assertEquals(c.test3(5, 9), 2430);
assertEquals(c.test3(8, 23), 0);
assertEquals(c.test4(5, 9), 3240);
assertEquals(c.test4(8, 15), 0);
assertEquals(c.testIfElse("b"), 20);
assertEquals(c.testIfElse("c"), 10);
assertEquals(c.testIfElse2("12345"), 2);
return true;
}
public static void main(String[] args) throws Exception {
System.out.println("TestCF: " + new TestCF().testRun());
}
}
@@ -1,117 +0,0 @@
package jadx.samples;
public class TestCF2 extends AbstractTest {
private final Object readyMutex = new Object();
private boolean ready = false;
public int simpleLoops() throws InterruptedException {
int[] a = new int[]{1, 2, 4, 6, 8};
int b = 0;
for (int i = 0; i < a.length; i++) {
b += a[i];
}
for (long i = b; i > 0; i--) {
b += i;
}
return b;
}
/**
* Test infinite loop
*/
public void run() throws InterruptedException {
while (true) {
if (!ready) {
readyMutex.wait();
}
ready = false;
func();
}
}
private void func() {
ready = true;
}
public void doWhile() throws InterruptedException {
int i = 3;
do {
func();
i++;
} while (i < 5);
}
public void doWhile2(long k) throws InterruptedException {
if (k > 5) {
long i = 3;
do {
func();
i++;
} while (i < 5);
}
}
public void doWhile3(int k) throws InterruptedException {
int i = 3;
do {
if (k > 9) {
func();
}
i++;
} while (i < 5);
}
public int doWhileBreak(int k) throws InterruptedException {
int i = 3;
do {
if (k > 9) {
i = 0;
break;
}
i++;
} while (i < 5);
return i;
}
public int doWhileContinue(int k) throws InterruptedException {
int i = 0;
do {
if (k > 9) {
i = k + 1;
continue;
}
i++;
} while (i < k);
return i;
}
public void doWhileReturn2(boolean k) throws InterruptedException {
int i = 3;
do {
if (k) {
return;
}
i++;
} while (i < 5);
}
public void whileIterator(String[] args, int k) throws InterruptedException {
for (String arg : args) {
if (arg.length() > 9) {
func();
}
}
}
@Override
public boolean testRun() throws Exception {
assertEquals(simpleLoops(), 252);
// TODO add checks
return true;
}
public static void main(String[] args) throws Exception {
System.out.println("TestCF2: " + new TestCF2().testRun());
}
}
@@ -1,255 +0,0 @@
package jadx.samples;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class TestCF3 extends AbstractTest {
public String f = "str//ing";
private boolean enabled;
private void setEnabled(boolean b) {
this.enabled = b;
}
private int next() {
return 1;
}
private int exc() throws Exception {
return 1;
}
public void testSwitchInLoop() throws Exception {
while (true) {
int n = next();
switch (n) {
case 0:
setEnabled(false);
break;
case 1:
setEnabled(true);
return;
}
}
}
private void testIfInLoop() {
int j = 0;
for (int i = 0; i < f.length(); i++) {
char ch = f.charAt(i);
if (ch == '/') {
j++;
if (j == 2) {
setEnabled(true);
return;
}
}
}
setEnabled(false);
}
public boolean testNestedLoops(List<String> l1, List<String> l2) {
Iterator<String> it1 = l1.iterator();
while (it1.hasNext()) {
String s1 = it1.next();
Iterator<String> it2 = l2.iterator();
while (it2.hasNext()) {
String s2 = it2.next();
if (s1.equals(s2)) {
if (s1.length() == 5) {
l2.add(s1);
} else {
l1.remove(s2);
}
}
}
}
if (l2.size() > 0) {
l1.clear();
}
return l1.size() == 0;
}
public boolean testNestedLoops2(List<String> list) {
int i = 0;
int j = 0;
while (i < list.size()) {
String s = list.get(i);
while (j < s.length()) {
j++;
}
i++;
}
return j > 10;
}
private int testLoops(int[] a, int b) {
int i = 0;
while (i < a.length && i < b) {
a[i]++;
i++;
}
while (i < a.length) {
a[i]--;
i++;
}
int sum = 0;
for (int e : a) {
sum += e;
}
return sum;
}
public static boolean testLabeledBreakContinue() {
String searchMe = "Look for a substring in me";
String substring = "sub";
boolean foundIt = false;
// int max = searchMe.length() - substring.length();
// test: for (int i = 0; i <= max; i++) {
// int n = substring.length();
// int j = i;
// int k = 0;
// while (n-- != 0) {
// if (searchMe.charAt(j++) != substring.charAt(k++)) {
// continue test;
// }
// }
// foundIt = true;
// break test;
// }
// System.out.println(foundIt ? "Found it" : "Didn't find it");
return foundIt;
}
public String testReturnInLoop(List<String> list) {
Iterator<String> it = list.iterator();
while (it.hasNext()) {
String ver = it.next();
if (ver != null) {
return ver;
}
}
return "error";
}
public String testReturnInLoop2(List<String> list) {
try {
Iterator<String> it = list.iterator();
while (it.hasNext()) {
String ver = it.next();
exc();
if (ver != null) {
return ver;
}
}
} catch (Exception e) {
setEnabled(false);
}
return "error";
}
public int testComplexIfInLoop(boolean a) {
int i = 0;
while (a && i < 10) {
i++;
}
return i;
}
public int testComplexIfInLoop2(int k) {
int i = k;
while (i > 5 && i < 10) {
i++;
}
return i;
}
public int testComplexIfInLoop3(int k) {
int i = k;
while (i > 5 && i < k * 3) {
if (k == 8) {
i++;
} else {
break;
}
}
return i;
}
private void f() {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// ignore
}
}
public long testInline() {
long l = System.nanoTime();
f();
return System.nanoTime() - l;
}
private int f2 = 1;
public void func() {
this.f2++;
}
public boolean testInline2() {
int a = this.f2;
func();
return a != this.f2;
}
@Override
public boolean testRun() throws Exception {
setEnabled(false);
testSwitchInLoop();
assertTrue(enabled);
setEnabled(false);
testIfInLoop();
assertTrue(enabled);
assertTrue(testNestedLoops(
new ArrayList<>(Arrays.asList("a1", "a2")),
new ArrayList<>(Arrays.asList("a1", "b2"))));
List<String> list1 = Arrays.asList(null, "a", "b");
assertEquals(testReturnInLoop(list1), "a");
assertEquals(testReturnInLoop2(list1), "a");
// TODO this line required to omit generic information because it create List<Object>
// List<String> list2 = Arrays.asList(null, null, null);
// assertEquals(testReturnInLoop(list2), "error");
// assertEquals(testReturnInLoop2(list2), "error");
// assertTrue(testLabeledBreakContinue());
assertEquals(testComplexIfInLoop(false), 0);
assertEquals(testComplexIfInLoop(true), 10);
assertEquals(testComplexIfInLoop2(2), 2);
assertEquals(testComplexIfInLoop2(6), 10);
assertEquals(testComplexIfInLoop3(2), 2);
assertEquals(testComplexIfInLoop3(6), 6);
assertEquals(testComplexIfInLoop3(8), 24);
assertEquals(testLoops(new int[] { 1, 2, 3, 4, 5, 6 }, 2), 19);
assertTrue(testInline() > 20);
assertTrue(testInline2());
return true;
}
public static void main(String[] args) throws Exception {
new TestCF3().testRun();
}
}
@@ -1,48 +0,0 @@
package jadx.samples;
public class TestCF4 extends AbstractTest {
int c;
String d;
String f;
public void testComplexIf(String a, int b) {
if (d == null || (c == 0 && b != -1 && d.length() == 0)) {
c = a.codePointAt(c);
} else {
if (a.length() != 2) {
c = f.compareTo(a);
}
}
}
public void checkComplexIf() {
d = null;
f = null;
c = 2;
testComplexIf("abcdef", 0);
assertEquals(c, 'c');
d = "";
f = null;
c = 0;
testComplexIf("abcdef", 0);
assertEquals(c, 'a');
d = "";
f = "1";
c = 777;
testComplexIf("ab", -1);
assertEquals(c, 777);
}
@Override
public boolean testRun() throws Exception {
checkComplexIf();
return true;
}
public static void main(String[] args) throws Exception {
new TestCF4().testRun();
}
}
@@ -1,101 +0,0 @@
package jadx.samples;
public class TestConditions extends AbstractTest {
public int test1(int num) {
boolean inRange = (num >= 59 && num <= 66);
if (inRange) {
num++;
}
return num;
}
public int test1a(int num) {
boolean notInRange = (num < 59 || num > 66);
if (notInRange) {
num--;
}
return num;
}
public int test1b(int num) {
boolean inc = (num >= 59 && num <= 66 && num != 62);
if (inc) {
num++;
}
return num;
}
public boolean test1c(int num) {
return num == 4 || num == 6;
}
public boolean test2(int num) {
if (num == 4 || num == 6) {
return String.valueOf(num).equals("4");
}
if (num == 5) {
return true;
}
return this.toString().equals("a");
}
public void test3(boolean a, boolean b) {
if (a || b) {
throw new RuntimeException();
}
test1(0);
}
public void test4(int num) {
if (num == 4 || num == 6 || num == 8 || num == 10) {
accept("a");
}
}
public boolean test5(int num) {
return num > 5 && (num < 10 || num == 7);
}
private boolean test6(boolean a, boolean b, boolean c) {
return (a && b) || c;
}
public boolean accept(String name) {
return name.startsWith("Test") && name.endsWith(".class") && !name.contains("$");
}
@Override
public boolean testRun() throws Exception {
assertEquals(test1(50), 50);
assertEquals(test1(60), 61);
assertEquals(test1a(50), 49);
assertEquals(test1a(60), 60);
assertEquals(test1b(60), 61);
assertEquals(test1b(62), 62);
assertTrue(test1c(4));
assertFalse(test1c(5));
assertTrue(accept("Test.class"));
test3(false, false);
assertFalse(test5(4));
assertFalse(test5(11));
assertTrue(test5(6));
assertTrue(test5(7));
assertTrue(test5(8));
assertTrue(test6(true, true, false));
assertTrue(test6(false, false, true));
assertFalse(test6(true, false, false));
return true;
}
public static void main(String[] args) throws Exception {
new TestConditions().testRun();
}
}
@@ -1,16 +0,0 @@
package jadx.samples;
public class TestDeadCode extends AbstractTest {
private void test1(int i) {
if (i == 0) {
return;
}
return;
}
@Override
public boolean testRun() throws Exception {
return true;
}
}
@@ -1,152 +0,0 @@
package jadx.samples;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class TestEnum extends AbstractTest {
public enum Direction {
NORTH, SOUTH, EAST, WEST
}
public static final String DOG = "DOG";
public enum Animal {
CAT, DOG
}
private static int three = 3;
public enum Numbers {
ONE(1), TWO(2), THREE(three), FOUR(three + 1);
private final int num;
private Numbers(int n) {
this.num = n;
}
public int getNum() {
return num;
}
}
public enum Operation {
PLUS {
@Override
int apply(int x, int y) {
return x + y;
}
},
MINUS {
@Override
int apply(int x, int y) {
return x - y;
}
};
abstract int apply(int x, int y);
}
public interface IOps {
double apply(double x, double y);
}
public enum DoubleOperations implements IOps {
TIMES("*") {
@Override
public double apply(double x, double y) {
return x * y;
}
},
DIVIDE("/") {
@Override
public double apply(double x, double y) {
return x / y;
}
};
private final String op;
private DoubleOperations(String op) {
this.op = op;
}
public String getOp() {
return op;
}
}
public enum Types {
INT, FLOAT,
LONG, DOUBLE,
OBJECT, ARRAY;
private static Set<Types> primitives = EnumSet.of(INT, FLOAT, LONG, DOUBLE);
public static List<Types> references = new ArrayList<>();
static {
references.add(OBJECT);
references.add(ARRAY);
}
public static Set<Types> getPrimitives() {
return primitives;
}
}
@SuppressWarnings("NoWhitespaceBefore")
public enum EmptyEnum {
;
public static String getOp() {
return "op";
}
}
public enum Singleton {
INSTANCE;
public String test(String arg) {
return arg.concat("test");
}
}
public String testEnumSwitch(final Direction color) {
String d;
switch (color) {
case NORTH:
d = "N";
break;
case SOUTH:
d = "S";
break;
default:
d = "<>";
break;
}
return d;
}
@Override
public boolean testRun() throws Exception {
Direction d = Direction.EAST;
assertTrue(d.toString().equals("EAST"));
assertTrue(d.ordinal() == 2);
assertTrue(Numbers.THREE.getNum() == 3);
assertTrue(Operation.PLUS.apply(2, 2) == 4);
assertTrue(DoubleOperations.TIMES.apply(1, 1) == 1);
assertTrue(Types.getPrimitives().contains(Types.INT));
assertTrue(Types.references.size() == 2);
assertTrue(EmptyEnum.values().length == 0);
assertTrue(EmptyEnum.getOp().equals("op"));
assertTrue(Singleton.INSTANCE.test("a").equals("atest"));
return true;
}
public static void main(String[] args) throws Exception {
new TestEnum().testRun();
}
}
@@ -1,48 +0,0 @@
package jadx.samples;
import java.util.Arrays;
@SuppressWarnings("ConstantName")
public class TestFields extends AbstractTest {
public static class ConstFields {
public static final boolean BOOL = false;
public static final int CONST_INT = 56789;
public static final int ZERO = 0;
public static final String STR = "string";
public static final double PI = 3.14;
}
private static final boolean fbz = false;
private static final boolean fb = true;
private static final int fi = 5;
private static final int fiz = 0;
private static final String fstr = "final string";
private static final double fd = 3.14;
private static final double[] fda = new double[] { 3.14, 2.7 };
private static int si = 5;
public void testConstsFields() {
int r = ConstFields.CONST_INT;
r += ConstFields.BOOL ? 1 : 0;
r += ConstFields.ZERO * 5;
r += ConstFields.STR.length() + ConstFields.STR.indexOf('i');
r += Math.round(ConstFields.PI);
assertEquals(r, 56801);
}
@Override
public boolean testRun() throws Exception {
testConstsFields();
String str = "" + fbz + fiz + fb + fi + fstr + fd + Arrays.toString(fda) + si;
return str.equals("false0true5final string3.14[3.14, 2.7]5");
}
public static void main(String[] args) throws Exception {
new TestFields().testRun();
}
}
@@ -1,197 +0,0 @@
package jadx.samples;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TestGenerics extends AbstractTest {
public List<String> strings;
public Class<?>[] classes;
public interface MyComparable<T> {
int compareTo(T o);
}
public static class GenericClass implements MyComparable<String> {
@Override
public int compareTo(String o) {
return 0;
}
}
public static class Box<T> {
private T t;
public void set(T t) {
this.t = t;
}
public T get() {
return t;
}
}
public static Box<Integer> integerBox = new Box<>();
@SuppressWarnings("InterfaceTypeParameterName")
public interface Pair<K, LongGenericType> {
K getKey();
LongGenericType getValue();
}
public static class OrderedPair<K, V> implements Pair<K, V> {
private final K key;
private final V value;
public OrderedPair(K key, V value) {
this.key = key;
this.value = value;
}
@Override
public K getKey() {
return key;
}
@Override
public V getValue() {
return value;
}
}
Pair<String, Integer> p1 = new OrderedPair<>("8", 8);
OrderedPair<String, Box<Integer>> p = new OrderedPair<>("primes", new Box<Integer>());
public static class Util {
// Generic static method
public static <K, V> boolean compare(Pair<K, V> p1, Pair<K, V> p2) {
return p1.getKey().equals(p2.getKey())
&& p1.getValue().equals(p2.getValue());
}
}
public static boolean use() {
Pair<Integer, String> p1 = new OrderedPair<>(1, "str1");
Pair<Integer, String> p2 = new OrderedPair<>(2, "str2");
boolean same = Util.<Integer, String>compare(p1, p2);
return same;
}
public class NaturalNumber<T extends Integer> {
private final T n;
public NaturalNumber(T n) {
this.n = n;
}
public boolean isEven() {
return n.intValue() % 2 == 0;
}
}
class A {
}
interface B {
}
interface C {
}
class D<T extends A & B & C> {
}
public static <T extends Comparable<T>> int countGreaterThan(T[] anArray, T elem) {
int count = 0;
for (T e : anArray) {
if (e.compareTo(elem) > 0) {
++count;
}
}
return count;
}
public static void process(List<? extends A> list) {
}
public static void printList(List<?> list) {
for (Object elem : list) {
System.out.print(elem + " ");
}
System.out.println();
}
public static void addNumbers(List<? super Integer> list) {
for (int i = 1; i <= 10; i++) {
list.add(i);
}
}
public class Node<T extends Comparable<T>> {
private final T data;
public final Node<T> next;
public Node(T data, Node<T> next) {
this.data = data;
this.next = next;
}
public T getData() {
return data;
}
}
public class TestConstructor implements Enumeration<String> {
public final TestGenerics a;
TestConstructor(TestGenerics a) {
this.a = a;
}
@Override
public boolean hasMoreElements() {
return false;
}
@Override
public String nextElement() {
return null;
}
}
public Enumeration<String> testThis() {
return new TestConstructor(this);
}
private List<String> test1(Map<String, String> map) {
List<String> list = new ArrayList<>();
String str = map.get("key");
list.add(str);
return list;
}
public void test2(Map<String, String> map, List<Object> list) {
String str = map.get("key");
list.add(str);
}
public void test3(List<Object> list, int a, float[] b, String[] c, String[][][] d) {
}
@Override
public boolean testRun() throws Exception {
assertTrue(test1(new HashMap<String, String>()) != null);
// TODO: add other checks
return true;
}
public static void main(String[] args) throws Exception {
new TestGenerics().testRun();
}
}
@@ -1,25 +0,0 @@
package jadx.samples;
import jadx.samples.otherpkg.A;
/**
* Tests:
* - class B not imported
*/
public class TestImports extends AbstractTest {
public class C extends A {
public B getB() {
return null;
}
}
@Override
public boolean testRun() {
return true;
}
public static void main(String[] args) {
new TestImports().testRun();
}
}
@@ -1,40 +0,0 @@
package jadx.samples;
import jadx.samples.otherpkg.C.E;
import jadx.samples.otherpkg.D;
public class TestImports2 extends AbstractTest {
public Object f1() {
return new E() {
@Override
public String toString() {
return "C.E";
}
};
}
public Object f2() {
return new D.E() {
@Override
public String toString() {
return "D.E";
}
};
}
public static class X1 extends E {
}
public static class X2 extends D.E {
}
@Override
public boolean testRun() {
return true;
}
public static void main(String[] args) {
new TestImports2().testRun();
}
}
@@ -1,103 +0,0 @@
package jadx.samples;
public class TestInitializers extends AbstractTest {
private static String a;
private static int counter;
private A cA;
public static class A {
public static String a;
static {
a = "a1";
}
public boolean z() {
return true;
}
}
public class B {
private int b;
private int bbb;
public B() {
if (cA.z()) {
b = -1;
} else {
b = 1;
}
}
public B(int pb) {
b = pb;
}
public void setB(int pb) {
b = pb;
}
public int getB() {
return b;
}
public int getBBB() {
return bbb;
}
{
bbb = 123;
}
}
static {
a = "a0";
counter = 0;
}
{
cA = new A();
}
@Override
public boolean testRun() throws Exception {
assertTrue(counter == 0);
assertTrue(a.equals("a0"));
assertTrue(A.a.equals("a1"));
B b1 = new B() {
{
TestInitializers.counter++;
setB(TestInitializers.counter);
}
};
assertTrue(b1.getB() == 1);
B b2 = new B() {
@SuppressWarnings("unused")
private int bb;
public int getB() {
return super.getB();
}
{
bb = 100;
}
};
assertTrue(b2.getB() == -1);
assertTrue((new B()).getB() == -1);
assertTrue(counter == 1);
B b3 = new B(3);
assertTrue((b3.getB() == 3) && (b3.getBBB() == 123));
return true;
}
public static void main(String[] args) throws Exception {
new TestInitializers().testRun();
}
}
@@ -1,116 +0,0 @@
package jadx.samples;
public class TestInner extends AbstractTest {
public static int count = -2;
public static class MyThread extends Thread {
public MyThread(String name) {
super(name);
}
@Override
public void run() {
count++;
super.run();
}
}
public static class MyInceptionThread extends MyThread {
public static class MyThread2 extends Thread {
@Override
public void run() {
count += 2;
}
}
public MyInceptionThread() {
super("MyInceptionThread");
}
@Override
public void run() {
MyThread2 thr = new MyThread2();
thr.start();
try {
thr.join();
} catch (InterruptedException e) {
assertTrue(false);
}
}
}
public void func() {
new Runnable() {
@Override
public void run() {
count += 4;
}
}.run();
}
public void func2() {
new Runnable() {
{
count += 5;
}
@Override
public void run() {
count += 6;
}
}.run();
}
public String func3() {
return new Object() {
{
count += 7;
}
@Override
public String toString() {
count += 8;
return Integer.toString(count);
}
}.toString();
}
@SuppressWarnings("serial")
public static class MyException extends Exception {
public MyException(String str, Exception e) {
super("msg:" + str, e);
}
}
@Override
public boolean testRun() throws Exception {
TestInner c = new TestInner();
TestInner.count = 0;
c.func();
c.func2();
Runnable myRunnable = new Runnable() {
@Override
public void run() {
TestInner.count += 8;
}
};
myRunnable.run();
MyThread thread = new TestInner.MyThread("my thread");
thread.start();
MyInceptionThread thread2 = new TestInner.MyInceptionThread();
thread2.start();
thread.join();
thread2.join();
assertEquals(func3(), "41");
return TestInner.count == 41;
}
}
@@ -1,87 +0,0 @@
package jadx.samples;
import java.lang.reflect.Method;
public class TestInner2 extends AbstractTest {
private String a;
public class A {
public A() {
a = "a";
}
public String a() {
return a;
}
}
private static String b;
public static class B {
public B() {
b = "b";
}
public String b() {
return b;
}
}
private String c;
private void setC(String c) {
this.c = c;
}
public class C {
public String c() {
setC("c");
return c;
}
}
private static String d;
private static void setD(String s) {
d = s;
}
public static class D {
public String d() {
setD("d");
return d;
}
}
// value from java.lang.reflect.Modifier
static final int SYNTHETIC = 0x00001000;
@Override
public boolean testRun() throws Exception {
assertTrue((new A()).a().equals("a"));
assertTrue(a.equals("a"));
assertTrue((new B()).b().equals("b"));
assertTrue(b.equals("b"));
assertTrue((new C()).c().equals("c"));
assertTrue(c.equals("c"));
assertTrue((new D()).d().equals("d"));
assertTrue(d.equals("d"));
Method[] mths = TestInner2.class.getDeclaredMethods();
for (Method mth : mths) {
if (mth.getName().startsWith("access$")) {
int modifiers = mth.getModifiers();
assertTrue((modifiers & SYNTHETIC) != 0, "Synthetic methods must be removed");
}
}
return true;
}
public static void main(String[] args) throws Exception {
new TestInner2().testRun();
}
}
@@ -1,85 +0,0 @@
package jadx.samples;
public class TestInner3 extends AbstractTest {
private String i0;
public class A {
protected String a;
public A() {
a = "";
}
public String a() {
return "";
}
}
public class I0 {
private String i0;
private String i1;
public class I1 {
private String i0;
private String i1;
private String i2;
public I1() {
TestInner3.this.i0 = "i0";
I0.this.i0 = "i1";
I0.this.i1 = "i2";
i0 = "i0";
i1 = "i1";
i2 = "i2";
}
public String i() {
String result = TestInner3.this.i0 + I0.this.i0 + I0.this.i1 + i0 + i1 + i2;
A a = new A() {
public String a() {
TestInner3.this.i0 = "i1";
I0.this.i0 = "i2";
I0.this.i1 = "i3";
I1.this.i0 = "i1";
I1.this.i1 = "i2";
I1.this.i2 = "i3";
a = "a";
return TestInner3.this.i0 + I0.this.i0 + I0.this.i1 + I1.this.i0 + I1.this.i1 + I1.this.i2 + a;
}
};
return result + a.a();
}
}
public I0() {
TestInner3.this.i0 = "i-";
i0 = "i0";
i1 = "i1";
}
public String i() {
String result = TestInner3.this.i0 + i0 + i1;
return result + (new I1()).i();
}
}
@Override
public boolean testRun() throws Exception {
assertTrue((new I0()).i().equals("i-i0i1i0i1i2i0i1i2i1i2i3i1i2i3a"));
assertTrue(i0.equals("i1"));
return true;
}
public static void main(String[] args) throws Exception {
new TestInner2().testRun();
}
}
@@ -1,37 +0,0 @@
package jadx.samples;
public class TestInnerNames extends AbstractTest {
@SuppressWarnings("MemberName")
public int D;
public class A extends TestInner.MyThread {
public A(String name) {
super(name);
}
}
public class B extends A {
public B(String name) {
super(name);
}
public class C extends TestInner2.B {
}
}
public class C extends TestInner2.B {
}
public class D extends TestInner2.D {
}
@Override
public boolean testRun() throws Exception {
return true;
}
public static void main(String[] args) throws Exception {
new TestInnerNames().testRun();
}
}
@@ -1,67 +0,0 @@
package jadx.samples;
import java.util.Arrays;
public class TestInvoke extends AbstractTest {
private int f;
public TestInvoke() {
this(-1);
}
public TestInvoke(int f) {
this.f = f;
}
private void parse(String[] args) {
if (args.length > 0) {
f = Integer.parseInt(args[0]);
} else {
f = 20;
}
}
public int getF() {
return f;
}
private boolean testVarArgs(String s1, String... args) {
String str = Arrays.toString(args);
return s1.length() + str.length() > 0;
}
private String testVarArgs2(char[]... args) {
String s = "";
for (char[] ca : args) {
s += new String(ca);
}
return s;
}
private String testSameArgTypes(String s1, String s2) {
if (s1.equals(s2)) {
return null;
}
return s1;
}
@Override
public boolean testRun() throws Exception {
TestInvoke inv = new TestInvoke();
inv.parse(new String[] { "12", "35" });
assertTrue(inv.getF() == 12);
inv.parse(new String[0]);
assertTrue(inv.getF() == 20);
assertTrue(inv.testVarArgs("a", "2", "III"));
assertTrue(inv.testVarArgs2("a".toCharArray(), new char[] { '1', '2' }).equals("a12"));
assertEquals(testSameArgTypes("a", "b"), "a");
return true;
}
public static void main(String[] args) throws Exception {
new TestInvoke().testRun();
}
}
@@ -1,25 +0,0 @@
package jadx.samples;
public class TestStringProcessing extends AbstractTest {
@SuppressWarnings("AvoidEscapedUnicodeCharacters")
public void testStringEscape() {
String str = "test\tstr\n";
assertTrue(str.length() == 9);
str = "test\bunicode\u1234";
assertTrue(str.charAt(4) == '\b');
}
public void testStringConcat() {
String s = "1";
assertEquals('a' + s, "a1");
}
@Override
public boolean testRun() throws Exception {
testStringEscape();
testStringConcat();
return true;
}
}
@@ -1,123 +0,0 @@
package jadx.samples;
public class TestSwitch extends AbstractTest {
public static int test1(int i) {
int k = i * 4;
switch (k) {
case 1:
return 0;
case 10:
return 1;
case 100:
return 2;
case 1000:
return 3;
}
i -= 77;
return i;
}
public static int test2(int i) {
int k = i;
switch (k) {
case 1:
return 0;
case 2:
return 1;
case 3:
return 2;
case 5:
return 3;
case 7:
return 4;
case 9:
return 5;
}
i /= 2;
return -i;
}
public static int test3(int i, int j) {
int k = i;
switch (k) {
case 1:
if (j == 0) {
return 0;
} else {
return -1;
}
case 2:
return 1;
}
return -1;
}
public static int test4(int i) {
int k = i;
switch (k) {
case 1:
throw new RuntimeException("test4");
case 2:
return 1;
}
return -1;
}
@SuppressWarnings("fallthrough")
public static int test5(int i, int b) {
int k = i;
switch (k) {
case 1:
if (b == 0) {
return 3;
}
case 2:
b++;
return b;
}
return -1;
}
public String escape(String str) {
int len = str.length();
StringBuilder sb = new StringBuilder(len);
for (int i = 0; i < len; i++) {
char c = str.charAt(i);
switch (c) {
case '.':
case '/':
sb.append('_');
break;
case ']':
sb.append('A');
break;
case '?':
break;
default:
sb.append(c);
break;
}
}
return sb.toString();
}
@Override
public boolean testRun() {
assertTrue(test1(25) == 2);
assertTrue(test2(5) == 3);
assertTrue(test3(1, 0) == 0);
assertTrue(test4(2) == 1);
assertEquals(escape("a.b/c]d?e"), "a_b_cAde");
return true;
}
public static void main(String[] args) {
new TestSwitch().testRun();
}
}
@@ -1,227 +0,0 @@
package jadx.samples;
import java.io.IOException;
public class TestTryCatch extends AbstractTest {
private static boolean exc(Object obj) throws Exception {
if (obj == null) {
throw new Exception("test");
}
return (obj instanceof Object);
}
private static boolean exc2(Object obj) throws IOException {
if (obj == null) {
throw new IOException();
}
return true;
}
private static boolean test0(Object obj) {
try {
synchronized (obj) {
obj.wait(5);
}
} catch (InterruptedException e) {
return false;
}
return true;
}
private static boolean test1(Object obj) {
boolean res = false;
try {
res = exc(obj);
} catch (Exception e) {
return false;
}
return res;
}
private static boolean test2(Object obj) {
try {
return exc(obj);
} catch (Exception e) {
if (obj != null) {
return true;
} else {
return false;
}
}
}
private static boolean test3(Object obj) {
boolean res = false;
try {
res = exc(obj);
} catch (Exception e) {
res = false;
} finally {
test0(obj);
}
return res;
}
private static String test4(Object obj) {
String res = "good";
try {
res += exc(obj);
exc2("a");
} catch (IOException e) {
res = "io exc";
} catch (Exception e) {
res = "exc";
}
return res;
}
private static String test5(Object obj) {
String res = "good";
try {
res = "" + exc(obj);
boolean f = exc2("a");
if (!f) {
res = "f == false";
}
} catch (Exception e) {
res = "exc";
}
return res;
}
private static boolean test6(Object obj) {
boolean res = false;
while (true) {
try {
res = exc2(obj);
return res;
} catch (IOException e) {
res = true;
} catch (Throwable e) {
if (obj == null) {
obj = new Object();
}
}
}
}
private static boolean test7() {
boolean res = false;
Object obj = null;
while (true) {
try {
res = exc2(obj);
return res;
} catch (IOException e) {
res = true;
obj = new Object();
} catch (Throwable e) {
if (obj == null) {
res = false;
}
}
}
}
private boolean test8(Object obj) {
this.mDiscovering = false;
try {
exc(obj);
} catch (Exception e) {
e.toString();
} finally {
mDiscovering = true;
}
return mDiscovering;
}
private boolean test8a(Object obj) {
this.mDiscovering = false;
try {
exc(obj);
} catch (Exception e) {
e.toString();
} finally {
if (!mDiscovering) {
mDiscovering = true;
}
}
return mDiscovering;
}
private static boolean testSynchronize(Object obj) throws InterruptedException {
synchronized (obj) {
if (obj instanceof String) {
return false;
}
obj.wait(5);
}
return true;
}
// TODO: remove 'synchronized(TestTryCatch.class)' block in decompiled version
private static synchronized boolean testSynchronize2(Object obj) throws InterruptedException {
return obj.toString() != null;
}
public Object mObject = new Object();
public boolean mDiscovering = true;
private boolean testSynchronize3() {
boolean b = false;
synchronized (mObject) {
b = this.mDiscovering;
}
return b;
}
public int catchInLoop(int i, int j) {
while (true) {
try {
while (i < j) {
i = j++ / i;
}
} catch (RuntimeException e) {
i = 10;
continue;
}
break;
}
return j;
}
@Override
public boolean testRun() throws Exception {
Object obj = new Object();
assertTrue(test0(obj));
assertTrue(test1(obj));
assertTrue(test2(obj));
assertTrue(test3(obj));
assertTrue(test4(obj) != null);
assertTrue(test5(null) != null);
assertTrue(test6(obj));
assertTrue(test7());
assertTrue(testSynchronize(obj));
assertFalse(testSynchronize("str"));
assertTrue(testSynchronize2("str"));
assertTrue(testSynchronize3());
assertTrue(test8("a"));
assertTrue(test8(null));
assertTrue(test8a("a"));
assertTrue(test8a(null));
assertEquals(catchInLoop(1, 0), 0);
assertEquals(catchInLoop(0, 1), 2);
assertEquals(catchInLoop(788, 100), 100);
return true;
}
public static void main(String[] args) throws Exception {
new TestTryCatch().testRun();
}
}
@@ -1,54 +0,0 @@
package jadx.samples;
public class TestTypeResolver extends AbstractTest {
public final int f1;
public TestTypeResolver() {
this.f1 = 2;
}
public TestTypeResolver(int b1, int b2) {
// test 'this' move and constructor invocation on moved register
this(b1, b2, 0, 0, 0);
}
public TestTypeResolver(int a1, int a2, int a3, int a4, int a5) {
this.f1 = a1;
}
public static class TestTernaryInSuper extends TestTypeResolver {
public TestTernaryInSuper(int c) {
// super(c > 0 ? c : -c, 1);
}
}
// public static Object testVarsPropagation(int a) {
// Object b = new Exception();
// if (a == 5)
// b = 1;
// return b;
// }
//
// public Object testMoveThis(int a) {
// TestTypeResolver t = this;
// if (a == 0)
// return t;
//
// return t.testMoveThis(--a);
// }
@Override
public boolean testRun() throws Exception {
// assertTrue((Integer) testVarsPropagation(5) == 1);
// assertTrue(testVarsPropagation(1).getClass() == Exception.class);
//
// assertTrue(testMoveThis(f1) == this);
return true;
}
public static void main(String[] args) throws Exception {
new TestTypeResolver().testRun();
}
}
@@ -1,49 +0,0 @@
package jadx.samples;
/**
* Code example from
* <a href="http://stackoverflow.com/questions/2840183/is-there-any-java-decompiler-that-can-correctly-decompile-calls-to-overloaded-me">
* stackoverflow question</a>
*/
public class TestTypeResolver2 extends AbstractTest {
private static String result = "";
@SuppressWarnings({ "UnnecessaryBoxing", "CachedNumberConstructorCall", "deprecation" })
public void testOverloadedMethods() {
Object s1 = "The";
Object s2 = "answer";
doPrint((Object) "You should know:");
for (int i = 0; i < 2; i++) {
doPrint(s1);
doPrint(s2);
s1 = "is";
s2 = new Integer(42);
}
}
public static void doPrint(String s1) {
fail();
}
public static void doPrint(Integer s1) {
fail();
}
private static void doPrint(Object s1) {
// correct call
result += s1 + " ";
}
@Override
public boolean testRun() throws Exception {
testOverloadedMethods();
assertEquals(result, "You should know: The answer is 42 ");
return true;
}
public static void main(String[] args) throws Exception {
new TestTypeResolver2().testRun();
}
}
@@ -1,44 +0,0 @@
package jadx.samples;
import java.util.ArrayList;
import java.util.List;
public class TestUnicode extends AbstractTest {
/**
* Some unicode strings from:
* http://www.ltg.ed.ac.uk/~richard/unicode-sample-3-2.html
*/
@SuppressWarnings({ "LineLength", "AvoidEscapedUnicodeCharacters" })
public List<String> strings() {
List<String> list = new ArrayList<>();
list.add("! \" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~");
list.add("¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ");
list.add("∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿");
list.add("Ѐ Ё Ђ Ѓ Є Ѕ І Ї Ј Љ Њ Ћ Ќ Ѝ Ў Џ А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я а б в г д е ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я ѐ ё ђ ѓ є ѕ і ї");
list.add("ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た だ ち ぢ っ つ づ て で と ど な に ぬ ね の は ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ ゐ ゑ を ん");
list.add("ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ ヰ ヱ ヲ ン ヴ ヵ ヶ");
list.add("一 丁 丂 七 丄 丅 丆 万 丈 三 上 下 丌 不 与 丏 丐 丑 丒 专 且 丕 世 丗 丘 丙 业 丛 东 丝 丞 丟 丠 両 丢 丣 两 严 並 丧 丨 丩 个 丫 丬 中 丮 丯 丰 丱 串 丳 临 丵 丶 丷 丸 丹 为 主 丼 丽 举 丿 乀 乁 乂 乃 乄 久 乆 乇 么 义 乊 之 乌 乍 乎 乏 乐 乑 乒 乓 乔 乕 乖 乗 乘 乙 乚 乛 乜 九 乞 也 习 乡 乢 乣 乤 乥 书 乧 乨 乩 乪 乫 乬 乭 乮 乯 买 乱 乲 乳 乴 乵 乶 乷 乸 乹 乺 乻 乼 乽 乾 乿");
list.add("豈 更 車 賈 滑 串 句 龜 龜 契 金 喇 奈 懶 癩 羅 蘿 螺 裸 邏 樂 洛 烙 珞 落 酪 駱 亂 卵 欄 爛 蘭 鸞 嵐 濫 藍 襤 拉 臘 蠟 廊 朗 浪 狼 郎 來 冷 勞 擄 櫓 爐 盧 老 蘆 虜 路 露 魯 鷺 碌 祿 綠 菉 錄 鹿 論 壟 弄 籠 聾 牢 磊 賂 雷 壘 屢 樓 淚 漏 累 縷 陋 勒 肋 凜 凌 稜 綾 菱 陵 讀 拏 樂 諾 丹 寧 怒 率 異 北 磻 便 復 不 泌 數 索 參 塞 省 葉 說 殺 辰 沈 拾 若 掠 略 亮 兩 凉 梁 糧 良 諒 量 勵");
list.add("ㄱ ㄲ ㄳ ㄴ ㄵ ㄶ ㄷ ㄸ ㄹ ㄺ ㄻ ㄼ ㄽ ㄾ ㄿ ㅀ ㅁ ㅂ ㅃ ㅄ ㅅ ㅆ ㅇ ㅈ ㅉ ㅊ ㅋ ㅌ ㅍ ㅎ ㅏ ㅐ ㅑ ㅒ ㅓ ㅔ ㅕ ㅖ ㅗ ㅘ ㅙ ㅚ ㅛ ㅜ ㅝ ㅞ ㅟ ㅠ ㅡ ㅢ ㅣ ㅤ ㅥ ㅦ ㅧ ㅨ ㅩ ㅪ ㅫ ㅬ ㅭ ㅮ ㅯ ㅰ ㅱ ㅲ ㅳ ㅴ ㅵ ㅶ ㅷ ㅸ ㅹ ㅺ ㅻ ㅼ ㅽ ㅾ ㅿ ㆀ ㆁ ㆂ ㆃ ㆄ ㆅ ㆆ ㆇ ㆈ ㆉ ㆊ ㆋ ㆌ");
list.add("가 각 갂 갃 간 갅 갆 갇 갈 갉 갊 갋 갌 갍 갎 갏 감 갑 값 갓 갔 강 갖 갗 갘 같 갚 갛 개 객 갞 갟 갠 갡 갢 갣 갤 갥 갦 갧 갨 갩 갪 갫 갬 갭 갮 갯 갰 갱 갲 갳 갴 갵 갶 갷 갸 갹 갺 갻 갼 갽 갾 갿 걀 걁 걂 걃 걄 걅 걆 걇 걈 걉 걊 걋 걌 걍 걎 걏 걐 걑 걒 걓 걔 걕 걖 걗 걘 걙 걚 걛 걜 걝 걞 걟 걠 걡 걢 걣 걤 걥 걦 걧 걨 걩 걪 걫 걬 걭 걮 걯 거 걱 걲 걳 건 걵 걶 걷 걸 걹 걺 걻 걼 걽 걾 걿");
list.add("؛ ؟ ء آ أ ؤ إ ئ ا ب ة ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ـ ف ق ك ل م ن ه و ى ي ً ٌ ٍ َ ُ ِ ّ ْ ٓ ٔ ٕ ٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩ ٪ ٫ ٬ ٭ ٮ ٯ ٰ ٱ ٲ ٳ ٴ ٵ ٶ ٷ ٸ ٹ ٺ ٻ ټ ٽ پ ٿ ڀ ځ ڂ ڃ ڄ څ چ ڇ ڈ ډ ڊ ڋ ڌ ڍ ڎ ڏ ڐ ڑ ڒ ړ ڔ ڕ ږ ڗ ژ ڙ ښ ڛ ڜ ڝ ڞ ڟ ڠ ڡ ڢ ڣ ڤ ڥ ڦ ڧ ڨ ک ڪ ګ ڬ");
list.add("ஃ அ ஆ இ ஈ உ ஊ எ ஏ ஐ ஒ ஓ ஔ க ங ச ஜ ஞ ட ண த ந ன ப ம ய ர ற ல ள ழ வ ஷ ஸ ஹ ா ி ீ ு ூ ெ ே ை ொ ோ ௌ ் ௗ ௧ ௨ ௩ ௪ ௫ ௬ ௭ ௮ ௯ ௰ ௱ ௲");
list.add("\uD800\uDF00 \uD800\uDF01 \uD800\uDF02 \uD800\uDF03 \uD800\uDF04 \uD800\uDF05 \uD800\uDF06 \uD800\uDF07 \uD800\uDF08 \uD800\uDF09 \uD800\uDF0A \uD800\uDF0B \uD800\uDF0C \uD800\uDF0D \uD800\uDF0E \uD800\uDF0F \uD800\uDF10 \uD800\uDF11 \uD800\uDF12 \uD800\uDF13 \uD800\uDF14 \uD800\uDF15 \uD800\uDF16 \uD800\uDF17 \uD800\uDF18 \uD800\uDF19 \uD800\uDF1A \uD800\uDF1B \uD800\uDF1C \uD800\uDF1D \uD800\uDF1E \uD800\uDF20 \uD800\uDF21 \uD800\uDF22 \uD800\uDF23");
list.add("𐌀 𐌁 𐌂 𐌃 𐌄 𐌅 𐌆 𐌇 𐌈 𐌉 𐌊 𐌋 𐌌 𐌍 𐌎 𐌏 𐌐 𐌑 𐌒 𐌓 𐌔 𐌕 𐌖 𐌗 𐌘 𐌙 𐌚 𐌛 𐌜 𐌝 𐌞 𐌠 𐌡 𐌢 𐌣");
return list;
}
@Override
public boolean testRun() throws Exception {
String s = "\uD800\uDF0F"; // 𐌏
int codePoint = s.codePointAt(0);
System.out.println(s + " = " + codePoint);
assertEquals(codePoint, 66319);
return true;
}
public static void main(String[] args) throws Exception {
new TestUnicode().testRun();
}
}
@@ -1,7 +0,0 @@
package jadx.samples.otherpkg;
public class A {
protected class B {
}
}
@@ -1,7 +0,0 @@
package jadx.samples.otherpkg;
public class C {
public static class E {
}
}
@@ -1,7 +0,0 @@
package jadx.samples.otherpkg;
public class D {
public static class E {
}
}
-1
View File
@@ -3,7 +3,6 @@ rootProject.name = 'jadx'
include 'jadx-core'
include 'jadx-cli'
include 'jadx-gui'
include 'jadx-samples'
include 'jadx-plugins'
include 'jadx-plugins:jadx-plugins-api'
include 'jadx-plugins:jadx-dex-input'