Search in sources :

Example 11 with JadxDecompiler

use of jadx.api.JadxDecompiler in project jadx by skylot.

the class SummaryNode method writeDecompilationSummary.

private void writeDecompilationSummary(StringEscapeUtils.Builder builder) {
    builder.append("<h2>Decompilation</h2>");
    JadxDecompiler jadx = mainWindow.getWrapper().getDecompiler();
    List<ClassNode> classes = jadx.getRoot().getClasses(false);
    int classesCount = classes.size();
    long processedClasses = classes.stream().filter(c -> c.getState() == ProcessState.PROCESS_COMPLETE).count();
    long generatedClasses = classes.stream().filter(c -> c.getState() == ProcessState.GENERATED_AND_UNLOADED).count();
    builder.append("<ul>");
    builder.append("<li>Top level classes: " + classesCount + "</li>");
    builder.append("<li>At process stage: " + valueAndPercent(processedClasses, classesCount) + "</li>");
    builder.append("<li>Code generated: " + valueAndPercent(generatedClasses, classesCount) + "</li>");
    builder.append("</ul>");
    ErrorsCounter counter = jadx.getRoot().getErrorsCounter();
    Set<IAttributeNode> problemNodes = new HashSet<>();
    problemNodes.addAll(counter.getErrorNodes());
    problemNodes.addAll(counter.getWarnNodes());
    long problemMethods = problemNodes.stream().filter(MethodNode.class::isInstance).count();
    int methodsCount = classes.stream().mapToInt(cls -> cls.getMethods().size()).sum();
    double methodSuccessRate = (methodsCount - problemMethods) * 100.0 / (double) methodsCount;
    builder.append("<h3>Issues</h3>");
    builder.append("<ul>");
    builder.append("<li>Errors: " + counter.getErrorCount() + "</li>");
    builder.append("<li>Warnings: " + counter.getWarnsCount() + "</li>");
    builder.append("<li>Nodes with errors: " + counter.getErrorNodes().size() + "</li>");
    builder.append("<li>Nodes with warnings: " + counter.getWarnNodes().size() + "</li>");
    builder.append("<li>Total nodes with issues: " + problemNodes.size() + "</li>");
    builder.append("<li>Methods with issues: " + problemMethods + "</li>");
    builder.append("<li>Methods success rate: " + String.format("%.2f", methodSuccessRate) + "%</li>");
    builder.append("</ul>");
}
Also used : MethodNode(jadx.core.dex.nodes.MethodNode) JadxDecompiler(jadx.api.JadxDecompiler) TabbedPane(jadx.gui.ui.TabbedPane) Set(java.util.Set) IOException(java.io.IOException) Icon(javax.swing.Icon) StringEscapeUtils(org.apache.commons.text.StringEscapeUtils) ContentPanel(jadx.gui.ui.panel.ContentPanel) IAttributeNode(jadx.core.dex.attributes.IAttributeNode) Collectors(java.util.stream.Collectors) File(java.io.File) HashSet(java.util.HashSet) ProcessState(jadx.core.dex.nodes.ProcessState) List(java.util.List) ClassNode(jadx.core.dex.nodes.ClassNode) ErrorsCounter(jadx.core.utils.ErrorsCounter) UiUtils(jadx.gui.utils.UiUtils) ImageIcon(javax.swing.ImageIcon) JNode(jadx.gui.treemodel.JNode) JClass(jadx.gui.treemodel.JClass) MainWindow(jadx.gui.ui.MainWindow) HtmlPanel(jadx.gui.ui.panel.HtmlPanel) Utils(jadx.core.utils.Utils) ClassNode(jadx.core.dex.nodes.ClassNode) JadxDecompiler(jadx.api.JadxDecompiler) ErrorsCounter(jadx.core.utils.ErrorsCounter) IAttributeNode(jadx.core.dex.attributes.IAttributeNode) HashSet(java.util.HashSet)

Example 12 with JadxDecompiler

use of jadx.api.JadxDecompiler in project jadx by skylot.

the class JadxWrapper method openFile.

public void openFile(List<Path> paths) {
    close();
    this.openPaths = paths;
    try {
        JadxArgs jadxArgs = settings.toJadxArgs();
        jadxArgs.setInputFiles(toFiles(paths));
        if (project != null) {
            jadxArgs.setCodeData(project.getCodeData());
        }
        this.decompiler = new JadxDecompiler(jadxArgs);
        this.decompiler.load();
    } catch (Exception e) {
        LOG.error("Jadx init error", e);
        close();
    }
}
Also used : JadxDecompiler(jadx.api.JadxDecompiler) JadxArgs(jadx.api.JadxArgs)

Aggregations

JadxDecompiler (jadx.api.JadxDecompiler)12 JadxArgs (jadx.api.JadxArgs)4 ClassNode (jadx.core.dex.nodes.ClassNode)4 File (java.io.File)4 IOException (java.io.IOException)4 RootNode (jadx.core.dex.nodes.RootNode)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 IAttributeNode (jadx.core.dex.attributes.IAttributeNode)2 MethodNode (jadx.core.dex.nodes.MethodNode)2 ProcessState (jadx.core.dex.nodes.ProcessState)2 ErrorsCounter (jadx.core.utils.ErrorsCounter)2 Utils (jadx.core.utils.Utils)2 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)2 JClass (jadx.gui.treemodel.JClass)2 JNode (jadx.gui.treemodel.JNode)2 MainWindow (jadx.gui.ui.MainWindow)2 TabbedPane (jadx.gui.ui.TabbedPane)2 ContentPanel (jadx.gui.ui.panel.ContentPanel)2 HtmlPanel (jadx.gui.ui.panel.HtmlPanel)2