elastic/elasticsearch · error · IllegalArgumentException
Malformed jdk version [${version}]
Error message
Malformed jdk version [${version}] What it means
Thrown by Jdk.parseVersion when the version string matches none of VERSION_PATTERN, LEGACY_VERSION_PATTERN, or EA_VERSION_PATTERN. In normal flow setVersion validates the same three patterns before calling parseVersion, so this branch is a defensive duplicate that is effectively unreachable from setVersion — it exists to fail loudly if parseVersion is ever called by another internal path with an unvalidated string. The message is shorter than error 162's and omits the jdk name.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java:228
}
@Override
public Iterator<File> iterator() {
return configuration.iterator();
}
private void parseVersion(String version) {
// decompose the bundled jdk version, broken into elements as: [feature, interim, update, build]
// Note the "patch" version is not yet handled here, as it has not yet been used by java.
Matcher jdkVersionMatcher = VERSION_PATTERN.matcher(version);
if (jdkVersionMatcher.matches() == false) {
// Try again with the pre-Java9 version format
jdkVersionMatcher = LEGACY_VERSION_PATTERN.matcher(version);
if (jdkVersionMatcher.matches() == false) {
// Try again with the pre-Java9 version format
jdkVersionMatcher = EA_VERSION_PATTERN.matcher(version);
if (jdkVersionMatcher.matches() == false) {
throw new IllegalArgumentException("Malformed jdk version [" + version + "]");
}
baseVersion = version;
major = jdkVersionMatcher.group(1);
build = jdkVersionMatcher.group(2);
hash = null;
return;
}
}
baseVersion = jdkVersionMatcher.group(1) + (jdkVersionMatcher.group(2) != null ? (jdkVersionMatcher.group(2)) : "");
major = jdkVersionMatcher.group(1);
build = jdkVersionMatcher.group(3);
hash = jdkVersionMatcher.group(5);
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Treat this as a build-tooling bug: if reached, file an issue — setVersion and parseVersion should agree.
- If you are editing Jdk.java, ensure the same three patterns are checked in both setVersion and parseVersion so they cannot diverge.
- As a workaround, supply the version in the canonical form 'feature[.interim.update[.patch]]+build[@hash]'.
Defensive patterns
Strategy: validation
Validate before calling
// This throw is defensively duplicated by setVersion's own regex gate. // As a caller you cannot reach it through the public API; just validate // the version with the same three patterns used in error 162 before calling // setVersion. See validationCode for errorIndex 162.
Prevention
- If you are editing Jdk.java, keep the pattern checks in setVersion and parseVersion in sync so this branch stays unreachable.
- Never call parseVersion directly with unvalidated input.
- Add a unit test asserting setVersion and parseVersion agree for all three pattern forms.
When it happens
Trigger: parseVersion is invoked (directly or via a future internal caller) with a string failing all three compiled patterns. Because setVersion gates on the same regexes immediately before delegating, reaching this throw from the public API requires the validation and the parse to disagree (e.g. a future pattern change applied to one site but not the other).
Common situations: Refactoring that updates VERSION_PATTERN in setVersion but not in parseVersion (or vice-versa); a new internal call site that bypasses setVersion; an edge-case string that matches under one Matcher instance configuration but not another.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- malformed version [${version}] for jdk [${name}]
- Unknown JDK vendor [${vendor}]
- unknown vendor [${vendor}] for jdk [${name}], must be one of
- unknown platform [${platform}] for jdk [${name}], must be on
- unknown architecture [${architecture}] for jdk [${name}], mu
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/ed48acce0edb5363.
Report an issue: GitHub.