{"record":{"id":"42f3b74408edc16b","repo":"apache/maven","slug":"invalid-jdk-version-in-profile","errorCode":null,"errorMessage":"Invalid JDK version in profile '{}': {}","messagePattern":"Invalid JDK version in profile '(.+?)': (.+?)","errorType":"exception","errorClass":"ProfileActivationException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java","lineNumber":45,"sourceCode":"/**\n * JdkPrefixProfileActivator\n */\n@Deprecated\npublic class JdkPrefixProfileActivator extends DetectedProfileActivator {\n    private static final String JDK_VERSION = System.getProperty(\"java.version\");\n\n    @Override\n    public boolean isActive(Profile profile) throws ProfileActivationException {\n        Activation activation = profile.getActivation();\n\n        String jdk = activation.getJdk();\n\n        // null case is covered by canDetermineActivation(), so we can do a straight startsWith() here.\n        if (jdk.startsWith(\"[\") || jdk.startsWith(\"(\")) {\n            try {\n                return matchJdkVersionRange(jdk);\n            } catch (InvalidVersionSpecificationException e) {\n                throw new ProfileActivationException(\n                        \"Invalid JDK version in profile '\" + profile.getId() + \"': \" + e.getMessage());\n            }\n        }\n\n        boolean reverse = false;\n\n        if (jdk.startsWith(\"!\")) {\n            reverse = true;\n            jdk = jdk.substring(1);\n        }\n\n        if (getJdkVersion().startsWith(jdk)) {\n            return !reverse;\n        } else {\n            return reverse;\n        }\n    }\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java#L27-L63","documentation":"Thrown while evaluating a profile's <jdk> activation when the value looks like a version range (starts with '[' or '(') but cannot be parsed. JdkPrefixProfileActivator converts '_' to '-' and passes the value to VersionRange.createFromVersionSpec; an InvalidVersionSpecificationException is rethrown as ProfileActivationException naming the offending profile id. Range syntax must be a Maven version range such as [1.8,11) or (,1.8].","triggerScenarios":"A POM profile with activation <jdk>[something-invalid</jdk>: unbalanced brackets, empty bounds like [,1.8], non-numeric bounds, or a malformed range such as [1.8,1.9]x. Activation is only attempted when canDetectActivation() sees a non-empty jdk element.","commonSituations":"Hand-edited POMs with typos in the jdk range; copying a single-version spec into range syntax (e.g. '[17.]' or '[17'); CI building the project for the first time so the previously inactive profile is evaluated; profiles inherited from parent BOMs with legacy 1.8_u40-style strings.","solutions":["Fix the range syntax in the profile: balanced brackets, valid bounds, e.g. <jdk>[1.8,)</jdk>","For a single-version prefix match, drop the brackets entirely: <jdk>17</jdk> matches any 17.x","Run 'mvn help:all-profiles' or validate phase to locate the exact profile id named in the message","Check profiles inherited from parents/BOMs, not just the current POM"],"exampleFix":"<!-- before -->\n<activation><jdk>[1.8,1.11)</jdk></activation>\n<!-- after -->\n<activation><jdk>[1.8,1.11)</jdk> is invalid: bounds must parse; use -->\n<activation><jdk>[1.8,11)</jdk></activation>","handlingStrategy":"validation","validationCode":"// Validate a jdk activation range before relying on the profile\nimport org.apache.maven.artifact.versioning.VersionRange;\ntry {\n    VersionRange.createFromVersionSpec(jdk.replace('_','-'));\n} catch (Exception invalid) {\n    throw new IllegalArgumentException(\"Bad <jdk> activation: \" + jdk, invalid);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate <jdk> values in a POM lint step (versions-maven-plugin / custom enforcer rule)","Prefer simple prefixes (<jdk>17</jdk>) over ranges unless a real range is needed","Run 'mvn validate' on new profiles in CI to catch activation errors before release"],"tags":["maven","profile","activation","version-range","pom"],"backgroundTag":"invalid-version-range","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}