{"record":{"id":"f9a38de515b76871","repo":"HMCL-dev/HMCL","slug":"candidates-candidates","errorCode":null,"errorMessage":"Candidates: ${candidates}","messagePattern":"Candidates: (.+?)","errorType":"exception","errorClass":"UnsupportedPlatformException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/mojang/MojangJavaDownloadTask.java","lineNumber":76,"sourceCode":"    public MojangJavaDownloadTask(DownloadProvider downloadProvider, Path target, Path tempDir, GameJavaVersion javaVersion, String platform) {\n        this.target = target;\n        this.tempDir = tempDir;\n        this.downloadProvider = downloadProvider;\n        this.javaDownloadsTask = new GetTask(downloadProvider.injectURLWithCandidates(JAVA_LIST_URL))\n                .thenComposeAsync(javaDownloadsJson -> {\n                    MojangJavaDownloads allDownloads = JsonUtils.fromNonNullJson(javaDownloadsJson, MojangJavaDownloads.class);\n\n                    Map<String, List<MojangJavaDownloads.JavaDownload>> osDownloads = allDownloads.downloads().get(platform);\n                    if (osDownloads == null || !osDownloads.containsKey(javaVersion.component()))\n                        throw new UnsupportedPlatformException(\"Unsupported platform: \" + platform);\n                    List<MojangJavaDownloads.JavaDownload> candidates = osDownloads.get(javaVersion.component());\n                    for (MojangJavaDownloads.JavaDownload download : candidates) {\n                        if (JavaInfo.parseVersion(download.version().name()) >= javaVersion.majorVersion()) {\n                            this.download = download;\n                            return new GetTask(downloadProvider.injectURLWithCandidates(download.manifest().getUrl()));\n                        }\n                    }\n                    throw new UnsupportedPlatformException(\"Candidates: \" + JsonUtils.GSON.toJson(candidates));\n                })\n                .thenApplyAsync(javaDownloadJson -> JsonUtils.fromNonNullJson(javaDownloadJson, MojangJavaRemoteFiles.class));\n    }\n\n    @Override\n    public Collection<Task<?>> getDependents() {\n        return Collections.singleton(javaDownloadsTask);\n    }\n\n    @Override\n    public void execute() throws Exception {\n        for (Map.Entry<String, MojangJavaRemoteFiles.Remote> entry : javaDownloadsTask.getResult().files().entrySet()) {\n            Path dest = tempDir.resolve(entry.getKey());\n            if (entry.getValue() instanceof MojangJavaRemoteFiles.RemoteFile file) {\n                // Use local file if it already exists\n                try {\n                    BasicFileAttributes localFileAttributes = Files.readAttributes(dest, BasicFileAttributes.class);\n                    if (localFileAttributes.isRegularFile() && file.getDownloads().containsKey(\"raw\")) {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/mojang/MojangJavaDownloadTask.java#L58-L94","documentation":"After locating the per-OS list of Java runtime candidates, MojangJavaDownloadTask scans them for one whose version satisfies the requested major version. If every candidate's parsed version is lower than javaVersion.majorVersion(), it throws UnsupportedPlatformException listing all candidates as JSON, meaning Mojang's index has no runtime new enough for this platform.","triggerScenarios":"Requesting a Java major version (e.g. Java 21) whose component exists for the platform in Mojang's index but whose published runtime versions are all below the requested majorVersion, so the loop over `candidates` completes without a match.","commonSituations":"Launching a game requiring Java 21 while Mojang's index for your OS only lists older runtimes (index lag after a new MC release); asking for an exact newer major than Mojang distributes; a stale/cached copy of the runtime index.","solutions":["Switch to a non-Mojang Java download provider (e.g. Adoptium) which distributes current JDKs.","Let the game use the highest runtime available by lowering the requested Java major version requirement.","Refresh the runtime list/clear cache so the latest Mojang index (with newer candidates) is fetched.","Install the required Java manually and point HMCL at it instead of auto-downloading."],"exampleFix":"// before\nJavaVersion JAVA_21 = JavaVersion.major(21) with mojang provider;\n// after (fallback)\nDownloadProvider p = new AdoptiumDownloadProvider(); // or install Java 21 manually and add it in Java settings","handlingStrategy":"fallback","validationCode":"// Check any candidate meets the major version before downloading\nboolean any = osDownloads.get(component).stream()\n    .anyMatch(c -> JavaInfo.parseVersion(c.version().name()) >= javaVersion.majorVersion());","typeGuard":"if (candidates == null || candidates.isEmpty()) return fallbackProvider();","tryCatchPattern":"try { return mojangTask.run().get(); }\ncatch (UnsupportedPlatformException e) { LOG.warning(\"No Mojang runtime: \" + e.getMessage()); return adoptiumTask.run().get(); }","preventionTips":["Prefer the newest runtime index (refresh before checking availability).","Choose Java majors Mojang actually distributes for your OS.","Always configure a secondary Java provider for majors Mojang lags on."],"tags":["java-runtime","download","version-mismatch","platform"],"backgroundTag":"empty-result-set","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}