public void openFile(File file) { this.openFile = file; try { this.decompiler = new JadxDecompiler(settings.toJadxArgs()); this.decompiler.getArgs().setInputFiles(Collections.singletonList(file)); this.decompiler.load(); } catch (Exception e) { LOG.error("Error load file: {}", file, e); } }
static int processAndSave(JadxCLIArgs inputArgs) { JadxDecompiler jadx = new JadxDecompiler(inputArgs.toJadxArgs()); try { jadx.load(); } catch (JadxArgsValidateException e) { LOG.error("Incorrect arguments: {}", e.getMessage()); return 1; } jadx.save(); int errorsCount = jadx.getErrorsCount(); if (errorsCount != 0) { jadx.printErrorsReport(); LOG.error("finished with errors"); } else { LOG.info("done"); } return errorsCount; } }
protected void decompile(JadxArgs jadxArgs, @Nullable String clsPatternStr, @Nullable String mthPatternStr) { JadxDecompiler jadx = new JadxDecompiler(jadxArgs); jadx.load(); if (clsPatternStr == null) { processAll(jadx); // jadx.saveSources(); } else { Pattern clsPtrn = Pattern.compile(clsPatternStr); Pattern mthPtrn = mthPatternStr == null ? null : Pattern.compile(mthPatternStr); processByPatterns(jadx, clsPtrn, mthPtrn); } printErrorReport(jadx); }
@Before 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()); }
@Test @Ignore public void testExampleUsage() { JadxArgs args = new JadxArgs(); args.getInputFiles().add(new File("test.apk")); args.setOutDir(new File("jadx-test-output")); JadxDecompiler jadx = new JadxDecompiler(args); jadx.load(); jadx.save(); }
public ClassNode getClassNodeFromFile(File file, String clsName) { JadxDecompiler d = null; try { args.setInputFiles(Collections.singletonList(file)); d = new JadxDecompiler(args); d.load(); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } RootNode root = JadxInternalAccess.getRoot(d); insertResources(root); ClassNode cls = root.searchClassByName(clsName); assertThat("Class not found: " + clsName, cls, notNullValue()); assertThat(clsName, is(cls.getClassInfo().getFullName())); if (unloadCls) { decompile(d, cls); } else { decompileWithoutUnload(d, cls); } System.out.println("-----------------------------------------------------------"); System.out.println(cls.getCode()); System.out.println("-----------------------------------------------------------"); checkCode(cls); compile(cls); runAutoCheck(clsName); return cls; }