use of jadx.api.JadxDecompiler in project bytecode-viewer by Konloch.
the class JADXDecompiler method decompileClassNode.
@Override
public String decompileClassNode(ClassNode cn, byte[] b) {
String fileStart = tempDirectory + fs;
String exception = "";
final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class");
try (FileOutputStream fos = new FileOutputStream(tempClass)) {
fos.write(b);
} catch (final IOException e) {
BytecodeViewer.handleException(e);
}
File fuckery = new File(fuckery(fileStart));
fuckery.mkdirs();
try {
JadxArgs args = new JadxArgs();
args.setInputFile(tempClass);
args.setOutDir(fuckery);
args.setOutDirSrc(fuckery);
args.setOutDirRes(fuckery);
JadxDecompiler jadx = new JadxDecompiler(args);
jadx.load();
jadx.saveSources();
} catch (StackOverflowError | Exception e) {
StringWriter exceptionWriter = new StringWriter();
e.printStackTrace(new PrintWriter(exceptionWriter));
e.printStackTrace();
exception = exceptionWriter.toString();
}
tempClass.delete();
if (fuckery.exists())
return findFile(MiscUtils.listFiles(fuckery));
if (exception.isEmpty())
exception = "Decompiled source file not found!";
return JADX + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + nl + nl + exception;
}
use of jadx.api.JadxDecompiler in project jadx by skylot.
the class JSourcesTest method init.
@BeforeEach
public void init() {
JRoot root = mock(JRoot.class);
when(root.isFlatPackages()).thenReturn(false);
JadxWrapper wrapper = mock(JadxWrapper.class);
sources = new JSources(root, wrapper);
decompiler = new JadxDecompiler(new JadxArgs());
}
use of jadx.api.JadxDecompiler in project jadx by skylot.
the class ExportTask method scheduleJobs.
@Override
public List<Runnable> scheduleJobs() {
wrapCodeCache();
JadxDecompiler decompiler = wrapper.getDecompiler();
decompiler.getArgs().setRootDir(saveDir);
List<Runnable> saveTasks = decompiler.getSaveTasks();
this.timeLimit = DecompileTask.calcDecompileTimeLimit(saveTasks.size());
return saveTasks;
}
use of jadx.api.JadxDecompiler in project jadx by skylot.
the class JadxCLI method processAndSave.
private static int processAndSave(JadxCLIArgs cliArgs) {
LogHelper.initLogLevel(cliArgs);
LogHelper.setLogLevelsForLoadingStage();
JadxArgs jadxArgs = cliArgs.toJadxArgs();
jadxArgs.setCodeCache(new NoOpCodeCache());
jadxArgs.setCodeWriterProvider(SimpleCodeWriter::new);
try (JadxDecompiler jadx = new JadxDecompiler(jadxArgs)) {
jadx.load();
if (checkForErrors(jadx)) {
return 1;
}
LogHelper.setLogLevelsForDecompileStage();
if (!SingleClassMode.process(jadx, cliArgs)) {
save(jadx);
}
int errorsCount = jadx.getErrorsCount();
if (errorsCount != 0) {
jadx.printErrorsReport();
LOG.error("finished with errors, count: {}", errorsCount);
} else {
LOG.info("done");
}
}
return 0;
}
use of jadx.api.JadxDecompiler in project jadx by skylot.
the class BaseExternalTest method decompile.
protected JadxDecompiler decompile(JadxArgs jadxArgs, @Nullable String clsPatternStr, @Nullable String mthPatternStr) {
JadxDecompiler jadx = new JadxDecompiler(jadxArgs);
jadx.load();
if (clsPatternStr == null) {
jadx.save();
} else {
processByPatterns(jadx, clsPatternStr, mthPatternStr);
}
printErrorReport(jadx);
return jadx;
}
Aggregations