elastic/elasticsearch · error · IllegalArgumentException

unknown platform [${platform}] for jdk [${name}], must be on

Error message

unknown platform [${platform}] for jdk [${name}], must be one of ${ALLOWED_PLATFORMS}

What it means

Thrown by Jdk.setPlatform when the platform string is not in ALLOWED_PLATFORMS (darwin, linux, windows, mac). The platform selects the OS-specific artifact classifier, the archive extension (zip for windows, tar.gz otherwise), and the macOS '/Contents/Home' layout, so an unknown platform cannot be mapped to a downloadable bundle.

Source

Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java:97

    }

    public void setVersion(String version) {
        if (VERSION_PATTERN.matcher(version).matches() == false
            && LEGACY_VERSION_PATTERN.matcher(version).matches() == false
            && EA_VERSION_PATTERN.matcher(version).matches() == false) {
            throw new IllegalArgumentException("malformed version [" + version + "] for jdk [" + name + "]");
        }
        parseVersion(version);
        this.version.set(version);
    }

    public String getPlatform() {
        return platform.get();
    }

    public void setPlatform(String platform) {
        if (ALLOWED_PLATFORMS.contains(platform) == false) {
            throw new IllegalArgumentException(
                "unknown platform [" + platform + "] for jdk [" + name + "], must be one of " + ALLOWED_PLATFORMS
            );
        }
        this.platform.set(platform);
    }

    public String getArchitecture() {
        return architecture.get();
    }

    public void setArchitecture(final String architecture) {
        if (ALLOWED_ARCHITECTURES.contains(architecture) == false) {
            throw new IllegalArgumentException(
                "unknown architecture [" + architecture + "] for jdk [" + name + "], must be one of " + ALLOWED_ARCHITECTURES
            );
        }
        this.architecture.set(architecture);
    }

View on GitHub (pinned to db6a809a66)

Solutions

  1. Set platform to one of: 'darwin', 'mac' (both = macOS), 'linux', or 'windows'.
  2. For macOS use 'darwin' or 'mac'; do not use 'osx' or 'macos'.
  3. Verify case — values are lowercase and case-sensitive.

Example fix

// before
jdks { j { platform = 'osx'; } }
// after
jdks { j { platform = 'darwin'; } }
Defensive patterns

Strategy: validation

Validate before calling

import java.util.List;
final List<String> ALLOWED_PLATFORMS = List.of("darwin", "linux", "windows", "mac");
void setJdkPlatform(String platform) {
    if (!ALLOWED_PLATFORMS.contains(platform)) {
        throw new IllegalArgumentException(
            "platform must be one of " + ALLOWED_PLATFORMS + ", got: " + platform);
    }
    // ... proceed
}

Prevention

When it happens

Trigger: Jdk.setPlatform(platform) is called with a value other than 'darwin', 'linux', 'windows', or 'mac'. Note 'mac' and 'darwin' are both accepted macOS aliases.

Common situations: Using 'osx' (the common-but-unaccepted macOS identifier); 'macos' (unaccepted — JdkDownloadPlugin maps mac/darwin to 'macos' only in dependency notation, not as a platform value); 'win' or 'win32'; 'x86_64-linux' (that is an architecture+os combo); case mismatch.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/e2caa9fc57aa02a8. Report an issue: GitHub.