{"record":{"id":"ed48acce0edb5363","repo":"elastic/elasticsearch","slug":"malformed-jdk-version-version","errorCode":null,"errorMessage":"Malformed jdk version [${version}]","messagePattern":"Malformed jdk version \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java","lineNumber":228,"sourceCode":"    }\n\n    @Override\n    public Iterator<File> iterator() {\n        return configuration.iterator();\n    }\n\n    private void parseVersion(String version) {\n        // decompose the bundled jdk version, broken into elements as: [feature, interim, update, build]\n        // Note the \"patch\" version is not yet handled here, as it has not yet been used by java.\n        Matcher jdkVersionMatcher = VERSION_PATTERN.matcher(version);\n        if (jdkVersionMatcher.matches() == false) {\n            // Try again with the pre-Java9 version format\n            jdkVersionMatcher = LEGACY_VERSION_PATTERN.matcher(version);\n            if (jdkVersionMatcher.matches() == false) {\n                // Try again with the pre-Java9 version format\n                jdkVersionMatcher = EA_VERSION_PATTERN.matcher(version);\n                if (jdkVersionMatcher.matches() == false) {\n                    throw new IllegalArgumentException(\"Malformed jdk version [\" + version + \"]\");\n                }\n                baseVersion = version;\n                major = jdkVersionMatcher.group(1);\n                build = jdkVersionMatcher.group(2);\n                hash = null;\n                return;\n            }\n        }\n\n        baseVersion = jdkVersionMatcher.group(1) + (jdkVersionMatcher.group(2) != null ? (jdkVersionMatcher.group(2)) : \"\");\n        major = jdkVersionMatcher.group(1);\n        build = jdkVersionMatcher.group(3);\n        hash = jdkVersionMatcher.group(5);\n    }\n\n}\n","sourceCodeStart":210,"sourceCodeEnd":245,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java#L210-L245","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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]'."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// This throw is defensively duplicated by setVersion's own regex gate.\n// As a caller you cannot reach it through the public API; just validate\n// the version with the same three patterns used in error 162 before calling\n// setVersion. See validationCode for errorIndex 162.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["gradle","jdk","validation","versioning","unreachable","defensive"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}