{"record":{"id":"41b75c8787a31289","repo":"elastic/elasticsearch","slug":"malformed-version-version-for-jdk-name","errorCode":null,"errorMessage":"malformed version [${version}] for jdk [${name}]","messagePattern":"malformed version \\[(.+?)\\] for jdk \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java","lineNumber":85,"sourceCode":"        return vendor.get();\n    }\n\n    public void setVendor(final String vendor) {\n        if (ALLOWED_VENDORS.contains(vendor) == false) {\n            throw new IllegalArgumentException(\"unknown vendor [\" + vendor + \"] for jdk [\" + name + \"], must be one of \" + ALLOWED_VENDORS);\n        }\n        this.vendor.set(vendor);\n    }\n\n    public String getVersion() {\n        return version.get();\n    }\n\n    public void setVersion(String version) {\n        if (VERSION_PATTERN.matcher(version).matches() == false\n            && LEGACY_VERSION_PATTERN.matcher(version).matches() == false\n            && EA_VERSION_PATTERN.matcher(version).matches() == false) {\n            throw new IllegalArgumentException(\"malformed version [\" + version + \"] for jdk [\" + name + \"]\");\n        }\n        parseVersion(version);\n        this.version.set(version);\n    }\n\n    public String getPlatform() {\n        return platform.get();\n    }\n\n    public void setPlatform(String platform) {\n        if (ALLOWED_PLATFORMS.contains(platform) == false) {\n            throw new IllegalArgumentException(\n                \"unknown platform [\" + platform + \"] for jdk [\" + name + \"], must be one of \" + ALLOWED_PLATFORMS\n            );\n        }\n        this.platform.set(platform);\n    }\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java#L67-L103","documentation":"Thrown by Jdk.setVersion when the version string matches none of the three accepted patterns: VERSION_PATTERN (e.g. '17.0.1+12' or '21+34@abcdef...'), LEGACY_VERSION_PATTERN (pre-Java-9, e.g. '8u302+b08'), or EA_VERSION_PATTERN (early-access, e.g. '22-ea+15'). The version must be parseable so that major/base/build/hash components can be derived for constructing the download artifact path.","triggerScenarios":"Jdk.setVersion(version) is called with a string that fails all three regex matches. The patterns require a build number component (the '+N' suffix) and an optional '@<32-hex-hash>' suffix; bare version numbers like '17' or Maven-style '17.0.1' without a build are rejected.","commonSituations":"Omitting the mandatory build number (e.g. '17.0.1' instead of '17.0.1+12'); using a Maven/Gradle dependency version like '17.0.1-12'; supplying only a major ('21'); including a patch segment the parser doesn't model; copy-pasting a version from a vendor page that uses a different separator.","solutions":["Use the JEP-322 format with a build suffix: '<feature>[.<interim>.<update>[.<patch>]]+<build>[@<32-hex-sha>]', e.g. '21.0.3+9'.","For JDK 8 use the legacy form '<major>u<update>+b<build>[@hash]', e.g. '8u402+b06'.","For early-access builds use '<major>-ea+<build>' or '<major>-rc+<build>'.","Copy the exact version string (including build and, when present, the @hash) from the build's VersionProperties or the JDK download page."],"exampleFix":"// before\njdks { build_jdk { version = '17.0.1'; } }  // missing build number\n// after\njdks { build_jdk { version = '17.0.1+12'; } }","handlingStrategy":"validation","validationCode":"import java.util.regex.Pattern;\nprivate static final Pattern VERSION = Pattern.compile(\n    \"(\\\\d+)(\\\\.\\\\d+\\\\.\\\\d+(\\\\.\\\\d+)?)?\\\\+(\\\\d+(\\\\.\\\\d+)?)(@([a-f0-9]{32}))?\");\nprivate static final Pattern LEGACY = Pattern.compile(\"(\\\\d)(u\\\\d+)\\\\+(b\\\\d+?)(@([a-f0-9]{32}))?\");\nprivate static final Pattern EA = Pattern.compile(\"(\\\\d+)-(?:ea|rc)\\\\+(\\\\d+)(@([a-f0-9]{32}))?\");\nboolean isValidJdkVersion(String v) {\n    return VERSION.matcher(v).matches() || LEGACY.matcher(v).matches() || EA.matcher(v).matches();\n}\n// assert isValidJdkVersion(\"21.0.3+9\");\n// assert isValidJdkVersion(\"8u402+b06\");\n// assert isValidJdkVersion(\"23-ea+15\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the build-number suffix ('+N'); bare feature versions are invalid.","For JDK 8 use the legacy 'NuNNN+bNN' shape; for EA builds use 'NN-ea+NN' or 'NN-rc+NN'.","Copy the exact version string (with build, and @hash when present) from VersionProperties or the JDK download page."],"tags":["gradle","jdk","build-config","validation","versioning"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}