{"record":{"id":"d6e3c663eb92ec6b","repo":"skylot/jadx","slug":"failed-to-load-top-level-domain-list-file-tlds-tx","errorCode":null,"errorMessage":"Failed to load top level domain list file: tlds.txt","messagePattern":"Failed to load top level domain list file: tlds\\.txt","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/deobf/conditions/ExcludePackageWithTLDNames.java","lineNumber":29,"sourceCode":"/**\n * Provides a list of all top level domains, so we can exclude them from deobfuscation.\n */\npublic class ExcludePackageWithTLDNames extends AbstractDeobfCondition {\n\n\t/**\n\t * Lazy load TLD set\n\t */\n\tprivate static class TldHolder {\n\t\tprivate static final Set<String> TLD_SET = loadTldSet();\n\t}\n\n\tprivate static Set<String> loadTldSet() {\n\t\ttry (BufferedReader reader = new BufferedReader(new InputStreamReader(TldHolder.class.getResourceAsStream(\"tlds.txt\")))) {\n\t\t\treturn reader.lines()\n\t\t\t\t\t.filter(line -> !line.startsWith(\"#\") && !line.isEmpty())\n\t\t\t\t\t.collect(Collectors.toSet());\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to load top level domain list file: tlds.txt\", e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic Action check(PackageNode pkg) {\n\t\tif (pkg.isRoot() && TldHolder.TLD_SET.contains(pkg.getName())) {\n\t\t\treturn Action.FORBID_RENAME;\n\t\t}\n\t\treturn Action.NO_ACTION;\n\t}\n}\n","sourceCodeStart":11,"sourceCodeEnd":41,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/deobf/conditions/ExcludePackageWithTLDNames.java#L11-L41","documentation":"Thrown when the bundled resource tlds.txt cannot be loaded from the classpath by ExcludePackageWithTLDNames (a deobfuscation condition that prevents renaming packages whose name is a top-level domain). It is loaded once, lazily, via a static-holder idiom. Any failure opening/reading the resource aborts initialisation.","triggerScenarios":"The resource jadx-core/.../conditions/tlds.txt is missing from the classpath/jar, getResourceAsStream returns null (NullPointerException inside the try), or the stream throws while reading. Happens if the jadx-core jar is repackaged/shaded and resources are stripped, or if the file is corrupted.","commonSituations":"Custom/shaded packaging of jadx that drops resources; building jadx from a partial checkout; classloader isolation (e.g. embedding jadx in another app with a non-standard classloader that does not expose sibling resources); corrupted jar download.","solutions":["Use the official, complete jadx distribution where tlds.txt ships alongside the class.","If repackaging, ensure resources under jadx/core/deobf/conditions/ are included (verify with: jar tf jadx-core.jar | grep tlds.txt).","Guard against null stream: getResourceAsStream can return null - wrap with Objects.requireNonNull and give a clearer message, or fall back to an empty set.","If embedding in another app, use a parent-first classloader or load the resource explicitly via the jadx-core classloader."],"exampleFix":"// before\ntry (BufferedReader reader = new BufferedReader(new InputStreamReader(TldHolder.class.getResourceAsStream(\"tlds.txt\")))) {\n    return reader.lines().filter(line -> !line.startsWith(\"#\") && !line.isEmpty()).collect(Collectors.toSet());\n} catch (Exception e) {\n    throw new JadxRuntimeException(\"Failed to load top level domain list file: tlds.txt\", e);\n}\n\n// after (handle null stream + explicit charset, degrade gracefully)\nInputStream is = TldHolder.class.getResourceAsStream(\"tlds.txt\");\nif (is == null) {\n    LOG.warn(\"tlds.txt not found on classpath; TLD exclusion disabled\");\n    return Collections.emptySet();\n}\ntry (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {\n    return reader.lines().filter(line -> !line.startsWith(\"#\") && !line.isEmpty()).collect(Collectors.toSet());\n} catch (IOException e) {\n    throw new JadxRuntimeException(\"Failed to load top level domain list file: tlds.txt\", e);\n}","handlingStrategy":"fallback","validationCode":"InputStream is = ExcludePackageWithTLDNames.class.getResourceAsStream(\"tlds.txt\");\nif (is == null) {\n    LOG.warn(\"tlds.txt missing from classpath; TLD exclusion will be disabled\");\n}","typeGuard":"null","tryCatchPattern":"// Static init failures are hard to catch; isolate the load behind a lazy holder\n// and catch at first use:\nSet<String> tlds;\ntry {\n    tlds = TldHolder.TLD_SET;\n} catch (ExceptionInInitializerError e) {\n    LOG.warn(\"TLD list unavailable, disabling rule\", e);\n    tlds = Collections.emptySet();\n}","preventionTips":["Use a complete, official jadx distribution that bundles resources.","When shading jadx, include resources under jadx/core/deobf/conditions/.","Verify with: jar tf jadx-core.jar | grep tlds.txt before deploying.","Make the loader null-tolerant so a missing resource degrades rather than crashes."],"tags":["resources","classpath","packaging","deobfuscation"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}