/** * Get the complete list of classes */ public List<JavaClass> getClasses() { return decompiler.getClasses(); }
/** * Get all classes that are not excluded by the excluded packages settings */ public List<JavaClass> getIncludedClasses() { List<JavaClass> classList = decompiler.getClasses(); String excludedPackages = settings.getExcludedPackages().trim(); if (excludedPackages.length() == 0) { return classList; } String[] excluded = excludedPackages.split("[ ]+"); return classList.stream().filter(cls -> { for (String exclude : excluded) { if (cls.getFullName().startsWith(exclude)) { return false; } } return true; }).collect(Collectors.toList()); }
public List<JavaPackage> getPackages() { List<JavaClass> classList = getClasses(); if (classList.isEmpty()) { return Collections.emptyList(); } Map<String, List<JavaClass>> map = new HashMap<>(); for (JavaClass javaClass : classList) { String pkg = javaClass.getPackage(); List<JavaClass> clsList = map.computeIfAbsent(pkg, k -> new ArrayList<>()); clsList.add(javaClass); } List<JavaPackage> packages = new ArrayList<>(map.size()); for (Map.Entry<String, List<JavaClass>> entry : map.entrySet()) { packages.add(new JavaPackage(entry.getKey(), entry.getValue())); } Collections.sort(packages); for (JavaPackage pkg : packages) { pkg.getClasses().sort(Comparator.comparing(JavaClass::getName)); } return Collections.unmodifiableList(packages); }
private void processAll(JadxDecompiler jadx) { for (JavaClass javaClass : jadx.getClasses()) { javaClass.decompile(); } }
@Override public void run() { try { decompiler.getArgs().setRootDir(dir); ThreadPoolExecutor ex = (ThreadPoolExecutor) decompiler.getSaveExecutor(); ex.shutdown(); while (ex.isTerminating()) { long total = ex.getTaskCount(); long done = ex.getCompletedTaskCount(); progressMonitor.setProgress((int) (done * 100.0 / (double) total)); Thread.sleep(500); } progressMonitor.close(); LOG.info("decompilation complete, freeing memory ..."); decompiler.getClasses().forEach(JavaClass::unload); LOG.info("done"); } catch (InterruptedException e) { LOG.error("Save interrupted", e); Thread.currentThread().interrupt(); } } };
private void appendSourcesSave(ExecutorService executor, File outDir) { for (JavaClass cls : getClasses()) { if (cls.getClassNode().contains(AFlag.DONT_GENERATE)) { continue; } executor.execute(() -> { try { cls.decompile(); SaveCode.save(outDir, args, cls.getClassNode()); } catch (Exception e) { LOG.error("Error saving class: {}", cls.getFullName(), e); } }); } }