feat: allow to load custom input (#1457)
This commit is contained in:
@@ -57,7 +57,7 @@ public class JadxArgsValidatorOutDirsTest {
|
||||
}
|
||||
|
||||
private void checkOutDirs(String outDir, String srcDir, String resDir) {
|
||||
JadxArgsValidator.validate(args);
|
||||
JadxArgsValidator.validate(new JadxDecompiler(args));
|
||||
LOG.debug("Got dirs: out={}, src={}, res={}", args.getOutDir(), args.getOutDirSrc(), args.getOutDirRes());
|
||||
assertThat(args.getOutDir(), is(toFile(outDir)));
|
||||
assertThat(args.getOutDirSrc(), is(toFile(srcDir)));
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package jadx.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jadx.core.utils.files.FileUtils;
|
||||
import jadx.plugins.input.dex.DexInputPlugin;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
@@ -38,6 +42,20 @@ public class JadxDecompilerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDirectDexInput() throws IOException {
|
||||
try (JadxDecompiler jadx = new JadxDecompiler();
|
||||
InputStream in = new FileInputStream(getFileFromSampleDir("hello.dex"))) {
|
||||
jadx.addCustomLoad(new DexInputPlugin().loadDexFromInputStream(in, "input"));
|
||||
jadx.load();
|
||||
for (JavaClass cls : jadx.getClasses()) {
|
||||
System.out.println(cls.getCode());
|
||||
}
|
||||
assertThat(jadx.getClasses(), Matchers.hasSize(1));
|
||||
assertThat(jadx.getErrorsCount(), Matchers.is(0));
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TEST_SAMPLES_DIR = "test-samples/";
|
||||
|
||||
public static File getFileFromSampleDir(String fileName) {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user