public List<JavaField> getFields() { decompile(); return fields; }
@Override public String toString() { return getFullName(); } }
@Nullable public JavaNode getJavaNodeAtPosition(int line, int offset) { Map<CodePosition, Object> map = getCodeAnnotations(); if (map.isEmpty()) { return null; } Object obj = map.get(new CodePosition(line, offset)); if (obj == null) { return null; } return convertNode(obj); }
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); } }); } }
public void indexNames(JavaClass cls) { clsNamesIndex.put(cls.getFullName(), nodeCache.makeFrom(cls)); for (JavaMethod mth : cls.getMethods()) { mthNamesIndex.put(mth.getFullName(), nodeCache.makeFrom(mth)); } for (JavaField fld : cls.getFields()) { fldNamesIndex.put(fld.getFullName(), nodeCache.makeFrom(fld)); } for (JavaClass innerCls : cls.getInnerClasses()) { indexNames(innerCls); } }
private void load() { JadxDecompiler rootDecompiler = getRootDecompiler(); int inClsCount = cls.getInnerClasses().size(); if (inClsCount != 0) { for (ClassNode inner : cls.getInnerClasses()) { if (!inner.contains(AFlag.DONT_GENERATE)) { JavaClass javaClass = new JavaClass(inner, this); javaClass.load(); list.add(javaClass); rootDecompiler.getClassesMap().put(inner, javaClass);
public static JavaClass newClass(JadxDecompiler decompiler, ClassNode classNode) { return new JavaClass(classNode, decompiler); } }
@Override public String getContent() { return cls.getCode(); }
@Override public boolean equals(Object obj) { return this == obj || obj instanceof JClass && cls.equals(((JClass) obj).cls); }
@Override public Icon getIcon() { AccessInfo accessInfo = cls.getAccessInfo(); if (accessInfo.isEnum()) { return ICON_ENUM; } if (accessInfo.isAnnotation()) { return ICON_ANNOTATION; } if (accessInfo.isInterface()) { return ICON_INTERFACE; } if (accessInfo.isProtected()) { return ICON_CLASS_PROTECTED; } if (accessInfo.isPrivate()) { return ICON_CLASS_PRIVATE; } if (accessInfo.isPublic()) { return ICON_CLASS; } return ICON_CLASS_DEFAULT; }
public List<JavaClass> getClasses() { if (root == null) { return Collections.emptyList(); } if (classes == null) { List<ClassNode> classNodeList = root.getClasses(false); List<JavaClass> clsList = new ArrayList<>(classNodeList.size()); classesMap.clear(); for (ClassNode classNode : classNodeList) { JavaClass javaClass = new JavaClass(classNode, this); clsList.add(javaClass); classesMap.put(classNode, javaClass); } classes = Collections.unmodifiableList(clsList); } return classes; }
@NotNull protected List<StringRef> splitLines(JavaClass cls) { List<StringRef> lines = StringRef.split(cls.getCode(), CodeWriter.NL); int size = lines.size(); for (int i = 0; i < size; i++) { lines.set(i, lines.get(i).trim()); } return lines; }
public List<JavaMethod> getMethods() { decompile(); return methods; }
@Override public String makeLongString() { return cls.getFullName(); } }
public Map<CodePosition, JavaNode> getUsageMap() { Map<CodePosition, Object> map = getCodeAnnotations(); if (map.isEmpty() || decompiler == null) { return Collections.emptyMap(); } Map<CodePosition, JavaNode> resultMap = new HashMap<>(map.size()); for (Map.Entry<CodePosition, Object> entry : map.entrySet()) { CodePosition codePosition = entry.getKey(); Object obj = entry.getValue(); if (obj instanceof LineAttrNode) { JavaNode node = convertNode(obj); if (node != null) { resultMap.put(codePosition, node); } } } return resultMap; }
public Flowable<CodeNode> searchInSkippedClasses(final String searchStr, final boolean caseInsensitive) { return Flowable.create(emitter -> { LOG.debug("Skipped code search started: {} ...", searchStr); for (JavaClass javaClass : skippedClasses) { String code = javaClass.getCode(); int pos = 0; while (pos != -1) { pos = searchNext(emitter, searchStr, javaClass, code, pos, caseInsensitive); if (emitter.isCancelled()) { LOG.debug("Skipped Code search canceled: {}", searchStr); return; } } if (!Utils.isFreeMemoryAvailable()) { LOG.warn("Skipped code search stopped due to memory limit: {}", Utils.memoryInfo()); emitter.onComplete(); return; } } LOG.debug("Skipped code search complete: {}, memory usage: {}", searchStr, Utils.memoryInfo()); emitter.onComplete(); }, BackpressureStrategy.LATEST); }
public List<JavaClass> getInnerClasses() { decompile(); return innerClasses; }
public String getFullName() { return cls.getFullName(); }
JavaMethod getJavaMethodByNode(MethodNode mth) { JavaMethod javaMethod = methodsMap.get(mth); if (javaMethod != null) { return javaMethod; } // parent class not loaded yet JavaClass javaClass = classesMap.get(mth.getParentClass()); if (javaClass != null) { javaClass.decompile(); return methodsMap.get(mth); } return null; }