{"record":{"id":"5dcbd14546d8ea4f","repo":"skylot/jadx","slug":"failed-to-enumerate-cached-classes","errorCode":null,"errorMessage":"Failed to enumerate cached classes","messagePattern":"Failed to enumerate cached classes","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-gui/src/main/java/jadx/gui/cache/code/disk/DiskCodeCache.java","lineNumber":232,"sourceCode":"\t\t\tthrow new JadxRuntimeException(\"Unknown class name: \" + clsFullName);\n\t\t}\n\t\treturn clsData;\n\t}\n\n\tprivate void loadCachedSet() {\n\t\tlong start = System.currentTimeMillis();\n\t\tBitSet cachedSet = new BitSet(clsDataMap.size());\n\t\ttry (Stream<Path> stream = Files.walk(metaDir)) {\n\t\t\tstream.forEach(file -> {\n\t\t\t\tString fileName = file.getFileName().toString();\n\t\t\t\tif (fileName.endsWith(\".jadxmd\")) {\n\t\t\t\t\tString idStr = StringUtils.removeSuffix(fileName, \".jadxmd\");\n\t\t\t\t\tint clsId = Integer.parseInt(idStr, 16);\n\t\t\t\t\tcachedSet.set(clsId);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to enumerate cached classes\", e);\n\t\t}\n\t\tint count = 0;\n\t\tfor (CacheData data : clsDataMap.values()) {\n\t\t\tint clsId = data.getClsId();\n\t\t\tif (cachedSet.get(clsId)) {\n\t\t\t\tdata.setCached(true);\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t\tLOG.info(\"Found {} classes in disk cache, time: {}ms, dir: {}\",\n\t\t\t\tcount, System.currentTimeMillis() - start, metaDir.getParent());\n\t}\n\n\tprivate Path getJavaFile(int clsId) {\n\t\treturn srcDir.resolve(getPathForClsId(clsId, \".java\"));\n\t}\n\n\tprivate Path getMetadataFile(int clsId) {","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-gui/src/main/java/jadx/gui/cache/code/disk/DiskCodeCache.java#L214-L250","documentation":"DiskCodeCache scans the metadata directory via Files.walk to enumerate which class IDs have cached .jadxmd files, building a BitSet of cached classes. If the walk or file parsing fails (missing dir, I/O error, non-hex filename), a JadxRuntimeException is thrown.","triggerScenarios":"loadCachedClasses() calls Files.walk(metaDir), iterates each file, parses filenames ending in .jadxmd by stripping the suffix and parsing the remaining hex string as an int. Integer.parseInt could throw NumberFormatException; the walk could throw IOException if metaDir is inaccessible. All are caught and wrapped.","commonSituations":"Cache directory deleted or moved between startup and this call. Non-cache files placed in the meta directory by external tools. Filesystem errors on a network-mounted cache. Corrupt or partial cache from a crash. Permission change on the cache directory.","solutions":["Clear the cache directory and let jadx rebuild it","Verify the cache directory permissions are consistent","Ensure no external process writes to the jadx cache directory","Use a local, stable cache path"],"exampleFix":"// Clear the cache and restart:\n// rm -rf ~/.jadx/cache\n// Restart jadx-gui — it will rebuild the cache cleanly.","handlingStrategy":"try-catch","validationCode":"// Verify meta directory exists and is readable before enumeration\nif (!Files.isDirectory(metaDir) || !Files.isReadable(metaDir)) {\n    LOG.warn(\"Cache meta dir inaccessible, skipping enumeration\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    diskCodeCache.loadCachedClasses();\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().contains(\"enumerate cached classes\")) {\n        LOG.warn(\"Cache enumeration failed, starting fresh\", e);\n        FileUtils.deleteDirectory(metaDir.toFile());\n    }\n}","preventionTips":["Clear cache after upgrades or crashes","Keep external processes out of the cache directory","Treat enumeration failure as a signal to rebuild cache"],"tags":["cache","io","filesystem","jadx-gui","corrupt-cache"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}