HMCL-dev/HMCL · error · IOException

Unsupported checksum type:

Error message

Unsupported checksum type: 

What it means

In the same Disco download flow, after resolving a package the code validates its reported checksum type. Only sha1, sha256, and md5 are supported; a blank checksum type is tolerated. If Disco reports any other checksum algorithm, the dialog throws IOException("Unsupported checksum type: ...") because the downloaded archive could not be verified.

Solutions

  1. Update HMCL to the latest version, which may support the new checksum type
  2. Check the message for the reported type and verify upstream changed its checksum field
  3. Download the JDK manually and register it through Java management instead of the in-app downloader
  4. If developing, add the missing algorithm to the allow-list and compute it with MessageDigest

Example fix

// before
&& !fileInfo.checksumType().equals("sha1") && !fileInfo.checksumType().equals("sha256") && !fileInfo.checksumType().equals("md5")
    throw new IOException("Unsupported checksum type: " + fileInfo.checksumType());
// after
&& !SUPPORTED_CHECKSUMS.contains(fileInfo.checksumType().toLowerCase(Locale.ROOT)) // SUPPORTED_CHECKSUMS = Set.of("sha1","sha256","md5","sha512")
Defensive patterns

Strategy: validation

Validate before calling

Set<String> supported = Set.of("sha1", "sha256", "md5");
String type = fileInfo.checksumType();
if (StringUtils.isNotBlank(type) && !supported.contains(type.toLowerCase(Locale.ROOT))) {
    // skip in-app download; use manual install path
}

Try / catch

try {
    downloadJava(version);
} catch (IOException e) {
    if (e.getMessage().startsWith("Unsupported checksum type:")) {
        offerManualDownloadDialog();
    } else throw e;
}

Prevention

When it happens

Trigger: Downloading a Java runtime whose DiscoRemoteFileInfo.checksumType() is a non-blank value other than "sha1", "sha256", or "md5" (e.g. a newer algorithm such as sha512).

Common situations: Upstream foojay API starts advertising a new checksum algorithm; a distribution entry uses an exotic hashing scheme; older HMCL releases lacking support for newer checksum types.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10). Data as JSON: /api/errors/a11ff6ea93c93bf0. Report an issue: GitHub.

Appendix: source

Thrown at HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java:385

            DiscoJavaDistribution distribution = distributionBox.getSelectionModel().getSelectedItem();
            DiscoJavaRemoteVersion version = remoteVersionBox.getSelectionModel().getSelectedItem();
            JavaPackageType packageType = packageTypeBox.getSelectionModel().getSelectedItem();

            if (version == null)
                return;

            Controllers.taskDialog(new GetTask(downloadProvider.injectURLWithCandidates(version.getLinks().pkgInfoUri()))
                    .setExecutor(Schedulers.io())
                    .thenComposeAsync(json -> {
                        DiscoResult<DiscoRemoteFileInfo> result = JsonUtils.fromNonNullJson(json, DiscoResult.typeOf(DiscoRemoteFileInfo.class));
                        if (result.getResult().size() != 1)
                            throw new IOException("Illegal result: " + json);

                        DiscoRemoteFileInfo fileInfo = result.getResult().get(0);
                        if (StringUtils.isNotBlank(fileInfo.checksumType())
                                && !fileInfo.checksumType().equals("sha1") && !fileInfo.checksumType().equals("sha256") && !fileInfo.checksumType().equals("md5"))
                            throw new IOException("Unsupported checksum type: " + fileInfo.checksumType());
                        if (StringUtils.isBlank(fileInfo.directDownloadUri()))
                            throw new IOException("Missing download URI: " + json);

                        Path targetFile = Files.createTempFile("hmcl-java-", "." + version.getArchiveType());
                        targetFile.toFile().deleteOnExit();

                        Task<FileDownloadTask.IntegrityCheck> getIntegrityCheck;
                        if (StringUtils.isNotBlank(fileInfo.checksum()))
                            getIntegrityCheck = Task.completed(new FileDownloadTask.IntegrityCheck(fileInfo.checksumType(), fileInfo.checksum()));
                        else if (StringUtils.isNotBlank(fileInfo.checksumUri()))
                            getIntegrityCheck = new GetTask(downloadProvider.injectURLWithCandidates(fileInfo.checksumUri()))
                                    .thenApplyAsync(checksum -> {
                                        checksum = checksum.trim();

                                        int idx = checksum.indexOf(' ');
                                        if (idx > 0)
                                            checksum = checksum.substring(0, idx);

View on GitHub (pinned to 24702dc5a0)