Search in sources :

Example 1 with IAttributeNode

use of jadx.core.dex.attributes.IAttributeNode in project jadx by skylot.

the class ErrorsCounter method printReport.

public void printReport() {
    if (getErrorCount() > 0) {
        LOG.error("{} errors occurred in following nodes:", getErrorCount());
        List<String> errors = new ArrayList<>(errorNodes.size());
        for (IAttributeNode node : errorNodes) {
            String nodeName = node.getClass().getSimpleName().replace("Node", "");
            errors.add(nodeName + ": " + node);
        }
        Collections.sort(errors);
        for (String err : errors) {
            LOG.error("  {}", err);
        }
    }
    if (getWarnsCount() > 0) {
        LOG.warn("{} warnings in {} nodes", getWarnsCount(), warnNodes.size());
    }
}
Also used : ArrayList(java.util.ArrayList) IAttributeNode(jadx.core.dex.attributes.IAttributeNode)

Example 2 with IAttributeNode

use of jadx.core.dex.attributes.IAttributeNode 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)

Aggregations

IAttributeNode (jadx.core.dex.attributes.IAttributeNode)2 JadxDecompiler (jadx.api.JadxDecompiler)1 ClassNode (jadx.core.dex.nodes.ClassNode)1 MethodNode (jadx.core.dex.nodes.MethodNode)1 ProcessState (jadx.core.dex.nodes.ProcessState)1 ErrorsCounter (jadx.core.utils.ErrorsCounter)1 Utils (jadx.core.utils.Utils)1 JClass (jadx.gui.treemodel.JClass)1 JNode (jadx.gui.treemodel.JNode)1 MainWindow (jadx.gui.ui.MainWindow)1 TabbedPane (jadx.gui.ui.TabbedPane)1 ContentPanel (jadx.gui.ui.panel.ContentPanel)1 HtmlPanel (jadx.gui.ui.panel.HtmlPanel)1 UiUtils (jadx.gui.utils.UiUtils)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1