repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/JadxArgs.java
jadx-core/src/main/java/jadx/api/JadxArgs.java
package jadx.api; import java.io.Closeable; import java.io.File; import java.nio.file.Path; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import jadx.api.args.GeneratedRenamesMappingFileMode; import jadx.api.args.IntegerFormat; import jadx.api.args.ResourceNameSource; import jadx.api.args.UseSourceNameAsClassNameAlias; import jadx.api.args.UserRenamesMappingsMode; import jadx.api.data.ICodeData; import jadx.api.deobf.IAliasProvider; import jadx.api.deobf.IRenameCondition; import jadx.api.impl.AnnotatedCodeWriter; import jadx.api.impl.InMemoryCodeCache; import jadx.api.plugins.loader.JadxBasePluginLoader; import jadx.api.plugins.loader.JadxPluginLoader; import jadx.api.security.IJadxSecurity; import jadx.api.security.JadxSecurityFlag; import jadx.api.security.impl.JadxSecurity; import jadx.api.usage.IUsageInfoCache; import jadx.api.usage.impl.InMemoryUsageInfoCache; import jadx.core.deobf.DeobfAliasProvider; import jadx.core.deobf.conditions.DeobfWhitelist; import jadx.core.deobf.conditions.JadxRenameConditions; import jadx.core.export.ExportGradleType; import jadx.core.plugins.PluginContext; import jadx.core.plugins.files.IJadxFilesGetter; import jadx.core.plugins.files.TempFilesGetter; import jadx.core.utils.files.FileUtils; public class JadxArgs implements Closeable { private static final Logger LOG = LoggerFactory.getLogger(JadxArgs.class); public static final int DEFAULT_THREADS_COUNT = Math.max(1, Runtime.getRuntime().availableProcessors() / 2); public static final String DEFAULT_NEW_LINE_STR = System.lineSeparator(); public static final String DEFAULT_INDENT_STR = " "; public static final String DEFAULT_OUT_DIR = "jadx-output"; public static final String DEFAULT_SRC_DIR = "sources"; public static final String DEFAULT_RES_DIR = "resources"; private List<File> inputFiles = new ArrayList<>(1); private File outDir; private File outDirSrc; private File outDirRes; private ICodeCache codeCache = new InMemoryCodeCache(); /** * Usage data cache. Saves use places of classes, methods and fields between code reloads. * Can be set to {@link jadx.api.usage.impl.EmptyUsageInfoCache} if code reload not needed. */ private IUsageInfoCache usageInfoCache = new InMemoryUsageInfoCache(); private Function<JadxArgs, ICodeWriter> codeWriterProvider = AnnotatedCodeWriter::new; private int threadsCount = DEFAULT_THREADS_COUNT; private boolean cfgOutput = false; private boolean rawCFGOutput = false; private boolean showInconsistentCode = false; private boolean useImports = true; private boolean debugInfo = true; private boolean insertDebugLines = false; private boolean extractFinally = true; private boolean inlineAnonymousClasses = true; private boolean inlineMethods = true; private boolean allowInlineKotlinLambda = true; private boolean moveInnerClasses = true; private boolean skipResources = false; private boolean skipSources = false; private boolean useHeadersForDetectResourceExtensions; /** * Predicate that allows to filter the classes to be process based on their full name */ private Predicate<String> classFilter = null; /** * Save dependencies for classes accepted by {@code classFilter} */ private boolean includeDependencies = false; private Path userRenamesMappingsPath = null; private UserRenamesMappingsMode userRenamesMappingsMode = UserRenamesMappingsMode.getDefault(); private boolean deobfuscationOn = false; private UseSourceNameAsClassNameAlias useSourceNameAsClassNameAlias = UseSourceNameAsClassNameAlias.getDefault(); private int sourceNameRepeatLimit = 10; private File generatedRenamesMappingFile = null; private GeneratedRenamesMappingFileMode generatedRenamesMappingFileMode = GeneratedRenamesMappingFileMode.getDefault(); private ResourceNameSource resourceNameSource = ResourceNameSource.AUTO; private int deobfuscationMinLength = 0; private int deobfuscationMaxLength = Integer.MAX_VALUE; /** * List of classes and packages (ends with '.*') to exclude from deobfuscation */ private List<String> deobfuscationWhitelist = DeobfWhitelist.DEFAULT_LIST; /** * Nodes alias provider for deobfuscator and rename visitor */ private IAliasProvider aliasProvider = new DeobfAliasProvider(); /** * Condition to rename node in deobfuscator */ private IRenameCondition renameCondition = JadxRenameConditions.buildDefault(); private boolean escapeUnicode = false; private boolean replaceConsts = true; private boolean respectBytecodeAccModifiers = false; private @Nullable ExportGradleType exportGradleType = null; private boolean restoreSwitchOverString = true; private boolean skipXmlPrettyPrint = false; private boolean fsCaseSensitive; public enum RenameEnum { CASE, VALID, PRINTABLE } private Set<RenameEnum> renameFlags = EnumSet.allOf(RenameEnum.class); public enum OutputFormatEnum { JAVA, JSON } private OutputFormatEnum outputFormat = OutputFormatEnum.JAVA; private DecompilationMode decompilationMode = DecompilationMode.AUTO; private ICodeData codeData; private String codeNewLineStr = DEFAULT_NEW_LINE_STR; private String codeIndentStr = DEFAULT_INDENT_STR; private CommentsLevel commentsLevel = CommentsLevel.INFO; private IntegerFormat integerFormat = IntegerFormat.AUTO; /** * Maximum updates allowed total in method per one instruction. * Should be more or equal 1, default value is 10. */ private int typeUpdatesLimitCount = 10; private boolean useDxInput = false; public enum UseKotlinMethodsForVarNames { DISABLE, APPLY, APPLY_AND_HIDE } private UseKotlinMethodsForVarNames useKotlinMethodsForVarNames = UseKotlinMethodsForVarNames.APPLY; /** * Additional files structure info. * Defaults to tmp dirs. */ private IJadxFilesGetter filesGetter = TempFilesGetter.INSTANCE; /** * Additional data validation and security checks */ private IJadxSecurity security = new JadxSecurity(JadxSecurityFlag.all()); /** * Don't save files (can be using for performance testing) */ private boolean skipFilesSave = false; /** * Run additional expensive checks to verify internal invariants and info integrity */ private boolean runDebugChecks = false; /** * Passes to exclude from processing. */ private final List<String> disabledPasses = new ArrayList<>(); private Map<String, String> pluginOptions = new HashMap<>(); private Set<String> disabledPlugins = new HashSet<>(); private JadxPluginLoader pluginLoader = new JadxBasePluginLoader(); private boolean loadJadxClsSetFile = true; public JadxArgs() { // use default options } public void setRootDir(File rootDir) { setOutDir(rootDir); setOutDirSrc(new File(rootDir, DEFAULT_SRC_DIR)); setOutDirRes(new File(rootDir, DEFAULT_RES_DIR)); } @Override public void close() { try { inputFiles = null; if (codeCache != null) { codeCache.close(); } if (usageInfoCache != null) { usageInfoCache.close(); } if (pluginLoader != null) { pluginLoader.close(); } } catch (Exception e) { LOG.error("Failed to close JadxArgs", e); } finally { codeCache = null; usageInfoCache = null; } } public List<File> getInputFiles() { return inputFiles; } public void addInputFile(File inputFile) { this.inputFiles.add(inputFile); } public void setInputFile(File inputFile) { addInputFile(inputFile); } public void setInputFiles(List<File> inputFiles) { this.inputFiles = inputFiles; } public File getOutDir() { return outDir; } public void setOutDir(File outDir) { this.outDir = outDir; } public File getOutDirSrc() { return outDirSrc; } public void setOutDirSrc(File outDirSrc) { this.outDirSrc = outDirSrc; } public File getOutDirRes() { return outDirRes; } public void setOutDirRes(File outDirRes) { this.outDirRes = outDirRes; } public int getThreadsCount() { return threadsCount; } public void setThreadsCount(int threadsCount) { this.threadsCount = Math.max(1, threadsCount); // make sure threadsCount >= 1 } public boolean isCfgOutput() { return cfgOutput; } public void setCfgOutput(boolean cfgOutput) { this.cfgOutput = cfgOutput; } public boolean isRawCFGOutput() { return rawCFGOutput; } public void setRawCFGOutput(boolean rawCFGOutput) { this.rawCFGOutput = rawCFGOutput; } public boolean isFallbackMode() { return decompilationMode == DecompilationMode.FALLBACK; } /** * Deprecated: use 'decompilation mode' property */ @Deprecated public void setFallbackMode(boolean fallbackMode) { if (fallbackMode) { this.decompilationMode = DecompilationMode.FALLBACK; } } public boolean isShowInconsistentCode() { return showInconsistentCode; } public void setShowInconsistentCode(boolean showInconsistentCode) { this.showInconsistentCode = showInconsistentCode; } public boolean isUseImports() { return useImports; } public void setUseImports(boolean useImports) { this.useImports = useImports; } public boolean isDebugInfo() { return debugInfo; } public void setDebugInfo(boolean debugInfo) { this.debugInfo = debugInfo; } public boolean isInsertDebugLines() { return insertDebugLines; } public void setInsertDebugLines(boolean insertDebugLines) { this.insertDebugLines = insertDebugLines; } public boolean isInlineAnonymousClasses() { return inlineAnonymousClasses; } public void setInlineAnonymousClasses(boolean inlineAnonymousClasses) { this.inlineAnonymousClasses = inlineAnonymousClasses; } public boolean isInlineMethods() { return inlineMethods; } public void setInlineMethods(boolean inlineMethods) { this.inlineMethods = inlineMethods; } public boolean isAllowInlineKotlinLambda() { return allowInlineKotlinLambda; } public void setAllowInlineKotlinLambda(boolean allowInlineKotlinLambda) { this.allowInlineKotlinLambda = allowInlineKotlinLambda; } public boolean isMoveInnerClasses() { return moveInnerClasses; } public void setMoveInnerClasses(boolean moveInnerClasses) { this.moveInnerClasses = moveInnerClasses; } public boolean isExtractFinally() { return extractFinally; } public void setExtractFinally(boolean extractFinally) { this.extractFinally = extractFinally; } public boolean isSkipResources() { return skipResources; } public void setSkipResources(boolean skipResources) { this.skipResources = skipResources; } public boolean isSkipSources() { return skipSources; } public void setSkipSources(boolean skipSources) { this.skipSources = skipSources; } public void setIncludeDependencies(boolean includeDependencies) { this.includeDependencies = includeDependencies; } public boolean isIncludeDependencies() { return includeDependencies; } public Predicate<String> getClassFilter() { return classFilter; } public void setClassFilter(Predicate<String> classFilter) { this.classFilter = classFilter; } public Path getUserRenamesMappingsPath() { return userRenamesMappingsPath; } public void setUserRenamesMappingsPath(Path path) { this.userRenamesMappingsPath = path; } public UserRenamesMappingsMode getUserRenamesMappingsMode() { return userRenamesMappingsMode; } public void setUserRenamesMappingsMode(UserRenamesMappingsMode mode) { this.userRenamesMappingsMode = mode; } public boolean isDeobfuscationOn() { return deobfuscationOn; } public void setDeobfuscationOn(boolean deobfuscationOn) { this.deobfuscationOn = deobfuscationOn; } public boolean isDeobfuscationForceSave() { return generatedRenamesMappingFileMode == GeneratedRenamesMappingFileMode.OVERWRITE; } public void setDeobfuscationForceSave(boolean deobfuscationForceSave) { if (deobfuscationForceSave) { this.generatedRenamesMappingFileMode = GeneratedRenamesMappingFileMode.OVERWRITE; } } public GeneratedRenamesMappingFileMode getGeneratedRenamesMappingFileMode() { return generatedRenamesMappingFileMode; } public void setGeneratedRenamesMappingFileMode(GeneratedRenamesMappingFileMode mode) { this.generatedRenamesMappingFileMode = mode; } public UseSourceNameAsClassNameAlias getUseSourceNameAsClassNameAlias() { return useSourceNameAsClassNameAlias; } public void setUseSourceNameAsClassNameAlias(UseSourceNameAsClassNameAlias useSourceNameAsClassNameAlias) { this.useSourceNameAsClassNameAlias = useSourceNameAsClassNameAlias; } public int getSourceNameRepeatLimit() { return sourceNameRepeatLimit; } public void setSourceNameRepeatLimit(int sourceNameRepeatLimit) { this.sourceNameRepeatLimit = sourceNameRepeatLimit; } /** * @deprecated Use {@link #getUseSourceNameAsClassNameAlias()} instead. */ @Deprecated public boolean isUseSourceNameAsClassAlias() { return getUseSourceNameAsClassNameAlias().toBoolean(); } /** * @deprecated Use {@link #setUseSourceNameAsClassNameAlias(UseSourceNameAsClassNameAlias)} instead. */ @Deprecated public void setUseSourceNameAsClassAlias(boolean useSourceNameAsClassAlias) { final var useSourceNameAsClassNameAlias = UseSourceNameAsClassNameAlias.create(useSourceNameAsClassAlias); setUseSourceNameAsClassNameAlias(useSourceNameAsClassNameAlias); } public int getDeobfuscationMinLength() { return deobfuscationMinLength; } public void setDeobfuscationMinLength(int deobfuscationMinLength) { this.deobfuscationMinLength = deobfuscationMinLength; } public int getDeobfuscationMaxLength() { return deobfuscationMaxLength; } public void setDeobfuscationMaxLength(int deobfuscationMaxLength) { this.deobfuscationMaxLength = deobfuscationMaxLength; } public List<String> getDeobfuscationWhitelist() { return this.deobfuscationWhitelist; } public void setDeobfuscationWhitelist(List<String> deobfuscationWhitelist) { this.deobfuscationWhitelist = deobfuscationWhitelist; } public File getGeneratedRenamesMappingFile() { return generatedRenamesMappingFile; } public void setGeneratedRenamesMappingFile(File file) { this.generatedRenamesMappingFile = file; } public ResourceNameSource getResourceNameSource() { return resourceNameSource; } public void setResourceNameSource(ResourceNameSource resourceNameSource) { this.resourceNameSource = resourceNameSource; } public IAliasProvider getAliasProvider() { return aliasProvider; } public void setAliasProvider(IAliasProvider aliasProvider) { this.aliasProvider = aliasProvider; } public IRenameCondition getRenameCondition() { return renameCondition; } public void setRenameCondition(IRenameCondition renameCondition) { this.renameCondition = renameCondition; } public boolean isEscapeUnicode() { return escapeUnicode; } public void setEscapeUnicode(boolean escapeUnicode) { this.escapeUnicode = escapeUnicode; } public boolean isReplaceConsts() { return replaceConsts; } public void setReplaceConsts(boolean replaceConsts) { this.replaceConsts = replaceConsts; } public boolean isRespectBytecodeAccModifiers() { return respectBytecodeAccModifiers; } public void setRespectBytecodeAccModifiers(boolean respectBytecodeAccModifiers) { this.respectBytecodeAccModifiers = respectBytecodeAccModifiers; } public boolean isExportAsGradleProject() { return exportGradleType != null; } public void setExportAsGradleProject(boolean exportAsGradleProject) { if (exportAsGradleProject) { if (exportGradleType == null) { exportGradleType = ExportGradleType.AUTO; } } else { exportGradleType = null; } } public @Nullable ExportGradleType getExportGradleType() { return exportGradleType; } public void setExportGradleType(@Nullable ExportGradleType exportGradleType) { this.exportGradleType = exportGradleType; } public boolean isRestoreSwitchOverString() { return restoreSwitchOverString; } public void setRestoreSwitchOverString(boolean restoreSwitchOverString) { this.restoreSwitchOverString = restoreSwitchOverString; } public boolean isSkipXmlPrettyPrint() { return skipXmlPrettyPrint; } public void setSkipXmlPrettyPrint(boolean skipXmlPrettyPrint) { this.skipXmlPrettyPrint = skipXmlPrettyPrint; } public boolean isFsCaseSensitive() { return fsCaseSensitive; } public void setFsCaseSensitive(boolean fsCaseSensitive) { this.fsCaseSensitive = fsCaseSensitive; } public boolean isRenameCaseSensitive() { return renameFlags.contains(RenameEnum.CASE); } public void setRenameCaseSensitive(boolean renameCaseSensitive) { updateRenameFlag(renameCaseSensitive, RenameEnum.CASE); } public boolean isRenameValid() { return renameFlags.contains(RenameEnum.VALID); } public void setRenameValid(boolean renameValid) { updateRenameFlag(renameValid, RenameEnum.VALID); } public boolean isRenamePrintable() { return renameFlags.contains(RenameEnum.PRINTABLE); } public void setRenamePrintable(boolean renamePrintable) { updateRenameFlag(renamePrintable, RenameEnum.PRINTABLE); } private void updateRenameFlag(boolean enabled, RenameEnum flag) { if (enabled) { renameFlags.add(flag); } else { renameFlags.remove(flag); } } public void setRenameFlags(Set<RenameEnum> renameFlags) { this.renameFlags = renameFlags; } public Set<RenameEnum> getRenameFlags() { return renameFlags; } public OutputFormatEnum getOutputFormat() { return outputFormat; } public boolean isJsonOutput() { return outputFormat == OutputFormatEnum.JSON; } public void setOutputFormat(OutputFormatEnum outputFormat) { this.outputFormat = outputFormat; } public DecompilationMode getDecompilationMode() { return decompilationMode; } public void setDecompilationMode(DecompilationMode decompilationMode) { this.decompilationMode = decompilationMode; } public ICodeCache getCodeCache() { return codeCache; } public void setCodeCache(ICodeCache codeCache) { this.codeCache = codeCache; } public Function<JadxArgs, ICodeWriter> getCodeWriterProvider() { return codeWriterProvider; } public void setCodeWriterProvider(Function<JadxArgs, ICodeWriter> codeWriterProvider) { this.codeWriterProvider = codeWriterProvider; } public IUsageInfoCache getUsageInfoCache() { return usageInfoCache; } public void setUsageInfoCache(IUsageInfoCache usageInfoCache) { this.usageInfoCache = usageInfoCache; } public ICodeData getCodeData() { return codeData; } public void setCodeData(ICodeData codeData) { this.codeData = codeData; } public String getCodeIndentStr() { return codeIndentStr; } public void setCodeIndentStr(String codeIndentStr) { this.codeIndentStr = codeIndentStr; } public String getCodeNewLineStr() { return codeNewLineStr; } public void setCodeNewLineStr(String codeNewLineStr) { this.codeNewLineStr = codeNewLineStr; } public CommentsLevel getCommentsLevel() { return commentsLevel; } public void setCommentsLevel(CommentsLevel commentsLevel) { this.commentsLevel = commentsLevel; } public IntegerFormat getIntegerFormat() { return integerFormat; } public void setIntegerFormat(IntegerFormat format) { this.integerFormat = format; } public int getTypeUpdatesLimitCount() { return typeUpdatesLimitCount; } public void setTypeUpdatesLimitCount(int typeUpdatesLimitCount) { this.typeUpdatesLimitCount = Math.max(1, typeUpdatesLimitCount); } public boolean isUseDxInput() { return useDxInput; } public void setUseDxInput(boolean useDxInput) { this.useDxInput = useDxInput; } public UseKotlinMethodsForVarNames getUseKotlinMethodsForVarNames() { return useKotlinMethodsForVarNames; } public void setUseKotlinMethodsForVarNames(UseKotlinMethodsForVarNames useKotlinMethodsForVarNames) { this.useKotlinMethodsForVarNames = useKotlinMethodsForVarNames; } public IJadxFilesGetter getFilesGetter() { return filesGetter; } public void setFilesGetter(IJadxFilesGetter filesGetter) { this.filesGetter = filesGetter; } public IJadxSecurity getSecurity() { return security; } public void setSecurity(IJadxSecurity security) { this.security = security; } public boolean isSkipFilesSave() { return skipFilesSave; } public void setSkipFilesSave(boolean skipFilesSave) { this.skipFilesSave = skipFilesSave; } public boolean isRunDebugChecks() { return runDebugChecks; } public void setRunDebugChecks(boolean runDebugChecks) { this.runDebugChecks = runDebugChecks; } public List<String> getDisabledPasses() { return disabledPasses; } public Map<String, String> getPluginOptions() { return pluginOptions; } public void setPluginOptions(Map<String, String> pluginOptions) { this.pluginOptions = pluginOptions; } public Set<String> getDisabledPlugins() { return disabledPlugins; } public void setDisabledPlugins(Set<String> disabledPlugins) { this.disabledPlugins = disabledPlugins; } public JadxPluginLoader getPluginLoader() { return pluginLoader; } public void setPluginLoader(JadxPluginLoader pluginLoader) { this.pluginLoader = pluginLoader; } public boolean isLoadJadxClsSetFile() { return loadJadxClsSetFile; } public void setLoadJadxClsSetFile(boolean loadJadxClsSetFile) { this.loadJadxClsSetFile = loadJadxClsSetFile; } public void setUseHeadersForDetectResourceExtensions(boolean useHeadersForDetectResourceExtensions) { this.useHeadersForDetectResourceExtensions = useHeadersForDetectResourceExtensions; } public boolean isUseHeadersForDetectResourceExtensions() { return useHeadersForDetectResourceExtensions; } /** * Hash of all options that can change result code */ public String makeCodeArgsHash(@Nullable JadxDecompiler decompiler) { String argStr = "args:" + decompilationMode + useImports + showInconsistentCode + inlineAnonymousClasses + inlineMethods + moveInnerClasses + allowInlineKotlinLambda + deobfuscationOn + deobfuscationMinLength + deobfuscationMaxLength + deobfuscationWhitelist + useSourceNameAsClassNameAlias + sourceNameRepeatLimit + resourceNameSource + useHeadersForDetectResourceExtensions + useKotlinMethodsForVarNames + insertDebugLines + extractFinally + debugInfo + escapeUnicode + replaceConsts + restoreSwitchOverString + respectBytecodeAccModifiers + fsCaseSensitive + renameFlags + commentsLevel + useDxInput + integerFormat + typeUpdatesLimitCount + "|" + buildPluginsHash(decompiler); return FileUtils.md5Sum(argStr); } private static String buildPluginsHash(@Nullable JadxDecompiler decompiler) { if (decompiler == null) { return ""; } return decompiler.getPluginManager().getResolvedPluginContexts() .stream() .map(PluginContext::getInputsHash) .collect(Collectors.joining(":")); } @Override public String toString() { return "JadxArgs{" + "inputFiles=" + inputFiles + ", outDir=" + outDir + ", outDirSrc=" + outDirSrc + ", outDirRes=" + outDirRes + ", threadsCount=" + threadsCount + ", decompilationMode=" + decompilationMode + ", showInconsistentCode=" + showInconsistentCode + ", useImports=" + useImports + ", skipResources=" + skipResources + ", skipSources=" + skipSources + ", includeDependencies=" + includeDependencies + ", userRenamesMappingsPath=" + userRenamesMappingsPath + ", userRenamesMappingsMode=" + userRenamesMappingsMode + ", deobfuscationOn=" + deobfuscationOn + ", generatedRenamesMappingFile=" + generatedRenamesMappingFile + ", generatedRenamesMappingFileMode=" + generatedRenamesMappingFileMode + ", resourceNameSource=" + resourceNameSource + ", useSourceNameAsClassNameAlias=" + useSourceNameAsClassNameAlias + ", sourceNameRepeatLimit=" + sourceNameRepeatLimit + ", useKotlinMethodsForVarNames=" + useKotlinMethodsForVarNames + ", insertDebugLines=" + insertDebugLines + ", extractFinally=" + extractFinally + ", deobfuscationMinLength=" + deobfuscationMinLength + ", deobfuscationMaxLength=" + deobfuscationMaxLength + ", deobfuscationWhitelist=" + deobfuscationWhitelist + ", escapeUnicode=" + escapeUnicode + ", replaceConsts=" + replaceConsts + ", restoreSwitchOverString=" + restoreSwitchOverString + ", respectBytecodeAccModifiers=" + respectBytecodeAccModifiers + ", exportGradleType=" + exportGradleType + ", skipXmlPrettyPrint=" + skipXmlPrettyPrint + ", fsCaseSensitive=" + fsCaseSensitive + ", renameFlags=" + renameFlags + ", outputFormat=" + outputFormat + ", commentsLevel=" + commentsLevel + ", codeCache=" + codeCache + ", codeWriter=" + codeWriterProvider.apply(this).getClass().getSimpleName() + ", useDxInput=" + useDxInput + ", pluginOptions=" + pluginOptions + ", cfgOutput=" + cfgOutput + ", rawCFGOutput=" + rawCFGOutput + ", useHeadersForDetectResourceExtensions=" + useHeadersForDetectResourceExtensions + ", typeUpdatesLimitCount=" + typeUpdatesLimitCount + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/JavaClass.java
jadx-core/src/main/java/jadx/api/JavaClass.java
package jadx.api; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import jadx.api.metadata.ICodeAnnotation; import jadx.api.metadata.ICodeNodeRef; import jadx.core.dex.attributes.AFlag; import jadx.core.dex.attributes.AType; import jadx.core.dex.attributes.nodes.AnonymousClassAttr; import jadx.core.dex.attributes.nodes.InlinedAttr; import jadx.core.dex.info.AccessInfo; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.FieldNode; import jadx.core.dex.nodes.MethodNode; import jadx.core.utils.ListUtils; public final class JavaClass implements JavaNode { private static final Logger LOG = LoggerFactory.getLogger(JavaClass.class); private final JadxDecompiler decompiler; private final ClassNode cls; private final JavaClass parent; private List<JavaClass> innerClasses = Collections.emptyList(); private List<JavaClass> inlinedClasses = Collections.emptyList(); private List<JavaField> fields = Collections.emptyList(); private List<JavaMethod> methods = Collections.emptyList(); private boolean listsLoaded; JavaClass(ClassNode classNode, JadxDecompiler decompiler) { this.decompiler = decompiler; this.cls = classNode; this.parent = null; } /** * Inner classes constructor */ JavaClass(ClassNode classNode, JavaClass parent) { this.decompiler = null; this.cls = classNode; this.parent = parent; } public String getCode() { return getCodeInfo().getCodeStr(); } public @NotNull ICodeInfo getCodeInfo() { ICodeInfo code = load(); if (code != null) { return code; } return cls.decompile(); } public void decompile() { load(); } public synchronized ICodeInfo reload() { listsLoaded = false; return cls.reloadCode(); } public void unload() { listsLoaded = false; cls.unloadCode(); } public boolean isNoCode() { return cls.contains(AFlag.DONT_GENERATE); } public boolean isInner() { return cls.isInner(); } public synchronized String getSmali() { return cls.getDisassembledCode(); } @Override public boolean isOwnCodeAnnotation(ICodeAnnotation ann) { if (ann.getAnnType() == ICodeAnnotation.AnnType.CLASS) { return ann.equals(cls); } return false; } @Override public ICodeNodeRef getCodeNodeRef() { return cls; } /** * Internal API. Not Stable! */ @ApiStatus.Internal public ClassNode getClassNode() { return cls; } /** * Decompile class and loads internal lists of fields, methods, etc. * Do nothing if already loaded. * * @return code info if decompilation was executed, null otherwise */ private synchronized @Nullable ICodeInfo load() { if (listsLoaded) { return null; } ICodeInfo code; if (cls.getState().isProcessComplete()) { // already decompiled -> class internals loaded code = null; } else { code = cls.decompile(); } loadLists(); return code; } private void loadLists() { listsLoaded = true; JadxDecompiler rootDecompiler = getRootDecompiler(); int inClsCount = cls.getInnerClasses().size(); if (inClsCount != 0) { List<JavaClass> list = new ArrayList<>(inClsCount); for (ClassNode inner : cls.getInnerClasses()) { if (!inner.contains(AFlag.DONT_GENERATE)) { JavaClass javaClass = rootDecompiler.convertClassNode(inner); javaClass.loadLists(); list.add(javaClass); } } this.innerClasses = Collections.unmodifiableList(list); } int inlinedClsCount = cls.getInlinedClasses().size(); if (inlinedClsCount != 0) { List<JavaClass> list = new ArrayList<>(inlinedClsCount); for (ClassNode inner : cls.getInlinedClasses()) { JavaClass javaClass = rootDecompiler.convertClassNode(inner); javaClass.loadLists(); list.add(javaClass); } this.inlinedClasses = Collections.unmodifiableList(list); } int fieldsCount = cls.getFields().size(); if (fieldsCount != 0) { List<JavaField> flds = new ArrayList<>(fieldsCount); for (FieldNode f : cls.getFields()) { if (!f.contains(AFlag.DONT_GENERATE)) { flds.add(rootDecompiler.convertFieldNode(f)); } } this.fields = Collections.unmodifiableList(flds); } int methodsCount = cls.getMethods().size(); if (methodsCount != 0) { List<JavaMethod> mths = new ArrayList<>(methodsCount); for (MethodNode m : cls.getMethods()) { if (!m.contains(AFlag.DONT_GENERATE)) { mths.add(rootDecompiler.convertMethodNode(m)); } } mths.sort(Comparator.comparing(JavaMethod::getName)); this.methods = Collections.unmodifiableList(mths); } } JadxDecompiler getRootDecompiler() { if (parent != null) { return parent.getRootDecompiler(); } return decompiler; } public ICodeAnnotation getAnnotationAt(int pos) { return getCodeInfo().getCodeMetadata().getAt(pos); } public Map<Integer, JavaNode> getUsageMap() { Map<Integer, ICodeAnnotation> map = getCodeInfo().getCodeMetadata().getAsMap(); if (map.isEmpty() || decompiler == null) { return Collections.emptyMap(); } Map<Integer, JavaNode> resultMap = new HashMap<>(map.size()); for (Map.Entry<Integer, ICodeAnnotation> entry : map.entrySet()) { int codePosition = entry.getKey(); ICodeAnnotation obj = entry.getValue(); if (obj instanceof ICodeNodeRef) { JavaNode node = getRootDecompiler().getJavaNodeByRef((ICodeNodeRef) obj); if (node != null) { resultMap.put(codePosition, node); } } } return resultMap; } public List<Integer> getUsePlacesFor(ICodeInfo codeInfo, JavaNode javaNode) { if (!codeInfo.hasMetadata()) { return Collections.emptyList(); } List<Integer> result = new ArrayList<>(); codeInfo.getCodeMetadata().searchDown(0, (pos, ann) -> { if (javaNode.isOwnCodeAnnotation(ann)) { result.add(pos); } return null; }); return result; } @Override public List<JavaNode> getUseIn() { return getRootDecompiler().convertNodes(cls.getUseIn()); } public Integer getSourceLine(int decompiledLine) { return getCodeInfo().getCodeMetadata().getLineMapping().get(decompiledLine); } @Override public String getName() { return cls.getShortName(); } @Override public String getFullName() { return cls.getFullName(); } public String getRawName() { return cls.getRawName(); } public String getPackage() { return cls.getPackage(); } public JavaPackage getJavaPackage() { return cls.getPackageNode().getJavaNode(); } @Override public JavaClass getDeclaringClass() { return parent; } public JavaClass getOriginalTopParentClass() { return parent == null ? this : parent.getOriginalTopParentClass(); } /** * Return top parent class which contains code of this class. * Code parent can be different from original parent after move or inline * * @return this if already a top class */ @Override public JavaClass getTopParentClass() { JavaClass codeParent = getCodeParent(); return codeParent == null ? this : codeParent.getTopParentClass(); } /** * Return parent class which contains code of this class. * Code parent can be different for original parent after move or inline */ public @Nullable JavaClass getCodeParent() { AnonymousClassAttr anonymousClsAttr = cls.get(AType.ANONYMOUS_CLASS); if (anonymousClsAttr != null) { // moved to usage class return getRootDecompiler().convertClassNode(anonymousClsAttr.getOuterCls()); } InlinedAttr inlinedAttr = cls.get(AType.INLINED); if (inlinedAttr != null) { return getRootDecompiler().convertClassNode(inlinedAttr.getInlineCls()); } return parent; } public AccessInfo getAccessInfo() { return cls.getAccessFlags(); } public List<JavaClass> getInnerClasses() { load(); return innerClasses; } public List<JavaClass> getInlinedClasses() { load(); return inlinedClasses; } public List<JavaField> getFields() { load(); return fields; } public List<JavaMethod> getMethods() { load(); return methods; } @Nullable public JavaMethod searchMethodByShortId(String shortId) { MethodNode methodNode = cls.searchMethodByShortId(shortId); if (methodNode == null) { return null; } return getRootDecompiler().convertMethodNode(methodNode); } public List<JavaClass> getDependencies() { JadxDecompiler d = getRootDecompiler(); return ListUtils.map(cls.getDependencies(), d::convertClassNode); } public int getTotalDepsCount() { return cls.getTotalDepsCount(); } @Override public void removeAlias() { cls.removeAlias(); } @Override public int getDefPos() { return cls.getDefPosition(); } @Override public boolean equals(Object o) { return this == o || o instanceof JavaClass && cls.equals(((JavaClass) o).cls); } @Override public int hashCode() { return cls.hashCode(); } @Override public String toString() { return getFullName(); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/JadxArgsValidator.java
jadx-core/src/main/java/jadx/api/JadxArgsValidator.java
package jadx.api; import java.io.File; import java.util.List; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import jadx.core.utils.exceptions.JadxArgsValidateException; public class JadxArgsValidator { private static final Logger LOG = LoggerFactory.getLogger(JadxArgsValidator.class); public static void validate(JadxDecompiler jadx) { JadxArgs args = jadx.getArgs(); checkInputFiles(jadx, args); validateOutDirs(args); if (LOG.isDebugEnabled()) { LOG.debug("Effective jadx args: {}", args); } } private static void checkInputFiles(JadxDecompiler jadx, JadxArgs args) { List<File> inputFiles = args.getInputFiles(); if (inputFiles.isEmpty() && jadx.getCustomCodeLoaders().isEmpty()) { throw new JadxArgsValidateException("Please specify input file"); } for (File file : inputFiles) { checkFile(file); } } private static void validateOutDirs(JadxArgs args) { File outDir = args.getOutDir(); File srcDir = args.getOutDirSrc(); File resDir = args.getOutDirRes(); if (outDir == null) { if (srcDir != null) { outDir = srcDir; } else if (resDir != null) { outDir = resDir; } else { outDir = makeDirFromInput(args); } args.setOutDir(outDir); } if (srcDir == null) { args.setOutDirSrc(new File(args.getOutDir(), JadxArgs.DEFAULT_SRC_DIR)); } if (resDir == null) { args.setOutDirRes(new File(args.getOutDir(), JadxArgs.DEFAULT_RES_DIR)); } checkDir(args.getOutDir(), "Output"); checkDir(args.getOutDirSrc(), "Source output"); checkDir(args.getOutDirRes(), "Resources output"); } @NotNull private static File makeDirFromInput(JadxArgs args) { String outDirName; List<File> inputFiles = args.getInputFiles(); if (inputFiles.isEmpty()) { outDirName = JadxArgs.DEFAULT_OUT_DIR; } else { File file = inputFiles.get(0); String name = file.getName(); int pos = name.lastIndexOf('.'); if (pos != -1) { outDirName = name.substring(0, pos); } else { outDirName = name + '-' + JadxArgs.DEFAULT_OUT_DIR; } } LOG.info("output directory: {}", outDirName); return new File(outDirName); } private static void checkFile(File file) { if (!file.exists()) { throw new JadxArgsValidateException("File not found " + file.getAbsolutePath()); } } private static void checkDir(File dir, String desc) { if (dir != null && dir.exists() && !dir.isDirectory()) { throw new JadxArgsValidateException(desc + " directory exists as file " + dir); } } private JadxArgsValidator() { } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/ResourceType.java
jadx-core/src/main/java/jadx/api/ResourceType.java
package jadx.api; import java.util.HashMap; import java.util.Locale; import java.util.Map; import jadx.api.resources.ResourceContentType; import jadx.core.utils.exceptions.JadxRuntimeException; import static jadx.api.resources.ResourceContentType.CONTENT_BINARY; import static jadx.api.resources.ResourceContentType.CONTENT_TEXT; import static jadx.api.resources.ResourceContentType.CONTENT_UNKNOWN; public enum ResourceType { CODE(CONTENT_BINARY, ".dex", ".jar", ".class"), XML(CONTENT_TEXT, ".xml"), ARSC(CONTENT_TEXT, ".arsc"), APK(CONTENT_BINARY, ".apk", ".apkm", ".apks"), FONT(CONTENT_BINARY, ".ttf", ".ttc", ".otf"), IMG(CONTENT_BINARY, ".png", ".gif", ".jpg", ".jpeg", ".webp", ".bmp", ".tiff"), ARCHIVE(CONTENT_BINARY, ".zip", ".rar", ".7zip", ".7z", ".arj", ".tar", ".gzip", ".bzip", ".bzip2", ".cab", ".cpio", ".ar", ".gz", ".tgz", ".bz2"), VIDEOS(CONTENT_BINARY, ".mp4", ".mkv", ".webm", ".avi", ".flv", ".3gp"), SOUNDS(CONTENT_BINARY, ".aac", ".ogg", ".opus", ".mp3", ".wav", ".wma", ".mid", ".midi"), JSON(CONTENT_TEXT, ".json"), TEXT(CONTENT_TEXT, ".txt", ".ini", ".conf", ".yaml", ".properties", ".js", ".java", ".kt", ".md"), HTML(CONTENT_TEXT, ".html", ".htm"), LIB(CONTENT_BINARY, ".so"), MANIFEST(CONTENT_TEXT), UNKNOWN_BIN(CONTENT_BINARY, ".bin"), UNKNOWN(CONTENT_UNKNOWN); private final ResourceContentType contentType; private final String[] exts; ResourceType(ResourceContentType contentType, String... exts) { this.contentType = contentType; this.exts = exts; } public ResourceContentType getContentType() { return contentType; } public String[] getExts() { return exts; } private static final Map<String, ResourceType> EXT_MAP = new HashMap<>(); static { for (ResourceType type : ResourceType.values()) { for (String ext : type.getExts()) { ResourceType prev = EXT_MAP.put(ext, type); if (prev != null) { throw new JadxRuntimeException("Duplicate extension in ResourceType: " + ext); } } } } public static ResourceType getFileType(String fileName) { if (fileName.endsWith("/resources.pb")) { return ARSC; } int dot = fileName.lastIndexOf('.'); if (dot != -1) { String ext = fileName.substring(dot).toLowerCase(Locale.ROOT); ResourceType resType = EXT_MAP.get(ext); if (resType != null) { if (resType == XML && fileName.equals("AndroidManifest.xml")) { return MANIFEST; } return resType; } } return UNKNOWN; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/ResourceFile.java
jadx-core/src/main/java/jadx/api/ResourceFile.java
package jadx.api; import java.io.File; import org.jetbrains.annotations.Nullable; import jadx.core.deobf.FileTypeDetector; import jadx.core.utils.StringUtils; import jadx.core.utils.exceptions.JadxException; import jadx.core.xmlgen.ResContainer; import jadx.core.xmlgen.entry.ResourceEntry; import jadx.zip.IZipEntry; public class ResourceFile { private final JadxDecompiler decompiler; private final String name; private ResourceType type; private @Nullable IZipEntry zipEntry; private String deobfName; public static ResourceFile createResourceFile(JadxDecompiler decompiler, File file, ResourceType type) { return new ResourceFile(decompiler, file.getAbsolutePath(), type); } public static ResourceFile createResourceFile(JadxDecompiler decompiler, String name, ResourceType type) { if (!decompiler.getArgs().getSecurity().isValidEntryName(name)) { return null; } return new ResourceFile(decompiler, name, type); } protected ResourceFile(JadxDecompiler decompiler, String name, ResourceType type) { this.decompiler = decompiler; this.name = name; this.type = type; } public String getOriginalName() { return name; } public String getDeobfName() { return deobfName != null ? deobfName : name; } public void setDeobfName(String resFullName) { this.deobfName = resFullName; } public ResourceType getType() { return type; } public ResContainer loadContent() { return ResourcesLoader.loadContent(decompiler, this); } public boolean setAlias(ResourceEntry entry, boolean useHeaders) { StringBuilder sb = new StringBuilder(); sb.append("res/").append(entry.getTypeName()).append(entry.getConfig()); sb.append("/").append(entry.getKeyName()); if (useHeaders) { try { int maxBytesToReadLimit = 4096; byte[] bytes = ResourcesLoader.decodeStream(this, (size, is) -> { int bytesToRead; if (size > 0) { bytesToRead = (int) Math.min(size, maxBytesToReadLimit); } else if (size == 0) { bytesToRead = 0; } else { bytesToRead = maxBytesToReadLimit; } if (bytesToRead == 0) { return new byte[0]; } return is.readNBytes(bytesToRead); }); String fileExtension = FileTypeDetector.detectFileExtension(bytes); if (!StringUtils.isEmpty(fileExtension)) { sb.append(fileExtension); } else { sb.append(getExtFromName(name)); } } catch (JadxException ignored) { } } else { sb.append(getExtFromName(name)); } String alias = sb.toString(); if (!alias.equals(name)) { setDeobfName(alias); type = ResourceType.getFileType(alias); return true; } return false; } private String getExtFromName(String name) { // the image .9.png extension always saved, when resource shrinking by aapt2 if (name.contains(".9.png")) { return ".9.png"; } int lastDot = name.lastIndexOf('.'); if (lastDot != -1) { return name.substring(lastDot); } return ""; } public @Nullable IZipEntry getZipEntry() { return zipEntry; } void setZipEntry(@Nullable IZipEntry zipEntry) { this.zipEntry = zipEntry; } public JadxDecompiler getDecompiler() { return decompiler; } @Override public String toString() { return "ResourceFile{name='" + name + '\'' + ", type=" + type + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/metadata/ICodeMetadata.java
jadx-core/src/main/java/jadx/api/metadata/ICodeMetadata.java
package jadx.api.metadata; import java.util.Map; import java.util.function.BiFunction; import org.jetbrains.annotations.Nullable; import jadx.api.metadata.impl.CodeMetadataStorage; public interface ICodeMetadata { ICodeMetadata EMPTY = CodeMetadataStorage.empty(); @Nullable ICodeAnnotation getAt(int position); @Nullable ICodeAnnotation getClosestUp(int position); @Nullable ICodeAnnotation searchUp(int position, ICodeAnnotation.AnnType annType); @Nullable ICodeAnnotation searchUp(int position, int limitPos, ICodeAnnotation.AnnType annType); /** * Iterate code annotations from {@code startPos} to smaller positions. * * @param visitor * return not null value to stop iterations */ @Nullable <T> T searchUp(int startPos, BiFunction<Integer, ICodeAnnotation, T> visitor); /** * Iterate code annotations from {@code startPos} to higher positions. * * @param visitor * return not null value to stop iterations */ @Nullable <T> T searchDown(int startPos, BiFunction<Integer, ICodeAnnotation, T> visitor); /** * Get current node at position (can be enclosing class or method) */ @Nullable ICodeNodeRef getNodeAt(int position); /** * Any definition of class or method below position */ @Nullable ICodeNodeRef getNodeBelow(int position); Map<Integer, ICodeAnnotation> getAsMap(); Map<Integer, Integer> getLineMapping(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/metadata/ICodeNodeRef.java
jadx-core/src/main/java/jadx/api/metadata/ICodeNodeRef.java
package jadx.api.metadata; public interface ICodeNodeRef extends ICodeAnnotation { int getDefPosition(); void setDefPosition(int pos); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/metadata/ICodeAnnotation.java
jadx-core/src/main/java/jadx/api/metadata/ICodeAnnotation.java
package jadx.api.metadata; public interface ICodeAnnotation { enum AnnType { CLASS, FIELD, METHOD, PKG, VAR, VAR_REF, DECLARATION, OFFSET, END // class or method body end } AnnType getAnnType(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/metadata/annotations/VarNode.java
jadx-core/src/main/java/jadx/api/metadata/annotations/VarNode.java
package jadx.api.metadata.annotations; import org.jetbrains.annotations.Nullable; import jadx.api.metadata.ICodeAnnotation; import jadx.api.metadata.ICodeNodeRef; import jadx.core.dex.instructions.args.ArgType; import jadx.core.dex.instructions.args.CodeVar; import jadx.core.dex.instructions.args.RegisterArg; import jadx.core.dex.instructions.args.SSAVar; import jadx.core.dex.nodes.MethodNode; /** * Variable info */ public class VarNode implements ICodeNodeRef { @Nullable public static VarNode get(MethodNode mth, RegisterArg reg) { SSAVar ssaVar = reg.getSVar(); if (ssaVar == null) { return null; } return get(mth, ssaVar); } @Nullable public static VarNode get(MethodNode mth, CodeVar codeVar) { return get(mth, codeVar.getAnySsaVar()); } @Nullable public static VarNode get(MethodNode mth, SSAVar ssaVar) { CodeVar codeVar = ssaVar.getCodeVar(); if (codeVar.isThis()) { return null; } VarNode cachedVarNode = codeVar.getCachedVarNode(); if (cachedVarNode != null) { return cachedVarNode; } VarNode newVarNode = new VarNode(mth, ssaVar); codeVar.setCachedVarNode(newVarNode); return newVarNode; } @Nullable public static ICodeAnnotation getRef(MethodNode mth, RegisterArg reg) { VarNode varNode = get(mth, reg); if (varNode == null) { return null; } return varNode.getVarRef(); } private final MethodNode mth; private final int reg; private final int ssa; private final ArgType type; private @Nullable String name; private int defPos; private final VarRef varRef; protected VarNode(MethodNode mth, SSAVar ssaVar) { this(mth, ssaVar.getRegNum(), ssaVar.getVersion(), ssaVar.getCodeVar().getType(), ssaVar.getCodeVar().getName()); } public VarNode(MethodNode mth, int reg, int ssa, ArgType type, String name) { this.mth = mth; this.reg = reg; this.ssa = ssa; this.type = type; this.name = name; this.varRef = VarRef.fromVarNode(this); } public MethodNode getMth() { return mth; } public int getReg() { return reg; } public int getSsa() { return ssa; } public ArgType getType() { return type; } @Nullable public String getName() { return name; } public void setName(String name) { this.name = name; } public VarRef getVarRef() { return varRef; } @Override public int getDefPosition() { return defPos; } @Override public void setDefPosition(int pos) { this.defPos = pos; } @Override public AnnType getAnnType() { return AnnType.VAR; } @Override public int hashCode() { int h = 31 * getReg() + getSsa(); return 31 * h + mth.hashCode(); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof VarNode)) { return false; } VarNode other = (VarNode) o; return getReg() == other.getReg() && getSsa() == other.getSsa() && getMth().equals(other.getMth()); } @Override public String toString() { return "VarNode{r" + reg + 'v' + ssa + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/metadata/annotations/InsnCodeOffset.java
jadx-core/src/main/java/jadx/api/metadata/annotations/InsnCodeOffset.java
package jadx.api.metadata.annotations; import org.jetbrains.annotations.Nullable; import jadx.api.ICodeWriter; import jadx.api.metadata.ICodeAnnotation; import jadx.core.dex.nodes.InsnNode; public class InsnCodeOffset implements ICodeAnnotation { public static void attach(ICodeWriter code, InsnNode insn) { if (insn == null) { return; } if (code.isMetadataSupported()) { InsnCodeOffset ann = from(insn); if (ann != null) { code.attachLineAnnotation(ann); } } } public static void attach(ICodeWriter code, int offset) { if (offset >= 0 && code.isMetadataSupported()) { code.attachLineAnnotation(new InsnCodeOffset(offset)); } } @Nullable public static InsnCodeOffset from(InsnNode insn) { int offset = insn.getOffset(); if (offset < 0) { return null; } return new InsnCodeOffset(offset); } private final int offset; public InsnCodeOffset(int offset) { this.offset = offset; } public int getOffset() { return offset; } @Override public AnnType getAnnType() { return AnnType.OFFSET; } @Override public String toString() { return "offset=" + offset; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/metadata/annotations/NodeEnd.java
jadx-core/src/main/java/jadx/api/metadata/annotations/NodeEnd.java
package jadx.api.metadata.annotations; import jadx.api.metadata.ICodeAnnotation; public class NodeEnd implements ICodeAnnotation { public static final NodeEnd VALUE = new NodeEnd(); private NodeEnd() { } @Override public AnnType getAnnType() { return AnnType.END; } @Override public String toString() { return "END"; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/metadata/annotations/NodeDeclareRef.java
jadx-core/src/main/java/jadx/api/metadata/annotations/NodeDeclareRef.java
package jadx.api.metadata.annotations; import java.util.Objects; import jadx.api.metadata.ICodeAnnotation; import jadx.api.metadata.ICodeNodeRef; public class NodeDeclareRef implements ICodeAnnotation { private final ICodeNodeRef node; private int defPos; public NodeDeclareRef(ICodeNodeRef node) { this.node = Objects.requireNonNull(node); } public ICodeNodeRef getNode() { return node; } public int getDefPos() { return defPos; } public void setDefPos(int defPos) { this.defPos = defPos; } @Override public AnnType getAnnType() { return AnnType.DECLARATION; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof NodeDeclareRef)) { return false; } return node.equals(((NodeDeclareRef) o).node); } @Override public int hashCode() { return node.hashCode(); } @Override public String toString() { return "NodeDeclareRef{" + node + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/metadata/annotations/VarRef.java
jadx-core/src/main/java/jadx/api/metadata/annotations/VarRef.java
package jadx.api.metadata.annotations; import jadx.api.metadata.ICodeAnnotation; /** * Variable reference by position of VarNode in code metadata. * <br> * Because on creation position not yet known, * VarRef created using VarNode as a source of ref pos during serialization. * <br> * On metadata deserialization created with ref pos directly. */ public abstract class VarRef implements ICodeAnnotation { public static VarRef fromPos(int refPos) { if (refPos == 0) { throw new IllegalArgumentException("Zero refPos"); } return new FixedVarRef(refPos); } public static VarRef fromVarNode(VarNode varNode) { return new RelatedVarRef(varNode); } public abstract int getRefPos(); @Override public AnnType getAnnType() { return AnnType.VAR_REF; } public static final class FixedVarRef extends VarRef { private final int refPos; public FixedVarRef(int refPos) { this.refPos = refPos; } @Override public int getRefPos() { return refPos; } } public static final class RelatedVarRef extends VarRef { private final VarNode varNode; public RelatedVarRef(VarNode varNode) { this.varNode = varNode; } @Override public int getRefPos() { return varNode.getDefPosition(); } @Override public String toString() { return "VarRef{" + varNode + ", name=" + varNode.getName() + ", mth=" + varNode.getMth() + '}'; } } @Override public String toString() { return "VarRef{" + getRefPos() + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/metadata/impl/CodeMetadataStorage.java
jadx-core/src/main/java/jadx/api/metadata/impl/CodeMetadataStorage.java
package jadx.api.metadata.impl; import java.util.Collections; import java.util.Comparator; import java.util.Map; import java.util.NavigableMap; import java.util.TreeMap; import java.util.function.BiFunction; import org.jetbrains.annotations.Nullable; import jadx.api.metadata.ICodeAnnotation; import jadx.api.metadata.ICodeAnnotation.AnnType; import jadx.api.metadata.ICodeMetadata; import jadx.api.metadata.ICodeNodeRef; import jadx.api.metadata.annotations.NodeDeclareRef; import jadx.core.utils.Utils; public class CodeMetadataStorage implements ICodeMetadata { public static ICodeMetadata build(Map<Integer, Integer> lines, Map<Integer, ICodeAnnotation> map) { if (map.isEmpty() && lines.isEmpty()) { return ICodeMetadata.EMPTY; } Comparator<Integer> reverseCmp = Comparator.comparingInt(Integer::intValue).reversed(); NavigableMap<Integer, ICodeAnnotation> navMap = new TreeMap<>(reverseCmp); navMap.putAll(map); return new CodeMetadataStorage(lines, navMap); } public static ICodeMetadata empty() { return new CodeMetadataStorage(Collections.emptyMap(), Collections.emptyNavigableMap()); } private final Map<Integer, Integer> lines; private final NavigableMap<Integer, ICodeAnnotation> navMap; private CodeMetadataStorage(Map<Integer, Integer> lines, NavigableMap<Integer, ICodeAnnotation> navMap) { this.lines = lines; this.navMap = navMap; } @Override public ICodeAnnotation getAt(int position) { return navMap.get(position); } @Override public @Nullable ICodeAnnotation getClosestUp(int position) { Map.Entry<Integer, ICodeAnnotation> entryBefore = navMap.higherEntry(position); return entryBefore != null ? entryBefore.getValue() : null; } @Override public @Nullable ICodeAnnotation searchUp(int position, AnnType annType) { for (ICodeAnnotation v : navMap.tailMap(position, true).values()) { if (v.getAnnType() == annType) { return v; } } return null; } @Override public @Nullable ICodeAnnotation searchUp(int position, int limitPos, AnnType annType) { for (ICodeAnnotation v : navMap.subMap(position, true, limitPos, true).values()) { if (v.getAnnType() == annType) { return v; } } return null; } @Override public <T> @Nullable T searchUp(int startPos, BiFunction<Integer, ICodeAnnotation, T> visitor) { for (Map.Entry<Integer, ICodeAnnotation> entry : navMap.tailMap(startPos, true).entrySet()) { T value = visitor.apply(entry.getKey(), entry.getValue()); if (value != null) { return value; } } return null; } @Override public <T> @Nullable T searchDown(int startPos, BiFunction<Integer, ICodeAnnotation, T> visitor) { NavigableMap<Integer, ICodeAnnotation> map = navMap.headMap(startPos, true).descendingMap(); for (Map.Entry<Integer, ICodeAnnotation> entry : map.entrySet()) { T value = visitor.apply(entry.getKey(), entry.getValue()); if (value != null) { return value; } } return null; } @Override public ICodeNodeRef getNodeAt(int position) { int nesting = 0; for (ICodeAnnotation ann : navMap.tailMap(position, true).values()) { switch (ann.getAnnType()) { case END: nesting++; break; case DECLARATION: ICodeNodeRef node = ((NodeDeclareRef) ann).getNode(); AnnType nodeType = node.getAnnType(); if (nodeType == AnnType.CLASS || nodeType == AnnType.METHOD) { if (nesting == 0) { return node; } nesting--; } break; } } return null; } @Override public ICodeNodeRef getNodeBelow(int position) { for (ICodeAnnotation ann : navMap.headMap(position, true).descendingMap().values()) { if (ann.getAnnType() == AnnType.DECLARATION) { ICodeNodeRef node = ((NodeDeclareRef) ann).getNode(); AnnType nodeType = node.getAnnType(); if (nodeType == AnnType.CLASS || nodeType == AnnType.METHOD) { return node; } } } return null; } @Override public NavigableMap<Integer, ICodeAnnotation> getAsMap() { return navMap; } @Override public Map<Integer, Integer> getLineMapping() { return lines; } @Override public String toString() { return "CodeMetadata{\nlines=" + lines + "\nannotations=\n " + Utils.listToString(navMap.descendingMap().entrySet(), "\n ") + "\n}"; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/InMemoryCodeCache.java
jadx-core/src/main/java/jadx/api/impl/InMemoryCodeCache.java
package jadx.api.impl; import java.io.IOException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import jadx.api.ICodeCache; import jadx.api.ICodeInfo; public class InMemoryCodeCache implements ICodeCache { private final Map<String, ICodeInfo> storage = new ConcurrentHashMap<>(); @Override public void add(String clsFullName, ICodeInfo codeInfo) { storage.put(clsFullName, codeInfo); } @Override public void remove(String clsFullName) { storage.remove(clsFullName); } @NotNull @Override public ICodeInfo get(String clsFullName) { ICodeInfo codeInfo = storage.get(clsFullName); if (codeInfo == null) { return ICodeInfo.EMPTY; } return codeInfo; } @Override public @Nullable String getCode(String clsFullName) { ICodeInfo codeInfo = storage.get(clsFullName); if (codeInfo == null) { return null; } return codeInfo.getCodeStr(); } @Override public boolean contains(String clsFullName) { return storage.containsKey(clsFullName); } @Override public void close() throws IOException { storage.clear(); } @Override public String toString() { return "InMemoryCodeCache: size=" + storage.size(); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/AnnotatedCodeWriter.java
jadx-core/src/main/java/jadx/api/impl/AnnotatedCodeWriter.java
package jadx.api.impl; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; import jadx.api.ICodeInfo; import jadx.api.ICodeWriter; import jadx.api.JadxArgs; import jadx.api.metadata.ICodeAnnotation; import jadx.api.metadata.ICodeNodeRef; import jadx.api.metadata.annotations.NodeDeclareRef; import jadx.core.utils.StringUtils; public class AnnotatedCodeWriter extends SimpleCodeWriter implements ICodeWriter { private int line = 1; private int offset; private Map<Integer, ICodeAnnotation> annotations = Collections.emptyMap(); private Map<Integer, Integer> lineMap = Collections.emptyMap(); public AnnotatedCodeWriter(JadxArgs args) { super(args); } @Override public boolean isMetadataSupported() { return true; } @Override public AnnotatedCodeWriter addMultiLine(String str) { if (str.contains(newLineStr)) { buf.append(str.replace(newLineStr, newLineStr + indentStr)); line += StringUtils.countMatches(str, newLineStr); offset = 0; } else { buf.append(str); } return this; } @Override public AnnotatedCodeWriter add(String str) { buf.append(str); offset += str.length(); return this; } @Override public AnnotatedCodeWriter add(char c) { buf.append(c); offset++; return this; } @Override public ICodeWriter add(ICodeWriter cw) { if (!cw.isMetadataSupported()) { buf.append(cw.getCodeStr()); return this; } AnnotatedCodeWriter code = (AnnotatedCodeWriter) cw; line--; int startPos = getLength(); for (Map.Entry<Integer, ICodeAnnotation> entry : code.annotations.entrySet()) { int pos = entry.getKey(); int newPos = startPos + pos; attachAnnotation(entry.getValue(), newPos); } for (Map.Entry<Integer, Integer> entry : code.lineMap.entrySet()) { attachSourceLine(line + entry.getKey(), entry.getValue()); } line += code.line; offset = code.offset; buf.append(code.buf); return this; } @Override protected void addLine() { buf.append(newLineStr); line++; offset = 0; } @Override protected AnnotatedCodeWriter addLineIndent() { buf.append(indentStr); offset += indentStr.length(); return this; } @Override public int getLine() { return line; } @Override public int getLineStartPos() { return getLength() - offset; } @Override public void attachDefinition(ICodeNodeRef obj) { if (obj == null) { return; } attachAnnotation(new NodeDeclareRef(obj)); } @Override public void attachAnnotation(ICodeAnnotation obj) { if (obj == null) { return; } attachAnnotation(obj, getLength()); } @Override public void attachLineAnnotation(ICodeAnnotation obj) { if (obj == null) { return; } attachAnnotation(obj, getLineStartPos()); } private void attachAnnotation(ICodeAnnotation obj, int pos) { if (annotations.isEmpty()) { annotations = new HashMap<>(); } annotations.put(pos, obj); } @Override public void attachSourceLine(int sourceLine) { if (sourceLine == 0) { return; } attachSourceLine(line, sourceLine); } private void attachSourceLine(int decompiledLine, int sourceLine) { if (lineMap.isEmpty()) { lineMap = new TreeMap<>(); } lineMap.put(decompiledLine, sourceLine); } @Override public ICodeInfo finish() { String code = buf.toString(); buf = null; return new AnnotatedCodeInfo(code, lineMap, annotations); } @Override public Map<Integer, ICodeAnnotation> getRawAnnotations() { return annotations; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/AnnotatedCodeInfo.java
jadx-core/src/main/java/jadx/api/impl/AnnotatedCodeInfo.java
package jadx.api.impl; import java.util.Map; import jadx.api.ICodeInfo; import jadx.api.metadata.ICodeAnnotation; import jadx.api.metadata.ICodeMetadata; import jadx.api.metadata.impl.CodeMetadataStorage; public class AnnotatedCodeInfo implements ICodeInfo { private final String code; private final ICodeMetadata metadata; public AnnotatedCodeInfo(String code, Map<Integer, Integer> lineMapping, Map<Integer, ICodeAnnotation> annotations) { this.code = code; this.metadata = CodeMetadataStorage.build(lineMapping, annotations); } @Override public String getCodeStr() { return code; } @Override public ICodeMetadata getCodeMetadata() { return metadata; } @Override public boolean hasMetadata() { return metadata != ICodeMetadata.EMPTY; } @Override public String toString() { return code; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/SimpleCodeWriter.java
jadx-core/src/main/java/jadx/api/impl/SimpleCodeWriter.java
package jadx.api.impl; import java.util.Collections; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import jadx.api.ICodeInfo; import jadx.api.ICodeWriter; import jadx.api.JadxArgs; import jadx.api.metadata.ICodeAnnotation; import jadx.api.metadata.ICodeNodeRef; import jadx.core.utils.Utils; /** * CodeWriter implementation without meta information support */ public class SimpleCodeWriter implements ICodeWriter { private static final Logger LOG = LoggerFactory.getLogger(SimpleCodeWriter.class); protected StringBuilder buf = new StringBuilder(); protected String indentStr = ""; protected int indent = 0; protected final boolean insertLineNumbers; protected final String singleIndentStr; protected final String newLineStr; public SimpleCodeWriter(JadxArgs args) { this.insertLineNumbers = args.isInsertDebugLines(); this.singleIndentStr = args.getCodeIndentStr(); this.newLineStr = args.getCodeNewLineStr(); if (insertLineNumbers) { incIndent(3); add(indentStr); } } /** * Constructor with JadxArgs should be used. */ @Deprecated public SimpleCodeWriter() { this.insertLineNumbers = false; this.singleIndentStr = JadxArgs.DEFAULT_INDENT_STR; this.newLineStr = JadxArgs.DEFAULT_NEW_LINE_STR; } @Override public boolean isMetadataSupported() { return false; } @Override public SimpleCodeWriter startLine() { addLine(); addLineIndent(); return this; } @Override public SimpleCodeWriter startLine(char c) { startLine(); add(c); return this; } @Override public SimpleCodeWriter startLine(String str) { startLine(); add(str); return this; } @Override public SimpleCodeWriter startLineWithNum(int sourceLine) { if (sourceLine == 0) { startLine(); return this; } if (this.insertLineNumbers) { newLine(); attachSourceLine(sourceLine); int start = getLength(); add("/* ").add(Integer.toString(sourceLine)).add(" */ "); int len = getLength() - start; if (indentStr.length() > len) { add(indentStr.substring(len)); } } else { startLine(); attachSourceLine(sourceLine); } return this; } @Override public SimpleCodeWriter addMultiLine(String str) { if (str.contains(newLineStr)) { buf.append(str.replace(newLineStr, newLineStr + indentStr)); } else { buf.append(str); } return this; } @Override public SimpleCodeWriter add(String str) { buf.append(str); return this; } @Override public SimpleCodeWriter add(char c) { buf.append(c); return this; } @Override public ICodeWriter add(ICodeWriter cw) { buf.append(cw.getCodeStr()); return this; } @Override public SimpleCodeWriter newLine() { addLine(); return this; } @Override public SimpleCodeWriter addIndent() { add(singleIndentStr); return this; } protected void addLine() { buf.append(newLineStr); } protected SimpleCodeWriter addLineIndent() { buf.append(indentStr); return this; } private void updateIndent() { this.indentStr = Utils.strRepeat(singleIndentStr, indent); } @Override public void incIndent() { incIndent(1); } @Override public void decIndent() { decIndent(1); } private void incIndent(int c) { this.indent += c; updateIndent(); } private void decIndent(int c) { this.indent -= c; if (this.indent < 0) { LOG.warn("Indent < 0"); this.indent = 0; } updateIndent(); } @Override public int getIndent() { return indent; } @Override public void setIndent(int indent) { this.indent = indent; updateIndent(); } @Override public int getLine() { return 0; } @Override public int getLineStartPos() { return 0; } @Override public void attachDefinition(ICodeNodeRef obj) { // no op } @Override public void attachAnnotation(ICodeAnnotation obj) { // no op } @Override public void attachLineAnnotation(ICodeAnnotation obj) { // no op } @Override public void attachSourceLine(int sourceLine) { // no op } @Override public ICodeInfo finish() { String code = getStringWithoutFirstEmptyLine(); buf = null; return new SimpleCodeInfo(code); } private String getStringWithoutFirstEmptyLine() { int len = newLineStr.length(); if (buf.length() > len && buf.substring(0, len).equals(newLineStr)) { return buf.substring(len); } return buf.toString(); } @Override public int getLength() { return buf.length(); } @Override public StringBuilder getRawBuf() { return buf; } @Override public Map<Integer, ICodeAnnotation> getRawAnnotations() { return Collections.emptyMap(); } @Override public String getCodeStr() { return buf.toString(); } @Override public String toString() { return getCodeStr(); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/SimpleCodeInfo.java
jadx-core/src/main/java/jadx/api/impl/SimpleCodeInfo.java
package jadx.api.impl; import jadx.api.ICodeInfo; import jadx.api.metadata.ICodeMetadata; public class SimpleCodeInfo implements ICodeInfo { private final String code; public SimpleCodeInfo(String code) { this.code = code; } @Override public String getCodeStr() { return code; } @Override public ICodeMetadata getCodeMetadata() { return ICodeMetadata.EMPTY; } @Override public boolean hasMetadata() { return false; } @Override public String toString() { return code; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/NoOpCodeCache.java
jadx-core/src/main/java/jadx/api/impl/NoOpCodeCache.java
package jadx.api.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import jadx.api.ICodeCache; import jadx.api.ICodeInfo; public class NoOpCodeCache implements ICodeCache { public static final NoOpCodeCache INSTANCE = new NoOpCodeCache(); @Override public void add(String clsFullName, ICodeInfo codeInfo) { // do nothing } @Override public void remove(String clsFullName) { // do nothing } @Override @NotNull public ICodeInfo get(String clsFullName) { return ICodeInfo.EMPTY; } @Override public @Nullable String getCode(String clsFullName) { return null; } @Override public boolean contains(String clsFullName) { return false; } @Override public void close() { // do nothing } @Override public String toString() { return "NoOpCodeCache"; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/DelegateCodeCache.java
jadx-core/src/main/java/jadx/api/impl/DelegateCodeCache.java
package jadx.api.impl; import java.io.IOException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import jadx.api.ICodeCache; import jadx.api.ICodeInfo; public abstract class DelegateCodeCache implements ICodeCache { protected final ICodeCache backCache; public DelegateCodeCache(ICodeCache backCache) { this.backCache = backCache; } @Override public void add(String clsFullName, ICodeInfo codeInfo) { backCache.add(clsFullName, codeInfo); } @Override public void remove(String clsFullName) { backCache.remove(clsFullName); } @Override public @NotNull ICodeInfo get(String clsFullName) { return backCache.get(clsFullName); } @Override @Nullable public String getCode(String clsFullName) { return backCache.getCode(clsFullName); } @Override public boolean contains(String clsFullName) { return backCache.contains(clsFullName); } @Override public void close() throws IOException { backCache.close(); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/passes/IPassWrapperVisitor.java
jadx-core/src/main/java/jadx/api/impl/passes/IPassWrapperVisitor.java
package jadx.api.impl.passes; import jadx.api.plugins.pass.JadxPass; import jadx.core.dex.visitors.IDexTreeVisitor; public interface IPassWrapperVisitor extends IDexTreeVisitor { JadxPass getPass(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/passes/DecompilePassWrapper.java
jadx-core/src/main/java/jadx/api/impl/passes/DecompilePassWrapper.java
package jadx.api.impl.passes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import jadx.api.plugins.pass.JadxPass; import jadx.api.plugins.pass.types.JadxDecompilePass; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.RootNode; import jadx.core.dex.visitors.AbstractVisitor; import jadx.core.utils.exceptions.JadxException; public class DecompilePassWrapper extends AbstractVisitor implements IPassWrapperVisitor { private static final Logger LOG = LoggerFactory.getLogger(DecompilePassWrapper.class); private final JadxDecompilePass decompilePass; public DecompilePassWrapper(JadxDecompilePass decompilePass) { this.decompilePass = decompilePass; } @Override public JadxPass getPass() { return decompilePass; } @Override public void init(RootNode root) throws JadxException { try { decompilePass.init(root); } catch (StackOverflowError | Exception e) { LOG.error("Error in decompile pass init: {}", this, e); } } @Override public boolean visit(ClassNode cls) throws JadxException { try { return decompilePass.visit(cls); } catch (StackOverflowError | Exception e) { cls.addError("Error in decompile pass: " + this, e); return false; } } @Override public void visit(MethodNode mth) throws JadxException { try { decompilePass.visit(mth); } catch (StackOverflowError | Exception e) { mth.addError("Error in decompile pass: " + this, e); } } @Override public String getName() { return decompilePass.getInfo().getName(); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/impl/passes/PreparePassWrapper.java
jadx-core/src/main/java/jadx/api/impl/passes/PreparePassWrapper.java
package jadx.api.impl.passes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import jadx.api.plugins.pass.JadxPass; import jadx.api.plugins.pass.types.JadxPreparePass; import jadx.core.dex.nodes.RootNode; import jadx.core.dex.visitors.AbstractVisitor; import jadx.core.utils.exceptions.JadxException; public class PreparePassWrapper extends AbstractVisitor implements IPassWrapperVisitor { private static final Logger LOG = LoggerFactory.getLogger(PreparePassWrapper.class); private final JadxPreparePass preparePass; public PreparePassWrapper(JadxPreparePass preparePass) { this.preparePass = preparePass; } @Override public JadxPass getPass() { return preparePass; } @Override public void init(RootNode root) throws JadxException { try { preparePass.init(root); } catch (Exception e) { LOG.error("Error in prepare pass init: {}", this, e); } } @Override public String getName() { return preparePass.getInfo().getName(); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/utils/CodeUtils.java
jadx-core/src/main/java/jadx/api/utils/CodeUtils.java
package jadx.api.utils; import java.util.function.BiFunction; import jadx.api.ICodeInfo; import jadx.api.metadata.ICodeAnnotation; import jadx.api.metadata.ICodeNodeRef; import jadx.api.metadata.annotations.NodeDeclareRef; import jadx.core.dex.nodes.MethodNode; public class CodeUtils { public static String getLineForPos(String code, int pos) { int start = getLineStartForPos(code, pos); int end = getLineEndForPos(code, pos); return code.substring(start, end); } public static int getLineStartForPos(String code, int pos) { int start = getNewLinePosBefore(code, pos); return start == -1 ? 0 : start + 1; } public static int getLineEndForPos(String code, int pos) { int end = getNewLinePosAfter(code, pos); return end == -1 ? code.length() : end; } public static int getNewLinePosAfter(String code, int startPos) { int pos = code.indexOf('\n', startPos); if (pos != -1) { // check for '\r\n' int prev = pos - 1; if (code.charAt(prev) == '\r') { return prev; } } return pos; } public static int getNewLinePosBefore(String code, int startPos) { return code.lastIndexOf('\n', startPos); } public static int getLineNumForPos(String code, int pos, String newLine) { int newLineLen = newLine.length(); int line = 1; int prev = 0; while (true) { int next = code.indexOf(newLine, prev); if (next >= pos) { return line; } prev = next + newLineLen; line++; } } /** * Cut method code (including comments and annotations) from class code. * * @return method code or empty string if metadata is not available */ public static String extractMethodCode(MethodNode mth, ICodeInfo codeInfo) { int end = getMethodEnd(mth, codeInfo); if (end == -1) { return ""; } int start = getMethodStart(mth, codeInfo); if (end < start) { return ""; } return codeInfo.getCodeStr().substring(start, end); } /** * Search first empty line before method definition to include comments and annotations */ private static int getMethodStart(MethodNode mth, ICodeInfo codeInfo) { int pos = mth.getDefPosition(); String newLineStr = mth.root().getArgs().getCodeNewLineStr(); String emptyLine = newLineStr + newLineStr; int emptyLinePos = codeInfo.getCodeStr().lastIndexOf(emptyLine, pos); return emptyLinePos == -1 ? pos : emptyLinePos + emptyLine.length(); } /** * Search method end position in provided class code info. * * @return end pos or -1 if metadata not available */ public static int getMethodEnd(MethodNode mth, ICodeInfo codeInfo) { if (!codeInfo.hasMetadata()) { return -1; } // skip nested nodes DEF/END until first unpaired END annotation (end of this method) Integer end = codeInfo.getCodeMetadata().searchDown(mth.getDefPosition() + 1, new BiFunction<>() { int nested = 0; @Override public Integer apply(Integer pos, ICodeAnnotation ann) { switch (ann.getAnnType()) { case DECLARATION: ICodeNodeRef node = ((NodeDeclareRef) ann).getNode(); switch (node.getAnnType()) { case CLASS: case METHOD: nested++; break; } break; case END: if (nested == 0) { return pos; } nested--; break; } return null; } }); return end == null ? -1 : end; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/utils/tasks/ITaskExecutor.java
jadx-core/src/main/java/jadx/api/utils/tasks/ITaskExecutor.java
package jadx.api.utils.tasks; import java.util.List; import java.util.concurrent.ExecutorService; import org.jetbrains.annotations.Nullable; /** * Schedule and execute tasks combined into stages * with parallel or sequential execution (similar to the fork-join pattern). */ public interface ITaskExecutor { /** * Add parallel stage with provided tasks */ void addParallelTasks(List<? extends Runnable> parallelTasks); /** * Add sequential stage with provided tasks */ void addSequentialTasks(List<? extends Runnable> seqTasks); /** * Add sequential stage with a single task */ void addSequentialTask(Runnable task); /** * Scheduled tasks count */ int getTasksCount(); /** * Set threads count for parallel stage. * Can be changed during execution. * Defaults to half of processors count. */ void setThreadsCount(int threadsCount); int getThreadsCount(); /** * Start tasks execution. */ void execute(); int getProgress(); /** * Not started tasks will be not executed after this method invocation. */ void terminate(); boolean isTerminating(); boolean isRunning(); /** * Block until execution is finished */ void awaitTermination(); /** * Return internal executor service. */ @Nullable ExecutorService getInternalExecutor(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/JadxPluginContext.java
jadx-core/src/main/java/jadx/api/plugins/JadxPluginContext.java
package jadx.api.plugins; import java.util.function.Supplier; import org.jetbrains.annotations.Nullable; import jadx.api.JadxArgs; import jadx.api.JadxDecompiler; import jadx.api.plugins.data.IJadxFiles; import jadx.api.plugins.data.IJadxPlugins; import jadx.api.plugins.events.IJadxEvents; import jadx.api.plugins.gui.JadxGuiContext; import jadx.api.plugins.input.JadxCodeInput; import jadx.api.plugins.options.JadxPluginOptions; import jadx.api.plugins.pass.JadxPass; import jadx.api.plugins.resources.IResourcesLoader; import jadx.zip.ZipReader; public interface JadxPluginContext { JadxArgs getArgs(); JadxDecompiler getDecompiler(); void addPass(JadxPass pass); void addCodeInput(JadxCodeInput codeInput); void registerOptions(JadxPluginOptions options); /** * Function to calculate hash of all options which can change output code. * Hash for input files ({@link JadxArgs#getInputFiles()}) and registered options * calculated by default implementations. */ void registerInputsHashSupplier(Supplier<String> supplier); /** * Customize resource loading */ IResourcesLoader getResourcesLoader(); /** * Access to jadx-gui specific methods */ @Nullable JadxGuiContext getGuiContext(); /** * Subscribe and send events */ IJadxEvents events(); /** * Access to registered plugins and runtime data */ IJadxPlugins plugins(); /** * Access to plugin specific files and directories */ IJadxFiles files(); /** * Custom jadx zip reader to fight tampering and provide additional security checks */ ZipReader getZipReader(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/JadxPluginInfoBuilder.java
jadx-core/src/main/java/jadx/api/plugins/JadxPluginInfoBuilder.java
package jadx.api.plugins; import java.util.Objects; import org.jetbrains.annotations.Nullable; import jadx.core.plugins.versions.VerifyRequiredVersion; public class JadxPluginInfoBuilder { private String pluginId; private String name; private String description; private String homepage = ""; private @Nullable String requiredJadxVersion; private @Nullable String provides; /** * Start building method */ public static JadxPluginInfoBuilder pluginId(String pluginId) { JadxPluginInfoBuilder builder = new JadxPluginInfoBuilder(); builder.pluginId = Objects.requireNonNull(pluginId); return builder; } private JadxPluginInfoBuilder() { } public JadxPluginInfoBuilder name(String name) { this.name = Objects.requireNonNull(name); return this; } public JadxPluginInfoBuilder description(String description) { this.description = Objects.requireNonNull(description); return this; } public JadxPluginInfoBuilder homepage(String homepage) { this.homepage = homepage; return this; } public JadxPluginInfoBuilder provides(String provides) { this.provides = provides; return this; } public JadxPluginInfoBuilder requiredJadxVersion(String versions) { this.requiredJadxVersion = versions; return this; } public JadxPluginInfo build() { Objects.requireNonNull(pluginId, "PluginId is required"); Objects.requireNonNull(name, "Name is required"); Objects.requireNonNull(description, "Description is required"); if (provides == null) { provides = pluginId; } if (requiredJadxVersion != null) { VerifyRequiredVersion.verify(requiredJadxVersion); } JadxPluginInfo pluginInfo = new JadxPluginInfo(pluginId, name, description, homepage, provides); pluginInfo.setRequiredJadxVersion(requiredJadxVersion); return pluginInfo; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/CustomResourcesLoader.java
jadx-core/src/main/java/jadx/api/plugins/CustomResourcesLoader.java
package jadx.api.plugins; import java.io.Closeable; import java.io.File; import java.util.List; import jadx.api.ResourceFile; import jadx.api.ResourcesLoader; public interface CustomResourcesLoader extends Closeable { /** * Load resources from file to list of ResourceFile * * @param list list to add loaded resources * @param file file to load * @return true if file was loaded */ boolean load(ResourcesLoader loader, List<ResourceFile> list, File file); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/JadxPlugin.java
jadx-core/src/main/java/jadx/api/plugins/JadxPlugin.java
package jadx.api.plugins; import jadx.api.plugins.pass.types.JadxAfterLoadPass; import jadx.api.plugins.pass.types.JadxPreparePass; /** * Base interface for all jadx plugins * <br> * To create new plugin implement this interface and add to resources * a {@code META-INF/services/jadx.api.plugins.JadxPlugin} file with a full name of your class. */ public interface JadxPlugin { /** * Method for provide plugin information, like name and description. * Can be invoked several times. */ JadxPluginInfo getPluginInfo(); /** * Init plugin. * Use {@link JadxPluginContext} to register passes, code inputs and options. * For long operation, prefer {@link JadxPreparePass} or {@link JadxAfterLoadPass} instead. */ void init(JadxPluginContext context); /** * Plugin unload handler. * Can be used to clean up resources on plugin unloading. */ default void unload() { // optional method } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/JadxPluginInfo.java
jadx-core/src/main/java/jadx/api/plugins/JadxPluginInfo.java
package jadx.api.plugins; import org.jetbrains.annotations.Nullable; public class JadxPluginInfo { private final String pluginId; private final String name; private final String description; private String homepage; /** * Conflicting plugins should have the same 'provides' property; only one will be loaded */ private String provides; /** * Minimum required jadx version to run this plugin. * <br> * Format: "<stable version>, r<revision number of unstable version>". * Example: "1.5.1, r2305" * * @see <a href="https://github.com/skylot/jadx/wiki/Jadx-plugins-guide#required-jadx-version">wiki * page</a> * for details. */ private @Nullable String requiredJadxVersion; public JadxPluginInfo(String id, String name, String description) { this(id, name, description, "", id); } public JadxPluginInfo(String pluginId, String name, String description, String provides) { this(pluginId, name, description, "", provides); } public JadxPluginInfo(String pluginId, String name, String description, String homepage, String provides) { this.pluginId = pluginId; this.name = name; this.description = description; this.homepage = homepage; this.provides = provides; } public String getPluginId() { return pluginId; } public String getName() { return name; } public String getDescription() { return description; } public String getHomepage() { return homepage; } public void setHomepage(String homepage) { this.homepage = homepage; } public String getProvides() { return provides; } public void setProvides(String provides) { this.provides = provides; } public @Nullable String getRequiredJadxVersion() { return requiredJadxVersion; } public void setRequiredJadxVersion(@Nullable String requiredJadxVersion) { this.requiredJadxVersion = requiredJadxVersion; } @Override public String toString() { return pluginId + ": " + name + " - '" + description + '\''; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/loader/JadxPluginLoader.java
jadx-core/src/main/java/jadx/api/plugins/loader/JadxPluginLoader.java
package jadx.api.plugins.loader; import java.io.Closeable; import java.util.List; import jadx.api.plugins.JadxPlugin; public interface JadxPluginLoader extends Closeable { List<JadxPlugin> load(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/loader/JadxBasePluginLoader.java
jadx-core/src/main/java/jadx/api/plugins/loader/JadxBasePluginLoader.java
package jadx.api.plugins.loader; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.ServiceLoader; import jadx.api.plugins.JadxPlugin; /** * Loading plugins from current classpath */ public class JadxBasePluginLoader implements JadxPluginLoader { @Override public List<JadxPlugin> load() { List<JadxPlugin> list = new ArrayList<>(); ServiceLoader<JadxPlugin> plugins = ServiceLoader.load(JadxPlugin.class); for (JadxPlugin plugin : plugins) { list.add(plugin); } return list; } @Override public void close() throws IOException { // nothing to close } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/options/OptionType.java
jadx-core/src/main/java/jadx/api/plugins/options/OptionType.java
package jadx.api.plugins.options; public enum OptionType { STRING, NUMBER, BOOLEAN }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/options/OptionFlag.java
jadx-core/src/main/java/jadx/api/plugins/options/OptionFlag.java
package jadx.api.plugins.options; public enum OptionFlag { /** * Store in project settings instead global (for jadx-gui) */ PER_PROJECT, /** * Do not show this option in jadx-gui (useful if option is configured with custom ui) */ HIDE_IN_GUI, /** * Option will be read-only in jadx-gui (can be used for calculated properties) */ DISABLE_IN_GUI, /** * Add this flag only if the option does not affect generated code. * If added, option value change will not cause code cache reset. */ NOT_CHANGING_CODE, }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/options/JadxPluginOptions.java
jadx-core/src/main/java/jadx/api/plugins/options/JadxPluginOptions.java
package jadx.api.plugins.options; import java.util.List; import java.util.Map; public interface JadxPluginOptions { void setOptions(Map<String, String> options); List<OptionDescription> getOptionsDescriptions(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/options/OptionDescription.java
jadx-core/src/main/java/jadx/api/plugins/options/OptionDescription.java
package jadx.api.plugins.options; import java.util.Collections; import java.util.List; import java.util.Set; import org.jetbrains.annotations.Nullable; public interface OptionDescription { String name(); String description(); /** * Possible values. * Empty if not a limited set */ List<String> values(); /** * Default value. * Null if required */ @Nullable String defaultValue(); default OptionType getType() { return OptionType.STRING; } default Set<OptionFlag> getFlags() { return Collections.emptySet(); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/options/impl/BasePluginOptionsBuilder.java
jadx-core/src/main/java/jadx/api/plugins/options/impl/BasePluginOptionsBuilder.java
package jadx.api.plugins.options.impl; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; import org.jetbrains.annotations.Nullable; import jadx.api.plugins.options.JadxPluginOptions; import jadx.api.plugins.options.OptionDescription; import jadx.api.plugins.options.OptionFlag; import jadx.api.plugins.options.OptionType; /** * Base class for {@link JadxPluginOptions} implementation * <p> * Override {@link BasePluginOptionsBuilder#registerOptions()} method * and use *option methods to add option info. */ @SuppressWarnings("unused") public abstract class BasePluginOptionsBuilder implements JadxPluginOptions { private final List<OptionData<?>> options = new ArrayList<>(); public abstract void registerOptions(); public BasePluginOptionsBuilder() { registerOptions(); for (OptionData<?> option : options) { option.validate(); } } public <T> OptionBuilder<T> option(String name) { return addOption(new OptionData<>(name)); } public <T> OptionBuilder<T> option(String name, Class<T> optionType) { return addOption(new OptionData<>(name)); } public OptionBuilder<Boolean> boolOption(String name) { return addOption( new OptionData<Boolean>(name) .type(OptionType.BOOLEAN) .values(Arrays.asList(Boolean.TRUE, Boolean.FALSE)) .formatter(b -> b ? "yes" : "no") .parser(val -> parseBoolOption(name, val))); } public OptionBuilder<String> strOption(String name) { return addOption( new OptionData<String>(name) .type(OptionType.STRING) .formatter(v -> v) .parser(v -> v)); } public OptionBuilder<Integer> intOption(String name) { return addOption( new OptionData<Integer>(name) .type(OptionType.NUMBER) .formatter(Object::toString) .parser(Integer::parseInt)); } public <E extends Enum<?>> OptionBuilder<E> enumOption(String name, E[] values, Function<String, E> valueOf) { return addOption( new OptionData<E>(name) .type(OptionType.STRING) .values(Arrays.asList(values)) .formatter(v -> v.name().toLowerCase(Locale.ROOT)) .parser(v -> valueOf.apply(v.toUpperCase(Locale.ROOT)))); } @Override public void setOptions(Map<String, String> map) { for (OptionData<?> option : options) { parseOption(option, map.get(option.name)); } } @Override public List<OptionDescription> getOptionsDescriptions() { return Collections.unmodifiableList(options); } private static <T> void parseOption(OptionData<T> option, @Nullable String value) { T parsedValue; if (value == null) { parsedValue = option.defaultValue; } else { try { parsedValue = option.getParser().apply(value); } catch (Exception e) { throw new RuntimeException("Parse failed for option: " + option.name + ", value: " + value, e); } } try { option.getSetter().accept(parsedValue); } catch (Exception e) { throw new RuntimeException("Setter invoke failed for option: " + option.name + ", value: " + parsedValue, e); } } private static boolean parseBoolOption(String name, String val) { String valLower = val.trim().toLowerCase(Locale.ROOT); if (valLower.equals("yes") || valLower.equals("true")) { return true; } if (valLower.equals("no") || valLower.equals("false")) { return false; } throw new IllegalArgumentException("Unknown value '" + val + "' for option '" + name + "', expect: 'yes' or 'no'"); } private <T> OptionBuilder<T> addOption(OptionBuilder<T> optionData) { this.options.add((OptionData<?>) optionData); return optionData; } protected static class OptionData<T> implements OptionDescription, OptionBuilder<T> { private final String name; private String desc; private List<T> values = Collections.emptyList(); private OptionType type = OptionType.STRING; private Set<OptionFlag> flags = EnumSet.noneOf(OptionFlag.class); private Function<String, T> parser; private Function<T, String> formatter; private Consumer<T> setter; private T defaultValue; public OptionData(String name) { this.name = name; } @Override public String name() { return name; } @Override public String description() { return desc; } @Override public List<String> values() { return values.stream().map(formatter).collect(Collectors.toList()); } @Override public @Nullable String defaultValue() { return formatter.apply(defaultValue); } @Override public OptionType getType() { return type; } @Override public Set<OptionFlag> getFlags() { return flags; } @Override public OptionBuilder<T> description(String desc) { this.desc = desc; return this; } @Override public OptionBuilder<T> defaultValue(@Nullable T defValue) { this.defaultValue = defValue; return this; } @Override public OptionBuilder<T> parser(Function<String, T> parser) { this.parser = parser; return this; } @Override public OptionBuilder<T> formatter(Function<T, String> formatter) { this.formatter = formatter; return this; } @Override public OptionBuilder<T> setter(Consumer<T> setter) { this.setter = setter; return this; } @Override public OptionBuilder<T> type(OptionType optionType) { this.type = optionType; return this; } @Override public OptionBuilder<T> flags(OptionFlag... flags) { this.flags = EnumSet.copyOf(Arrays.asList(flags)); return this; } @Override public OptionBuilder<T> values(List<T> values) { this.values = values; return this; } public Function<String, T> getParser() { return parser; } public Function<T, String> getFormatter() { return formatter; } public Consumer<T> getSetter() { return setter; } public void validate() { if (desc == null || desc.isEmpty()) { throw new IllegalArgumentException("Description should be set for option: " + name); } if (parser == null) { throw new IllegalArgumentException("Parser should be set for option: " + name); } if (formatter == null) { throw new IllegalArgumentException("Formatter should be set for option: " + name); } if (setter == null) { throw new IllegalArgumentException("Setter should be set for option: " + name); } } } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/options/impl/BaseOptionsParser.java
jadx-core/src/main/java/jadx/api/plugins/options/impl/BaseOptionsParser.java
package jadx.api.plugins.options.impl; import java.util.Locale; import java.util.Map; import java.util.function.Function; import jadx.api.plugins.options.JadxPluginOptions; /** * Prefer {@link BasePluginOptionsBuilder} as a better way to init and parse options */ @Deprecated public abstract class BaseOptionsParser implements JadxPluginOptions { protected Map<String, String> options; @Override public void setOptions(Map<String, String> options) { this.options = options; parseOptions(); } public abstract void parseOptions(); public boolean getBooleanOption(String key, boolean defValue) { String val = options.get(key); if (val == null) { return defValue; } String valLower = val.toLowerCase(Locale.ROOT); if (valLower.equals("yes") || valLower.equals("true")) { return true; } if (valLower.equals("no") || valLower.equals("false")) { return false; } throw new IllegalArgumentException("Unknown value '" + val + "' for option '" + key + "'" + ", expect: 'yes' or 'no'"); } public <T> T getOption(String key, Function<String, T> parse, T defValue) { String val = options.get(key); if (val == null) { return defValue; } return parse.apply(val); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/options/impl/JadxOptionDescription.java
jadx-core/src/main/java/jadx/api/plugins/options/impl/JadxOptionDescription.java
package jadx.api.plugins.options.impl; import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Set; import org.jetbrains.annotations.Nullable; import jadx.api.plugins.options.OptionDescription; import jadx.api.plugins.options.OptionFlag; import jadx.api.plugins.options.OptionType; public class JadxOptionDescription implements OptionDescription { public static JadxOptionDescription booleanOption(String name, String desc, boolean defaultValue) { return new JadxOptionDescription(name, desc, defaultValue ? "yes" : "no", Arrays.asList("yes", "no"), OptionType.BOOLEAN); } private final String name; private final String desc; private final String defaultValue; private final List<String> values; private final OptionType type; private final Set<OptionFlag> flags = EnumSet.noneOf(OptionFlag.class); public JadxOptionDescription(String name, String desc, @Nullable String defaultValue, List<String> values) { this(name, desc, defaultValue, values, OptionType.STRING); } public JadxOptionDescription(String name, String desc, @Nullable String defaultValue, List<String> values, OptionType type) { this.name = name; this.desc = desc; this.defaultValue = defaultValue; this.values = values; this.type = type; } @Override public String name() { return name; } @Override public String description() { return desc; } @Override public @Nullable String defaultValue() { return defaultValue; } @Override public List<String> values() { return values; } @Override public OptionType getType() { return type; } @Override public Set<OptionFlag> getFlags() { return flags; } public JadxOptionDescription withFlag(OptionFlag flag) { this.flags.add(flag); return this; } public JadxOptionDescription withFlags(OptionFlag... flags) { Collections.addAll(this.flags, flags); return this; } @Override public String toString() { return "OptionDescription{" + desc + ", values=" + values + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/options/impl/OptionBuilder.java
jadx-core/src/main/java/jadx/api/plugins/options/impl/OptionBuilder.java
package jadx.api.plugins.options.impl; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; import jadx.api.plugins.options.OptionFlag; import jadx.api.plugins.options.OptionType; public interface OptionBuilder<T> { /** * Option description (required) */ OptionBuilder<T> description(String desc); OptionBuilder<T> defaultValue(T defValue); /** * Function to parse input string into option value (required) */ OptionBuilder<T> parser(Function<String, T> parser); /** * Function to format option value into string for build help (required) */ OptionBuilder<T> formatter(Function<T, String> formatter); /** * Function to save/apply parsed option value (required) */ OptionBuilder<T> setter(Consumer<T> setter); /** * Possible option values */ OptionBuilder<T> values(List<T> values); OptionBuilder<T> type(OptionType optionType); OptionBuilder<T> flags(OptionFlag... flags); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/pass/JadxPass.java
jadx-core/src/main/java/jadx/api/plugins/pass/JadxPass.java
package jadx.api.plugins.pass; import jadx.api.plugins.pass.types.JadxPassType; public interface JadxPass { JadxPassInfo getInfo(); JadxPassType getPassType(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/pass/JadxPassInfo.java
jadx-core/src/main/java/jadx/api/plugins/pass/JadxPassInfo.java
package jadx.api.plugins.pass; import java.util.List; public interface JadxPassInfo { /** * Add this to 'run after' list to place pass before others */ String START = "start"; /** * Add this to 'run before' list to place pass at end */ String END = "end"; /** * Pass short id, should be unique. */ String getName(); /** * Pass description */ String getDescription(); /** * This pass will be executed after these passes. * Passes names list. */ List<String> runAfter(); /** * This pass will be executed before these passes. * Passes names list. */ List<String> runBefore(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/pass/impl/OrderedJadxPassInfo.java
jadx-core/src/main/java/jadx/api/plugins/pass/impl/OrderedJadxPassInfo.java
package jadx.api.plugins.pass.impl; import java.util.ArrayList; import java.util.List; import jadx.api.plugins.pass.JadxPassInfo; public class OrderedJadxPassInfo implements JadxPassInfo { private final String name; private final String desc; private final List<String> runAfter; private final List<String> runBefore; public OrderedJadxPassInfo(String name, String desc) { this(name, desc, new ArrayList<>(), new ArrayList<>()); } public OrderedJadxPassInfo(String name, String desc, List<String> runAfter, List<String> runBefore) { this.name = name; this.desc = desc; this.runAfter = runAfter; this.runBefore = runBefore; } public OrderedJadxPassInfo after(String pass) { runAfter.add(pass); return this; } public OrderedJadxPassInfo before(String pass) { runBefore.add(pass); return this; } @Override public String getName() { return name; } @Override public String getDescription() { return desc; } @Override public List<String> runAfter() { return runAfter; } @Override public List<String> runBefore() { return runBefore; } @Override public String toString() { return "PassInfo{'" + name + '\'' + ", desc='" + desc + '\'' + ", runAfter=" + runAfter + ", runBefore=" + runBefore + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/pass/impl/SimpleAfterLoadPass.java
jadx-core/src/main/java/jadx/api/plugins/pass/impl/SimpleAfterLoadPass.java
package jadx.api.plugins.pass.impl; import java.util.function.Consumer; import jadx.api.JadxDecompiler; import jadx.api.plugins.pass.JadxPassInfo; import jadx.api.plugins.pass.types.JadxAfterLoadPass; public class SimpleAfterLoadPass implements JadxAfterLoadPass { private final JadxPassInfo info; private final Consumer<JadxDecompiler> init; public SimpleAfterLoadPass(String name, Consumer<JadxDecompiler> init) { this.info = new SimpleJadxPassInfo(name); this.init = init; } @Override public JadxPassInfo getInfo() { return info; } @Override public void init(JadxDecompiler decompiler) { init.accept(decompiler); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/pass/impl/SimpleJadxPassInfo.java
jadx-core/src/main/java/jadx/api/plugins/pass/impl/SimpleJadxPassInfo.java
package jadx.api.plugins.pass.impl; import java.util.Collections; import java.util.List; import jadx.api.plugins.pass.JadxPassInfo; public class SimpleJadxPassInfo implements JadxPassInfo { private final String name; private final String desc; public SimpleJadxPassInfo(String name) { this(name, name); } public SimpleJadxPassInfo(String name, String desc) { this.name = name; this.desc = desc; } @Override public String getName() { return name; } @Override public String getDescription() { return desc; } @Override public List<String> runAfter() { return Collections.emptyList(); } @Override public List<String> runBefore() { return Collections.emptyList(); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/pass/types/JadxAfterLoadPass.java
jadx-core/src/main/java/jadx/api/plugins/pass/types/JadxAfterLoadPass.java
package jadx.api.plugins.pass.types; import jadx.api.JadxDecompiler; import jadx.api.plugins.pass.JadxPass; public interface JadxAfterLoadPass extends JadxPass { JadxPassType TYPE = new JadxPassType("AfterLoadPass"); void init(JadxDecompiler decompiler); @Override default JadxPassType getPassType() { return TYPE; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/pass/types/JadxPreparePass.java
jadx-core/src/main/java/jadx/api/plugins/pass/types/JadxPreparePass.java
package jadx.api.plugins.pass.types; import jadx.api.plugins.pass.JadxPass; import jadx.core.dex.nodes.RootNode; public interface JadxPreparePass extends JadxPass { JadxPassType TYPE = new JadxPassType("PreparePass"); void init(RootNode root); @Override default JadxPassType getPassType() { return TYPE; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/pass/types/JadxPassType.java
jadx-core/src/main/java/jadx/api/plugins/pass/types/JadxPassType.java
package jadx.api.plugins.pass.types; public class JadxPassType { private final String cls; public JadxPassType(String clsName) { this.cls = clsName; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof JadxPassType)) { return false; } return cls.equals(((JadxPassType) o).cls); } @Override public int hashCode() { return cls.hashCode(); } @Override public String toString() { return cls; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/pass/types/JadxDecompilePass.java
jadx-core/src/main/java/jadx/api/plugins/pass/types/JadxDecompilePass.java
package jadx.api.plugins.pass.types; import jadx.api.plugins.pass.JadxPass; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.RootNode; public interface JadxDecompilePass extends JadxPass { JadxPassType TYPE = new JadxPassType("DecompilePass"); void init(RootNode root); /** * Visit class * * @return false for disable child methods and inner classes traversal */ boolean visit(ClassNode cls); /** * Visit method */ void visit(MethodNode mth); @Override default JadxPassType getPassType() { return TYPE; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/utils/Utils.java
jadx-core/src/main/java/jadx/api/plugins/utils/Utils.java
package jadx.api.plugins.utils; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Objects; import java.util.Set; import java.util.function.Function; import org.jetbrains.annotations.Nullable; public class Utils { public static <T> void addToList(Collection<T> list, @Nullable T item) { if (item != null) { list.add(item); } } public static <T, I> void addToList(Collection<T> list, @Nullable I item, Function<I, T> map) { if (item != null) { T value = map.apply(item); if (value != null) { list.add(value); } } } public static <T> List<T> concat(List<T> a, List<T> b) { int aSize = a.size(); int bSize = b.size(); if (aSize == 0 && bSize == 0) { return Collections.emptyList(); } if (aSize == 0) { return b; } if (bSize == 0) { return a; } List<T> list = new ArrayList<>(aSize + bSize); list.addAll(a); list.addAll(b); return list; } public static <T> List<T> concatDistinct(List<T> a, List<T> b) { int aSize = a.size(); int bSize = b.size(); if (aSize == 0 && bSize == 0) { return Collections.emptyList(); } if (aSize == 0) { return b; } if (bSize == 0) { return a; } Set<T> set = new LinkedHashSet<>(aSize + bSize); set.addAll(a); set.addAll(b); return new ArrayList<>(set); } public static <T> String listToStr(List<T> list) { if (list == null) { return "null"; } if (list.isEmpty()) { return ""; } if (list.size() == 1) { return Objects.toString(list.get(0)); } StringBuilder sb = new StringBuilder(); Iterator<T> it = list.iterator(); sb.append(it.next()); while (it.hasNext()) { sb.append(", ").append(it.next()); } return sb.toString(); } public static String formatOffset(int offset) { return String.format("0x%04x", offset); } @SafeVarargs public static <T> Set<T> constSet(T... arr) { return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(arr))); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/utils/ZipSecurity.java
jadx-core/src/main/java/jadx/api/plugins/utils/ZipSecurity.java
package jadx.api.plugins.utils; import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.function.BiConsumer; import java.util.function.Function; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import org.jetbrains.annotations.Nullable; import jadx.api.JadxDecompiler; import jadx.api.plugins.JadxPluginContext; import jadx.core.utils.Utils; import jadx.zip.IZipEntry; import jadx.zip.ZipReader; import jadx.zip.io.LimitedInputStream; import jadx.zip.security.DisabledZipSecurity; import jadx.zip.security.IJadxZipSecurity; import jadx.zip.security.JadxZipSecurity; /** * Deprecated, migrate to {@link ZipReader}. <br> * Prefer already configured instance from {@link JadxDecompiler#getZipReader()} or * {@link JadxPluginContext#getZipReader()}. */ @Deprecated public class ZipSecurity { private static final boolean DISABLE_CHECKS = Utils.getEnvVarBool("JADX_DISABLE_ZIP_SECURITY", false); private static final int MAX_ENTRIES_COUNT = Utils.getEnvVarInt("JADX_ZIP_MAX_ENTRIES_COUNT", 100_000); private static final IJadxZipSecurity ZIP_SECURITY = buildZipSecurity(); private static final ZipReader ZIP_READER = new ZipReader(ZIP_SECURITY); private static IJadxZipSecurity buildZipSecurity() { if (DISABLE_CHECKS) { return DisabledZipSecurity.INSTANCE; } JadxZipSecurity jadxZipSecurity = new JadxZipSecurity(); jadxZipSecurity.setMaxEntriesCount(MAX_ENTRIES_COUNT); return jadxZipSecurity; } private ZipSecurity() { } public static boolean isInSubDirectory(File baseDir, File file) { return ZIP_SECURITY.isInSubDirectory(baseDir, file); } /** * Checks that entry name contains no any traversals and prevents cases like "../classes.dex", * to limit output only to the specified directory */ public static boolean isValidZipEntryName(String entryName) { return ZIP_SECURITY.isValidEntryName(entryName); } public static boolean isZipBomb(IZipEntry entry) { return !ZIP_SECURITY.isValidEntry(entry); } public static boolean isValidZipEntry(IZipEntry entry) { return ZIP_SECURITY.isValidEntry(entry); } public static InputStream getInputStreamForEntry(ZipFile zipFile, ZipEntry entry) throws IOException { if (DISABLE_CHECKS) { return new BufferedInputStream(zipFile.getInputStream(entry)); } InputStream in = zipFile.getInputStream(entry); LimitedInputStream limited = new LimitedInputStream(in, entry.getSize()); return new BufferedInputStream(limited); } /** * Visit valid entries in a zip file. * Return not null value from visitor to stop iteration. */ @Nullable public static <R> R visitZipEntries(File file, Function<IZipEntry, R> visitor) { return ZIP_READER.visitEntries(file, visitor); } public static void readZipEntries(File file, BiConsumer<IZipEntry, InputStream> visitor) { ZIP_READER.readEntries(file, visitor); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/utils/CommonFileUtils.java
jadx-core/src/main/java/jadx/api/plugins/utils/CommonFileUtils.java
package jadx.api.plugins.utils; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.util.Set; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CommonFileUtils { private static final Logger LOG = LoggerFactory.getLogger(CommonFileUtils.class); public static final File CWD = getCWD(); public static final Path CWD_PATH = CWD.toPath(); private static File getCWD() { try { return new File(".").getCanonicalFile(); } catch (IOException e) { throw new RuntimeException("Failed to init current working dir constant", e); } } public static Path saveToTempFile(InputStream in, String suffix) throws IOException { return saveToTempFile(null, in, suffix); } public static Path saveToTempFile(byte[] dataPrefix, InputStream in, String suffix) throws IOException { Path tempFile = Files.createTempFile("jadx-temp-", suffix); try (OutputStream out = Files.newOutputStream(tempFile)) { if (dataPrefix != null) { out.write(dataPrefix); } copyStream(in, out); } catch (Exception e) { throw new IOException("Failed to save temp file", e); } return tempFile; } public static boolean safeDeleteFile(File file) { try { return file.delete(); } catch (Exception e) { LOG.warn("Failed to delete file: {}", file, e); return false; } } public static byte[] loadBytes(InputStream input) throws IOException { return loadBytes(null, input); } public static byte[] loadBytes(byte[] dataPrefix, InputStream in) throws IOException { int estimateSize = dataPrefix == null ? in.available() : dataPrefix.length + in.available(); try (ByteArrayOutputStream out = new ByteArrayOutputStream(estimateSize)) { if (dataPrefix != null) { out.write(dataPrefix); } copyStream(in, out); return out.toByteArray(); } catch (Exception e) { throw new IOException("Failed to read input stream to bytes array", e); } } public static void copyStream(InputStream input, OutputStream output) throws IOException { byte[] buffer = new byte[8192]; while (true) { int count = input.read(buffer); if (count == -1) { break; } output.write(buffer, 0, count); } } @Nullable public static String getFileExtension(String fileName) { int dotIndex = fileName.lastIndexOf('.'); if (dotIndex == -1) { return null; } return fileName.substring(dotIndex + 1); } public static String removeFileExtension(String fileName) { int dotIndex = fileName.lastIndexOf('.'); if (dotIndex == -1) { return fileName; } return fileName.substring(0, dotIndex); } private static final Set<String> ZIP_FILE_EXTS = Utils.constSet("zip", "jar", "apk"); public static boolean isZipFileExt(String fileName) { String ext = getFileExtension(fileName); if (ext == null) { return false; } return ZIP_FILE_EXTS.contains(ext); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/events/JadxEvents.java
jadx-core/src/main/java/jadx/api/plugins/events/JadxEvents.java
package jadx.api.plugins.events; import jadx.api.plugins.events.types.NodeRenamedByUser; import jadx.api.plugins.events.types.ReloadProject; import jadx.api.plugins.events.types.ReloadSettingsWindow; import jadx.api.plugins.gui.ISettingsGroup; import jadx.api.plugins.gui.JadxGuiSettings; import static jadx.api.plugins.events.JadxEventType.create; /** * Typed and extendable enumeration of event types */ public class JadxEvents { /** * Notify about renaming done by user (GUI only). */ public static final JadxEventType<NodeRenamedByUser> NODE_RENAMED_BY_USER = create("NODE_RENAMED_BY_USER"); /** * Request reload of a current project (GUI only). */ public static final JadxEventType<ReloadProject> RELOAD_PROJECT = create("RELOAD_PROJECT"); /** * Request reload of a settings window (GUI only). * Useful for a reload custom settings group which was set with * {@link JadxGuiSettings#setCustomSettingsGroup(ISettingsGroup)}. */ public static final JadxEventType<ReloadSettingsWindow> RELOAD_SETTINGS_WINDOW = create("RELOAD_SETTINGS_WINDOW"); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/events/JadxEventType.java
jadx-core/src/main/java/jadx/api/plugins/events/JadxEventType.java
package jadx.api.plugins.events; public abstract class JadxEventType<T extends IJadxEvent> { public static <E extends IJadxEvent> JadxEventType<E> create() { return new JadxEventType<>() { }; } public static <E extends IJadxEvent> JadxEventType<E> create(String name) { return new JadxEventType<>() { @Override public String toString() { return name; } }; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/events/IJadxEvent.java
jadx-core/src/main/java/jadx/api/plugins/events/IJadxEvent.java
package jadx.api.plugins.events; public interface IJadxEvent { JadxEventType<? extends IJadxEvent> getType(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/events/IJadxEvents.java
jadx-core/src/main/java/jadx/api/plugins/events/IJadxEvents.java
package jadx.api.plugins.events; import java.util.function.Consumer; public interface IJadxEvents { /** * Send an event object. * For public event types check {@link JadxEvents} class. */ void send(IJadxEvent event); /** * Register listener for specific event. * For public event types check {@link JadxEvents} class. */ <E extends IJadxEvent> void addListener(JadxEventType<E> eventType, Consumer<E> listener); /** * Remove listener for specific event. * Listener should be same or equal object. */ <E extends IJadxEvent> void removeListener(JadxEventType<E> eventType, Consumer<E> listener); /** * Clear all listeners. */ void reset(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/events/types/NodeRenamedByUser.java
jadx-core/src/main/java/jadx/api/plugins/events/types/NodeRenamedByUser.java
package jadx.api.plugins.events.types; import org.jetbrains.annotations.Nullable; import jadx.api.metadata.ICodeNodeRef; import jadx.api.plugins.events.IJadxEvent; import jadx.api.plugins.events.JadxEventType; import jadx.api.plugins.events.JadxEvents; public class NodeRenamedByUser implements IJadxEvent { private final ICodeNodeRef node; private final String oldName; private final String newName; /** * Optional JRenameNode instance */ private @Nullable Object renameNode; /** * Request reset name to original */ private boolean resetName = false; public NodeRenamedByUser(ICodeNodeRef node, String oldName, String newName) { this.node = node; this.oldName = oldName; this.newName = newName; } public ICodeNodeRef getNode() { return node; } public String getOldName() { return oldName; } public String getNewName() { return newName; } public Object getRenameNode() { return renameNode; } public void setRenameNode(Object renameNode) { this.renameNode = renameNode; } public boolean isResetName() { return resetName; } public void setResetName(boolean resetName) { this.resetName = resetName; } @Override public JadxEventType<NodeRenamedByUser> getType() { return JadxEvents.NODE_RENAMED_BY_USER; } @Override public String toString() { return "NodeRenamedByUser{" + node + ", '" + oldName + "' -> '" + newName + '\'' + (resetName ? ", reset name" : "") + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/events/types/ReloadSettingsWindow.java
jadx-core/src/main/java/jadx/api/plugins/events/types/ReloadSettingsWindow.java
package jadx.api.plugins.events.types; import jadx.api.plugins.events.IJadxEvent; import jadx.api.plugins.events.JadxEventType; import jadx.api.plugins.events.JadxEvents; public class ReloadSettingsWindow implements IJadxEvent { public static final ReloadSettingsWindow INSTANCE = new ReloadSettingsWindow(); private ReloadSettingsWindow() { // singleton } @Override public JadxEventType<ReloadSettingsWindow> getType() { return JadxEvents.RELOAD_SETTINGS_WINDOW; } @Override public String toString() { return "RELOAD_SETTINGS_WINDOW"; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/events/types/ReloadProject.java
jadx-core/src/main/java/jadx/api/plugins/events/types/ReloadProject.java
package jadx.api.plugins.events.types; import jadx.api.plugins.events.IJadxEvent; import jadx.api.plugins.events.JadxEventType; import jadx.api.plugins.events.JadxEvents; public class ReloadProject implements IJadxEvent { public static final ReloadProject EVENT = new ReloadProject(); private ReloadProject() { // singleton } @Override public JadxEventType<ReloadProject> getType() { return JadxEvents.RELOAD_PROJECT; } @Override public String toString() { return "RELOAD_PROJECT"; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/data/JadxPluginRuntimeData.java
jadx-core/src/main/java/jadx/api/plugins/data/JadxPluginRuntimeData.java
package jadx.api.plugins.data; import java.io.Closeable; import java.nio.file.Path; import java.util.List; import org.jetbrains.annotations.Nullable; import jadx.api.plugins.JadxPlugin; import jadx.api.plugins.JadxPluginInfo; import jadx.api.plugins.input.ICodeLoader; import jadx.api.plugins.input.JadxCodeInput; import jadx.api.plugins.options.JadxPluginOptions; /** * Runtime plugin data. */ public interface JadxPluginRuntimeData { boolean isInitialized(); String getPluginId(); JadxPlugin getPluginInstance(); JadxPluginInfo getPluginInfo(); List<JadxCodeInput> getCodeInputs(); @Nullable JadxPluginOptions getOptions(); String getInputsHash(); /** * Convenient method to simplify code loading from custom files. */ ICodeLoader loadCodeFiles(List<Path> files, @Nullable Closeable closeable); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/data/IJadxFiles.java
jadx-core/src/main/java/jadx/api/plugins/data/IJadxFiles.java
package jadx.api.plugins.data; import java.nio.file.Path; public interface IJadxFiles { /** * Plugin cache directory. */ Path getPluginCacheDir(); /** * Plugin config directory. */ Path getPluginConfigDir(); /** * Plugin temp directory. */ Path getPluginTempDir(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/data/IJadxPlugins.java
jadx-core/src/main/java/jadx/api/plugins/data/IJadxPlugins.java
package jadx.api.plugins.data; import jadx.api.plugins.JadxPlugin; public interface IJadxPlugins { JadxPluginRuntimeData getById(String pluginId); JadxPluginRuntimeData getProviding(String provideId); <P extends JadxPlugin> P getInstance(Class<P> pluginCls); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/resources/IResourcesLoader.java
jadx-core/src/main/java/jadx/api/plugins/resources/IResourcesLoader.java
package jadx.api.plugins.resources; public interface IResourcesLoader { void addResContainerFactory(IResContainerFactory resContainerFactory); void addResTableParserProvider(IResTableParserProvider resTableParserProvider); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/resources/IResContainerFactory.java
jadx-core/src/main/java/jadx/api/plugins/resources/IResContainerFactory.java
package jadx.api.plugins.resources; import java.io.IOException; import java.io.InputStream; import org.jetbrains.annotations.Nullable; import jadx.api.ResourceFile; import jadx.core.dex.nodes.RootNode; import jadx.core.xmlgen.ResContainer; /** * Factory for {@link ResContainer}. Can be used in plugins via * {@code context.getResourcesLoader().addResContainerFactory()} to implement content parsing in * files with * different formats. */ public interface IResContainerFactory { /** * Optional init method */ default void init(RootNode root) { } /** * Checks if resource file is of expected format and tries to parse its content. * * @return {@link ResContainer} if file is of expected format, {@code null} otherwise. */ @Nullable ResContainer create(ResourceFile resFile, InputStream inputStream) throws IOException; }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/resources/IResTableParserProvider.java
jadx-core/src/main/java/jadx/api/plugins/resources/IResTableParserProvider.java
package jadx.api.plugins.resources; import org.jetbrains.annotations.Nullable; import jadx.api.ResourceFile; import jadx.core.dex.nodes.RootNode; import jadx.core.xmlgen.IResTableParser; /** * Provides the resource table parser instance for specific resource table file format. Can be used * in plugins via {@code context.getResourcesLoader().addResTableParserProvider()} to parse * resources from tables * in different formats. */ public interface IResTableParserProvider { /** * Optional init method */ default void init(RootNode root) { } /** * Checks a file format and provides the instance if the format is expected. * * @return {@link IResTableParser} if resource table is of expected format, {@code null} otherwise. */ @Nullable IResTableParser getParser(ResourceFile resFile); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/gui/JadxGuiContext.java
jadx-core/src/main/java/jadx/api/plugins/gui/JadxGuiContext.java
package jadx.api.plugins.gui; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.KeyStroke; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import jadx.api.gui.tree.ITreeNode; import jadx.api.metadata.ICodeNodeRef; public interface JadxGuiContext { /** * Run code in UI Thread */ void uiRun(Runnable runnable); /** * Add global menu entry ('Plugins' section) */ void addMenuAction(String name, Runnable action); /** * Add code viewer popup menu entry * * @param name entry title * @param enabled check if entry should be enabled, called on popup creation * @param keyBinding optional assigned keybinding {@link KeyStroke#getKeyStroke(String)} */ void addPopupMenuAction(String name, @Nullable Function<ICodeNodeRef, Boolean> enabled, @Nullable String keyBinding, Consumer<ICodeNodeRef> action); /** * Add popup menu entry for tree node * * @param name entry title * @param addPredicate check if entry should be added for provided node, called on popup creation */ @ApiStatus.Experimental void addTreePopupMenuEntry(String name, Predicate<ITreeNode> addPredicate, Consumer<ITreeNode> action); /** * Attach new key binding to main window * * @param id unique ID string * @param keyBinding keybinding string {@link KeyStroke#getKeyStroke(String)} * @param action runnable action * @return false if already registered */ boolean registerGlobalKeyBinding(String id, String keyBinding, Runnable action); void copyToClipboard(String str); /** * Access to GUI settings */ JadxGuiSettings settings(); /** * Main window component. * Can be used as a parent for creating new windows or dialogs. */ JFrame getMainFrame(); /** * Load SVG icon from jadx resources. * All available icons can be found in "jadx-gui/src/main/resources/icons". * Method is thread-safe. * * @param name short name in form: "category/iconName", example: "nodes/publicClass" * @return loaded and cached icon, if icon not found returns default icon: "ui/error" */ ImageIcon getSVGIcon(String name); ICodeNodeRef getNodeUnderCaret(); ICodeNodeRef getNodeUnderMouse(); ICodeNodeRef getEnclosingNodeUnderCaret(); ICodeNodeRef getEnclosingNodeUnderMouse(); /** * Jump to a code ref * * @return if successfully jumped to the code ref */ boolean open(ICodeNodeRef ref); /** * Open usage dialog for a node */ void openUsageDialog(ICodeNodeRef ref); /** * Reload code in active tab */ void reloadActiveTab(); /** * Reload code in all open tabs */ void reloadAllTabs(); /** * Save node rename in a project and run all needed UI updates */ void applyNodeRename(ICodeNodeRef node); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/gui/ISettingsGroup.java
jadx-core/src/main/java/jadx/api/plugins/gui/ISettingsGroup.java
package jadx.api.plugins.gui; import java.util.Collections; import java.util.List; import javax.swing.JComponent; /** * Settings page customization */ public interface ISettingsGroup { /** * Node name */ String getTitle(); /** * Custom page component */ JComponent buildComponent(); /** * Optional child nodes list */ default List<ISettingsGroup> getSubGroups() { return Collections.emptyList(); } /** * Settings close handler. * Apply settings if 'save' param set to true. * It can be used to clean up resources. */ default void close(boolean save) { // optional method } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/plugins/gui/JadxGuiSettings.java
jadx-core/src/main/java/jadx/api/plugins/gui/JadxGuiSettings.java
package jadx.api.plugins.gui; import java.util.List; import jadx.api.plugins.options.OptionDescription; public interface JadxGuiSettings { /** * Set plugin custom settings page */ void setCustomSettingsGroup(ISettingsGroup group); /** * Helper method to build options group only for provided option list */ ISettingsGroup buildSettingsGroupForOptions(String title, List<OptionDescription> options); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/deobf/IRenameCondition.java
jadx-core/src/main/java/jadx/api/deobf/IRenameCondition.java
package jadx.api.deobf; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.FieldNode; import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.PackageNode; import jadx.core.dex.nodes.RootNode; public interface IRenameCondition { void init(RootNode root); boolean shouldRename(PackageNode pkg); boolean shouldRename(ClassNode cls); boolean shouldRename(FieldNode fld); boolean shouldRename(MethodNode mth); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/deobf/IAliasProvider.java
jadx-core/src/main/java/jadx/api/deobf/IAliasProvider.java
package jadx.api.deobf; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.FieldNode; import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.PackageNode; import jadx.core.dex.nodes.RootNode; public interface IAliasProvider { default void init(RootNode root) { // optional } String forPackage(PackageNode pkg); String forClass(ClassNode cls); String forField(FieldNode fld); String forMethod(MethodNode mth); /** * Optional method to set initial max indexes loaded from mapping */ default void initIndexes(int pkg, int cls, int fld, int mth) { // optional } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/deobf/IDeobfCondition.java
jadx-core/src/main/java/jadx/api/deobf/IDeobfCondition.java
package jadx.api.deobf; import jadx.api.deobf.impl.CombineDeobfConditions; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.FieldNode; import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.PackageNode; import jadx.core.dex.nodes.RootNode; /** * Utility interface to simplify merging several rename conditions to build {@link IRenameCondition} * instance with {@link CombineDeobfConditions#combine(IDeobfCondition...)}. */ public interface IDeobfCondition { enum Action { NO_ACTION, FORCE_RENAME, FORBID_RENAME, } void init(RootNode root); Action check(PackageNode pkg); Action check(ClassNode cls); Action check(FieldNode fld); Action check(MethodNode mth); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/deobf/impl/CombineDeobfConditions.java
jadx-core/src/main/java/jadx/api/deobf/impl/CombineDeobfConditions.java
package jadx.api.deobf.impl; import java.util.Arrays; import java.util.List; import java.util.function.Function; import jadx.api.deobf.IDeobfCondition; import jadx.api.deobf.IRenameCondition; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.FieldNode; import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.PackageNode; import jadx.core.dex.nodes.RootNode; public class CombineDeobfConditions implements IRenameCondition { public static IRenameCondition combine(List<IDeobfCondition> conditions) { return new CombineDeobfConditions(conditions); } public static IRenameCondition combine(IDeobfCondition... conditions) { return new CombineDeobfConditions(Arrays.asList(conditions)); } private final List<IDeobfCondition> conditions; private CombineDeobfConditions(List<IDeobfCondition> conditions) { if (conditions == null || conditions.isEmpty()) { throw new IllegalArgumentException("Conditions list can't be empty"); } this.conditions = conditions; } private boolean combineFunc(Function<IDeobfCondition, IDeobfCondition.Action> check) { for (IDeobfCondition c : conditions) { switch (check.apply(c)) { case NO_ACTION: // ignore break; case FORCE_RENAME: return true; case FORBID_RENAME: return false; } } return false; } @Override public void init(RootNode root) { conditions.forEach(c -> c.init(root)); } @Override public boolean shouldRename(PackageNode pkg) { return combineFunc(c -> c.check(pkg)); } @Override public boolean shouldRename(ClassNode cls) { return combineFunc(c -> c.check(cls)); } @Override public boolean shouldRename(FieldNode fld) { return combineFunc(c -> c.check(fld)); } @Override public boolean shouldRename(MethodNode mth) { return combineFunc(c -> c.check(mth)); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/deobf/impl/AnyRenameCondition.java
jadx-core/src/main/java/jadx/api/deobf/impl/AnyRenameCondition.java
package jadx.api.deobf.impl; import java.util.function.BiPredicate; import jadx.api.deobf.IRenameCondition; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.FieldNode; import jadx.core.dex.nodes.IDexNode; import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.PackageNode; import jadx.core.dex.nodes.RootNode; public class AnyRenameCondition implements IRenameCondition { private final BiPredicate<String, IDexNode> predicate; public AnyRenameCondition(BiPredicate<String, IDexNode> predicate) { this.predicate = predicate; } @Override public void init(RootNode root) { } @Override public boolean shouldRename(PackageNode pkg) { return predicate.test(pkg.getAliasPkgInfo().getName(), pkg); } @Override public boolean shouldRename(ClassNode cls) { return predicate.test(cls.getAlias(), cls); } @Override public boolean shouldRename(FieldNode fld) { return predicate.test(fld.getAlias(), fld); } @Override public boolean shouldRename(MethodNode mth) { return predicate.test(mth.getAlias(), mth); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/deobf/impl/AlwaysRename.java
jadx-core/src/main/java/jadx/api/deobf/impl/AlwaysRename.java
package jadx.api.deobf.impl; import jadx.api.deobf.IRenameCondition; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.FieldNode; import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.PackageNode; import jadx.core.dex.nodes.RootNode; public class AlwaysRename implements IRenameCondition { public static final IRenameCondition INSTANCE = new AlwaysRename(); private AlwaysRename() { } @Override public void init(RootNode root) { } @Override public boolean shouldRename(PackageNode pkg) { return true; } @Override public boolean shouldRename(ClassNode cls) { return true; } @Override public boolean shouldRename(FieldNode fld) { return true; } @Override public boolean shouldRename(MethodNode mth) { return true; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/security/IJadxSecurity.java
jadx-core/src/main/java/jadx/api/security/IJadxSecurity.java
package jadx.api.security; import java.io.InputStream; import org.w3c.dom.Document; import jadx.zip.security.IJadxZipSecurity; public interface IJadxSecurity extends IJadxZipSecurity { /** * Check if application package is safe * * @return normalized/sanitized string or same string if safe */ String verifyAppPackage(String appPackage); /** * XML document parser */ Document parseXml(InputStream in); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/security/JadxSecurityFlag.java
jadx-core/src/main/java/jadx/api/security/JadxSecurityFlag.java
package jadx.api.security; import java.util.EnumSet; import java.util.Set; public enum JadxSecurityFlag { VERIFY_APP_PACKAGE, SECURE_XML_PARSER, SECURE_ZIP_READER; public static Set<JadxSecurityFlag> all() { return EnumSet.allOf(JadxSecurityFlag.class); } public static Set<JadxSecurityFlag> none() { return EnumSet.noneOf(JadxSecurityFlag.class); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/security/impl/JadxSecurity.java
jadx-core/src/main/java/jadx/api/security/impl/JadxSecurity.java
package jadx.api.security.impl; import java.io.File; import java.io.InputStream; import java.util.Set; import javax.xml.parsers.DocumentBuilderFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import jadx.api.security.IJadxSecurity; import jadx.api.security.JadxSecurityFlag; import jadx.core.deobf.NameMapper; import jadx.zip.IZipEntry; import jadx.zip.security.DisabledZipSecurity; import jadx.zip.security.IJadxZipSecurity; import jadx.zip.security.JadxZipSecurity; import static jadx.api.security.JadxSecurityFlag.SECURE_ZIP_READER; public class JadxSecurity implements IJadxSecurity { private static final Logger LOG = LoggerFactory.getLogger(JadxSecurity.class); private final Set<JadxSecurityFlag> flags; private final IJadxZipSecurity zipSecurity; public JadxSecurity(Set<JadxSecurityFlag> flags) { this.flags = flags; this.zipSecurity = flags.contains(SECURE_ZIP_READER) ? new JadxZipSecurity() : DisabledZipSecurity.INSTANCE; } public JadxSecurity(Set<JadxSecurityFlag> flags, IJadxZipSecurity zipSecurity) { this.flags = flags; this.zipSecurity = zipSecurity; } @Override public boolean isValidEntry(IZipEntry entry) { return zipSecurity.isValidEntry(entry); } @Override public boolean isValidEntryName(String entryName) { return zipSecurity.isValidEntryName(entryName); } @Override public boolean isInSubDirectory(File baseDir, File file) { return zipSecurity.isInSubDirectory(baseDir, file); } @Override public boolean useLimitedDataStream() { return zipSecurity.useLimitedDataStream(); } @Override public int getMaxEntriesCount() { return zipSecurity.getMaxEntriesCount(); } @Override public String verifyAppPackage(String appPackage) { if (flags.contains(JadxSecurityFlag.VERIFY_APP_PACKAGE) && !NameMapper.isValidFullIdentifier(appPackage)) { LOG.warn("App package '{}' has invalid format and will be ignored", appPackage); return "INVALID_PACKAGE"; } return appPackage; } @Override public Document parseXml(InputStream in) { DocumentBuilderFactory dbf; if (flags.contains(JadxSecurityFlag.SECURE_XML_PARSER)) { dbf = SecureDBFHolder.INSTANCE; } else { dbf = SimpleDBFHolder.INSTANCE; } try { return dbf.newDocumentBuilder().parse(in); } catch (Exception e) { throw new RuntimeException("Failed to parse xml", e); } } private static final class SimpleDBFHolder { private static final DocumentBuilderFactory INSTANCE = DocumentBuilderFactory.newInstance(); } private static final class SecureDBFHolder { private static final DocumentBuilderFactory INSTANCE = buildSecureDBF(); private static DocumentBuilderFactory buildSecureDBF() { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); dbf.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes", false); dbf.setXIncludeAware(false); dbf.setExpandEntityReferences(false); return dbf; } catch (Exception e) { throw new RuntimeException("Fail to build secure XML DocumentBuilderFactory", e); } } } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/usage/IUsageInfoData.java
jadx-core/src/main/java/jadx/api/usage/IUsageInfoData.java
package jadx.api.usage; import jadx.core.dex.nodes.ClassNode; public interface IUsageInfoData { void apply(); void applyForClass(ClassNode cls); void visitUsageData(IUsageInfoVisitor visitor); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/usage/IUsageInfoVisitor.java
jadx-core/src/main/java/jadx/api/usage/IUsageInfoVisitor.java
package jadx.api.usage; import java.util.List; import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.FieldNode; import jadx.core.dex.nodes.MethodNode; public interface IUsageInfoVisitor { void visitClassDeps(ClassNode cls, List<ClassNode> deps); void visitClassUsage(ClassNode cls, List<ClassNode> usage); void visitClassUseInMethods(ClassNode cls, List<MethodNode> methods); void visitFieldsUsage(FieldNode fld, List<MethodNode> methods); void visitMethodsUsage(MethodNode mth, List<MethodNode> methods); void visitComplete(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/usage/IUsageInfoCache.java
jadx-core/src/main/java/jadx/api/usage/IUsageInfoCache.java
package jadx.api.usage; import java.io.Closeable; import org.jetbrains.annotations.Nullable; import jadx.core.dex.nodes.RootNode; public interface IUsageInfoCache extends Closeable { @Nullable IUsageInfoData get(RootNode root); void set(RootNode root, IUsageInfoData data); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/usage/impl/EmptyUsageInfoCache.java
jadx-core/src/main/java/jadx/api/usage/impl/EmptyUsageInfoCache.java
package jadx.api.usage.impl; import java.io.IOException; import org.jetbrains.annotations.Nullable; import jadx.api.usage.IUsageInfoCache; import jadx.api.usage.IUsageInfoData; import jadx.core.dex.nodes.RootNode; public class EmptyUsageInfoCache implements IUsageInfoCache { @Override public @Nullable IUsageInfoData get(RootNode root) { return null; } @Override public void set(RootNode root, IUsageInfoData data) { } @Override public void close() throws IOException { } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/usage/impl/InMemoryUsageInfoCache.java
jadx-core/src/main/java/jadx/api/usage/impl/InMemoryUsageInfoCache.java
package jadx.api.usage.impl; import org.jetbrains.annotations.Nullable; import jadx.api.usage.IUsageInfoCache; import jadx.api.usage.IUsageInfoData; import jadx.core.dex.nodes.RootNode; public class InMemoryUsageInfoCache implements IUsageInfoCache { private IUsageInfoData data; /** * `data` field tied to root node instance, keep hash to reset cache on change */ private int rootNodeHash; @Override public @Nullable IUsageInfoData get(RootNode root) { return rootNodeHash == root.hashCode() ? data : null; } @Override public void set(RootNode root, IUsageInfoData data) { this.rootNodeHash = root.hashCode(); this.data = data; } @Override public void close() { this.rootNodeHash = 0; this.data = null; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/CodeRefType.java
jadx-core/src/main/java/jadx/api/data/CodeRefType.java
package jadx.api.data; public enum CodeRefType { MTH_ARG, VAR, CATCH, INSN, }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/ICodeRename.java
jadx-core/src/main/java/jadx/api/data/ICodeRename.java
package jadx.api.data; import org.jetbrains.annotations.Nullable; public interface ICodeRename extends Comparable<ICodeRename> { IJavaNodeRef getNodeRef(); @Nullable IJavaCodeRef getCodeRef(); String getNewName(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/ICodeComment.java
jadx-core/src/main/java/jadx/api/data/ICodeComment.java
package jadx.api.data; import org.jetbrains.annotations.Nullable; public interface ICodeComment extends Comparable<ICodeComment> { IJavaNodeRef getNodeRef(); @Nullable IJavaCodeRef getCodeRef(); String getComment(); CommentStyle getStyle(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/CommentStyle.java
jadx-core/src/main/java/jadx/api/data/CommentStyle.java
package jadx.api.data; public enum CommentStyle { /** * <pre> * // comment * </pre> */ LINE("// ", "// ", ""), // @formatter:off /** * <pre> * /* * * comment * *&#47; * </pre> */ // @formatter:on BLOCK("/*\n * ", " * ", "\n */"), /** * <pre> * /* comment *&#47; * </pre> */ BLOCK_CONDENSED("/* ", " * ", " */"), // @formatter:off /** * <pre> * /** * * comment * *&#47; * </pre> */ // @formatter:on JAVADOC("/**\n * ", " * ", "\n */"), /** * <pre> * /** comment *&#47; * </pre> */ JAVADOC_CONDENSED("/** ", " * ", " */"); private final String start; private final String onNewLine; private final String end; CommentStyle(String start, String onNewLine, String end) { this.start = start; this.onNewLine = onNewLine; this.end = end; } public String getStart() { return start; } public String getOnNewLine() { return onNewLine; } public String getEnd() { return end; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/ICodeData.java
jadx-core/src/main/java/jadx/api/data/ICodeData.java
package jadx.api.data; import java.util.List; public interface ICodeData { List<ICodeComment> getComments(); List<ICodeRename> getRenames(); boolean isEmpty(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/IRenameNode.java
jadx-core/src/main/java/jadx/api/data/IRenameNode.java
package jadx.api.data; public interface IRenameNode { void rename(String newName); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/IJavaNodeRef.java
jadx-core/src/main/java/jadx/api/data/IJavaNodeRef.java
package jadx.api.data; public interface IJavaNodeRef extends Comparable<IJavaNodeRef> { enum RefType { CLASS, FIELD, METHOD, PKG } RefType getType(); String getDeclaringClass(); String getShortId(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/IJavaCodeRef.java
jadx-core/src/main/java/jadx/api/data/IJavaCodeRef.java
package jadx.api.data; import org.jetbrains.annotations.NotNull; public interface IJavaCodeRef extends Comparable<IJavaCodeRef> { CodeRefType getAttachType(); int getIndex(); @Override default int compareTo(@NotNull IJavaCodeRef o) { return Integer.compare(getIndex(), o.getIndex()); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/impl/JadxCodeData.java
jadx-core/src/main/java/jadx/api/data/impl/JadxCodeData.java
package jadx.api.data.impl; import java.util.Collections; import java.util.List; import jadx.api.data.ICodeComment; import jadx.api.data.ICodeData; import jadx.api.data.ICodeRename; public class JadxCodeData implements ICodeData { private List<ICodeComment> comments = Collections.emptyList(); private List<ICodeRename> renames = Collections.emptyList(); @Override public List<ICodeComment> getComments() { return comments; } public void setComments(List<ICodeComment> comments) { this.comments = comments; } @Override public List<ICodeRename> getRenames() { return renames; } public void setRenames(List<ICodeRename> renames) { this.renames = renames; } @Override public boolean isEmpty() { return comments.isEmpty() && renames.isEmpty(); } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/impl/JadxCodeRename.java
jadx-core/src/main/java/jadx/api/data/impl/JadxCodeRename.java
package jadx.api.data.impl; import java.util.Objects; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import jadx.api.data.ICodeRename; import jadx.api.data.IJavaCodeRef; import jadx.api.data.IJavaNodeRef; public class JadxCodeRename implements ICodeRename { private IJavaNodeRef nodeRef; @Nullable private IJavaCodeRef codeRef; private String newName; public JadxCodeRename(IJavaNodeRef nodeRef, String newName) { this(nodeRef, null, newName); } public JadxCodeRename(IJavaNodeRef nodeRef, @Nullable IJavaCodeRef codeRef, String newName) { this.nodeRef = nodeRef; this.codeRef = codeRef; this.newName = newName; } public JadxCodeRename() { // used in json serialization } @Override public IJavaNodeRef getNodeRef() { return nodeRef; } public void setNodeRef(IJavaNodeRef nodeRef) { this.nodeRef = nodeRef; } @Override public IJavaCodeRef getCodeRef() { return codeRef; } public void setCodeRef(IJavaCodeRef codeRef) { this.codeRef = codeRef; } @Override public String getNewName() { return newName; } public void setNewName(String newName) { this.newName = newName; } @Override public int compareTo(@NotNull ICodeRename other) { int cmpNodeRef = this.getNodeRef().compareTo(other.getNodeRef()); if (cmpNodeRef != 0) { return cmpNodeRef; } if (this.getCodeRef() != null && other.getCodeRef() != null) { return this.getCodeRef().compareTo(other.getCodeRef()); } return this.getNewName().compareTo(other.getNewName()); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ICodeRename)) { return false; } ICodeRename other = (ICodeRename) o; return getNodeRef().equals(other.getNodeRef()) && Objects.equals(getCodeRef(), other.getCodeRef()); } @Override public int hashCode() { return 31 * getNodeRef().hashCode() + Objects.hashCode(getCodeRef()); } @Override public String toString() { return "JadxCodeRename{" + nodeRef + ", codeRef=" + codeRef + ", newName='" + newName + '\'' + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/impl/JadxCodeComment.java
jadx-core/src/main/java/jadx/api/data/impl/JadxCodeComment.java
package jadx.api.data.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import jadx.api.data.CommentStyle; import jadx.api.data.ICodeComment; import jadx.api.data.IJavaCodeRef; import jadx.api.data.IJavaNodeRef; public class JadxCodeComment implements ICodeComment { private IJavaNodeRef nodeRef; @Nullable private IJavaCodeRef codeRef; private String comment; private CommentStyle style = CommentStyle.LINE; public JadxCodeComment(IJavaNodeRef nodeRef, String comment) { this(nodeRef, null, comment); } public JadxCodeComment(IJavaNodeRef nodeRef, String comment, CommentStyle style) { this(nodeRef, null, comment, style); } public JadxCodeComment(IJavaNodeRef nodeRef, @Nullable IJavaCodeRef codeRef, String comment) { this(nodeRef, codeRef, comment, CommentStyle.LINE); } public JadxCodeComment(IJavaNodeRef nodeRef, @Nullable IJavaCodeRef codeRef, String comment, CommentStyle style) { this.nodeRef = nodeRef; this.codeRef = codeRef; this.comment = comment; this.style = style; } public JadxCodeComment() { // for json deserialization } @Override public IJavaNodeRef getNodeRef() { return nodeRef; } public void setNodeRef(IJavaNodeRef nodeRef) { this.nodeRef = nodeRef; } @Nullable @Override public IJavaCodeRef getCodeRef() { return codeRef; } public void setCodeRef(@Nullable IJavaCodeRef codeRef) { this.codeRef = codeRef; } @Override public String getComment() { return comment; } public void setComment(String comment) { this.comment = comment; } @Override public CommentStyle getStyle() { return style; } public void setStyle(CommentStyle style) { this.style = style; } @Override public int compareTo(@NotNull ICodeComment other) { int cmpNodeRef = this.getNodeRef().compareTo(other.getNodeRef()); if (cmpNodeRef != 0) { return cmpNodeRef; } if (this.getCodeRef() != null && other.getCodeRef() != null) { return this.getCodeRef().compareTo(other.getCodeRef()); } return this.getComment().compareTo(other.getComment()); } @Override public String toString() { return "JadxCodeComment{" + nodeRef + ", ref=" + codeRef + ", comment='" + comment + '\'' + ", style=" + style + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/impl/JadxNodeRef.java
jadx-core/src/main/java/jadx/api/data/impl/JadxNodeRef.java
package jadx.api.data.impl; import java.util.Comparator; import java.util.Objects; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import jadx.api.JavaClass; import jadx.api.JavaField; import jadx.api.JavaMethod; import jadx.api.JavaNode; import jadx.api.data.IJavaNodeRef; public class JadxNodeRef implements IJavaNodeRef { @Nullable public static JadxNodeRef forJavaNode(JavaNode javaNode) { if (javaNode instanceof JavaClass) { return forCls((JavaClass) javaNode); } if (javaNode instanceof JavaMethod) { return forMth((JavaMethod) javaNode); } if (javaNode instanceof JavaField) { return forFld((JavaField) javaNode); } return null; } public static JadxNodeRef forCls(JavaClass cls) { return new JadxNodeRef(RefType.CLASS, getClassRefStr(cls), null); } public static JadxNodeRef forCls(String clsFullName) { return new JadxNodeRef(RefType.CLASS, clsFullName, null); } public static JadxNodeRef forMth(JavaMethod mth) { return new JadxNodeRef(RefType.METHOD, getClassRefStr(mth.getDeclaringClass()), mth.getMethodNode().getMethodInfo().getShortId()); } public static JadxNodeRef forFld(JavaField fld) { return new JadxNodeRef(RefType.FIELD, getClassRefStr(fld.getDeclaringClass()), fld.getFieldNode().getFieldInfo().getShortId()); } public static JadxNodeRef forPkg(String pkgFullName) { return new JadxNodeRef(RefType.PKG, pkgFullName, ""); } private static String getClassRefStr(JavaClass cls) { return cls.getClassNode().getClassInfo().getRawName(); } private RefType refType; private String declClass; @Nullable private String shortId; public JadxNodeRef(RefType refType, String declClass, @Nullable String shortId) { this.refType = refType; this.declClass = declClass; this.shortId = shortId; } public JadxNodeRef() { // for json deserialization } @Override public RefType getType() { return refType; } public void setRefType(RefType refType) { this.refType = refType; } @Override public String getDeclaringClass() { return declClass; } public void setDeclClass(String declClass) { this.declClass = declClass; } @Nullable @Override public String getShortId() { return shortId; } public void setShortId(@Nullable String shortId) { this.shortId = shortId; } private static final Comparator<IJavaNodeRef> COMPARATOR = Comparator .comparing(IJavaNodeRef::getType) .thenComparing(IJavaNodeRef::getDeclaringClass) .thenComparing(IJavaNodeRef::getShortId); @Override public int compareTo(@NotNull IJavaNodeRef other) { return COMPARATOR.compare(this, other); } @Override public int hashCode() { return Objects.hash(refType, declClass, shortId); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof JadxNodeRef)) { return false; } JadxNodeRef that = (JadxNodeRef) o; return refType == that.refType && Objects.equals(declClass, that.declClass) && Objects.equals(shortId, that.shortId); } @Override public String toString() { switch (refType) { case CLASS: case PKG: return declClass; case FIELD: case METHOD: return declClass + "->" + shortId; default: return "unknown node ref type"; } } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/data/impl/JadxCodeRef.java
jadx-core/src/main/java/jadx/api/data/impl/JadxCodeRef.java
package jadx.api.data.impl; import jadx.api.JavaVariable; import jadx.api.data.CodeRefType; import jadx.api.data.IJavaCodeRef; import jadx.api.metadata.annotations.VarNode; public class JadxCodeRef implements IJavaCodeRef { public static JadxCodeRef forInsn(int offset) { return new JadxCodeRef(CodeRefType.INSN, offset); } public static JadxCodeRef forMthArg(int argIndex) { return new JadxCodeRef(CodeRefType.MTH_ARG, argIndex); } public static JadxCodeRef forVar(int regNum, int ssaVersion) { return new JadxCodeRef(CodeRefType.VAR, regNum << 16 | ssaVersion); } public static JadxCodeRef forVar(JavaVariable javaVariable) { return forVar(javaVariable.getReg(), javaVariable.getSsa()); } public static JadxCodeRef forVar(VarNode varNode) { return forVar(varNode.getReg(), varNode.getSsa()); } public static JadxCodeRef forCatch(int handlerOffset) { return new JadxCodeRef(CodeRefType.CATCH, handlerOffset); } private CodeRefType attachType; private int index; public JadxCodeRef(CodeRefType attachType, int index) { this.attachType = attachType; this.index = index; } public JadxCodeRef() { // used for json serialization } public CodeRefType getAttachType() { return attachType; } public void setAttachType(CodeRefType attachType) { this.attachType = attachType; } @Override public int getIndex() { return index; } public void setIndex(int index) { this.index = index; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof JadxCodeRef)) { return false; } JadxCodeRef other = (JadxCodeRef) o; return getIndex() == other.getIndex() && getAttachType() == other.getAttachType(); } @Override public int hashCode() { return 31 * getAttachType().hashCode() + getIndex(); } @Override public String toString() { return "JadxCodeRef{" + "attachType=" + attachType + ", index=" + index + '}'; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/resources/ResourceContentType.java
jadx-core/src/main/java/jadx/api/resources/ResourceContentType.java
package jadx.api.resources; public enum ResourceContentType { CONTENT_TEXT, CONTENT_BINARY, CONTENT_NONE, CONTENT_UNKNOWN, }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/gui/tree/ITreeNode.java
jadx-core/src/main/java/jadx/api/gui/tree/ITreeNode.java
package jadx.api.gui.tree; import javax.swing.Icon; import javax.swing.tree.TreeNode; import org.jetbrains.annotations.Nullable; import jadx.api.metadata.ICodeNodeRef; public interface ITreeNode extends TreeNode { /** * Locale independent node identifier */ String getID(); /** * Node title */ String getName(); /** * Node icon */ Icon getIcon(); /** * Related code node reference. */ @Nullable ICodeNodeRef getCodeNodeRef(); }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/args/ResourceNameSource.java
jadx-core/src/main/java/jadx/api/args/ResourceNameSource.java
package jadx.api.args; /** * Resources original name source (for deobfuscation) */ public enum ResourceNameSource { /** * Automatically select best name (default) */ AUTO, /** * Force use resources provided names */ RESOURCES, /** * Force use resources names from R class */ CODE, }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false
skylot/jadx
https://github.com/skylot/jadx/blob/7bbb58863b8a80c0b862425d2701d23be40aeae8/jadx-core/src/main/java/jadx/api/args/UserRenamesMappingsMode.java
jadx-core/src/main/java/jadx/api/args/UserRenamesMappingsMode.java
package jadx.api.args; public enum UserRenamesMappingsMode { /** * Just read, user can save manually (default) */ READ, /** * Read and autosave after every change */ READ_AND_AUTOSAVE_EVERY_CHANGE, /** * Read and autosave before exiting the app or closing the project */ READ_AND_AUTOSAVE_BEFORE_CLOSING, /** * Don't load and don't save */ IGNORE; public static UserRenamesMappingsMode getDefault() { return READ; } public boolean shouldRead() { return this != IGNORE; } public boolean shouldWrite() { return this == READ_AND_AUTOSAVE_EVERY_CHANGE || this == READ_AND_AUTOSAVE_BEFORE_CLOSING; } }
java
Apache-2.0
7bbb58863b8a80c0b862425d2701d23be40aeae8
2026-01-04T14:45:57.033910Z
false