elastic/elasticsearch · error · IllegalStateException

Unable to parse bundled JDK version {}

Error message

Unable to parse bundled JDK version {}

What it means

IllegalStateException thrown when VersionProperties.getBundledJdkVersion() does not match VERSION_PATTERN: (\d+)(\.\d+\.\d+(?:\.\d+)?)?\+(\d+(?:\.\d+)?)(@([a-f0-9]{32}))?. The pattern expects a JDK semver-style string with a mandatory +build (and optional @hash) suffix used to build the Oracle download URL.

Source

Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/toolchain/OracleOpenJdkToolchainResolver.java:80

        "(\\d+)(\\.\\d+\\.\\d+(?:\\.\\d+)?)?\\+(\\d+(?:\\.\\d+)?)(@([a-f0-9]{32}))?"
    );

    private static final List<OperatingSystem> supportedOperatingSystems = List.of(
        OperatingSystem.MAC_OS,
        OperatingSystem.LINUX,
        OperatingSystem.WINDOWS
    );

    // package private so it can be replaced by tests
    List<JdkBuild> builds = List.of(
        getBundledJdkBuild(VersionProperties.getBundledJdkVersion(), VersionProperties.getBundledJdkMajorVersion())
    );

    static JdkBuild getBundledJdkBuild(String bundledJdkVersion, String bundledJkdMajorVersionString) {
        JavaLanguageVersion bundledJdkMajorVersion = JavaLanguageVersion.of(bundledJkdMajorVersionString);
        Matcher jdkVersionMatcher = VERSION_PATTERN.matcher(bundledJdkVersion);
        if (jdkVersionMatcher.matches() == false) {
            throw new IllegalStateException("Unable to parse bundled JDK version " + bundledJdkVersion);
        }
        String baseVersion = jdkVersionMatcher.group(1) + (jdkVersionMatcher.group(2) != null ? (jdkVersionMatcher.group(2)) : "");
        String build = jdkVersionMatcher.group(3);
        String hash = jdkVersionMatcher.group(5);
        return new ReleaseJdkBuild(bundledJdkMajorVersion, "download.oracle.com", baseVersion, build, hash);
    }

    /**
     * We need some place to map JavaLanguageVersion to buildNumber, minor version etc.
     * */
    @Override
    public Optional<JavaToolchainDownload> resolve(JavaToolchainRequest request) {
        JdkBuild build = findSupportedBuild(request);
        if (build == null) {
            return Optional.empty();
        }

        OperatingSystem operatingSystem = request.getBuildPlatform().getOperatingSystem();

View on GitHub (pinned to db6a809a66)

Solutions

  1. Check the value of VersionProperties.getBundledJdkVersion() and compare against VERSION_PATTERN.
  2. Reformat the bundled JDK version to match '<major>[.<minor>.<patch>[.<update>]]+<build>[@<hash>]' (e.g. '25.0.1+12@abcdef0123456789abcdef0123456789').
  3. Update the property source (version.properties / gradle -P flag) consistently across the build.

Example fix

// before: bundledJdkVersion = "25"
// after:  bundledJdkVersion = "25.0.1+12"
Defensive patterns

Strategy: validation

Validate before calling

private static final Pattern VERSION_PATTERN =
    Pattern.compile("(\\d+)(\\.\\d+\\.\\d+(?:\\.\\d+)?)?\\+(\\d+(?:\\.\\d+)?)(@([a-f0-9]{32}))?");

static boolean isValidBundledJdkVersion(String v) {
    return v != null && VERSION_PATTERN.matcher(v).matches();
}

// usage before assigning VersionProperties
if (!isValidBundledJdkVersion(candidate)) {
    throw new IllegalArgumentException("Bundled JDK version must match " + VERSION_PATTERN + ": " + candidate);
}

Prevention

When it happens

Trigger: build-tools-internal's VersionProperties (typically fed from buildSrcVersion.properties or a gradle property) contains a bundled JDK version string lacking the +buildNumber suffix, using a different separator, or missing components.

Common situations: Bumping the bundled JDK and forgetting the build metadata suffix (e.g. setting '25' instead of '25.0.1+12'); a version-rectification script producing a stripped string; merging version properties with conflicting formats.

Understand the failure class

Related errors


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