Skip to content

Fix javadoc -Werror breakage on JDK 11#2844

Closed
donald-pinckney wants to merge 1 commit intomasterfrom
d/fix-werror-11
Closed

Fix javadoc -Werror breakage on JDK 11#2844
donald-pinckney wants to merge 1 commit intomasterfrom
d/fix-werror-11

Conversation

@donald-pinckney
Copy link
Copy Markdown
Contributor

Bug

Building javadoc (and therefore javadocJar, publishToSonatype, publishToMavenLocal) fails on JDK 11 with:

javadoc: error - invalid flag: -Werror

Reproducer from the root of the repo, running Gradle on JDK 11:

JAVA_HOME=/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home \
  ./gradlew publishToMavenLocal

Every module's javadoc task rejects -Werror, so nothing can publish. This blocks the JDK-11 publish-snapshot and prepare-release workflows.

Cause

gradle/java.gradle unconditionally passes -Werror to the javadoc tool. That flag was added to javadoc in JDK 15 (JDK-8232513); JDK 11's javadoc doesn't know it and errors.

The unconditional option was added in #2822 ("Claude fix all docstring problems & add check to CI"). That PR was developed against JDK 17+ (the javadoc CI job already runs on JDK 23), so the incompatibility with the publish job's JDK 11 was not caught.

Fix

Gate the addBooleanOption('Werror', true) call on JavaVersion.current().isCompatibleWith(VERSION_15). No change on JDK 15+ (the current javadoc CI job, and any future publish job running on a newer JDK); on JDK 11 the flag is simply omitted so the tool accepts the invocation.

Other -Werror uses in the file (compileJava/compileTestJava) are for javac, which has supported -Werror since Java 5 — no change needed there.

Verification

Re-ran the reproducer after the fix:

$ JAVA_HOME=/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home \
    ./gradlew publishToMavenLocal
...
BUILD SUCCESSFUL in 40s
168 actionable tasks: 83 executed, 85 up-to-date

🤖 Generated with Claude Code

The -Werror flag for the javadoc tool was added in JDK 15
(https://bugs.openjdk.org/browse/JDK-8232513). On older JDKs javadoc
rejects the flag outright, which breaks any task that invokes javadoc
(javadocJar, and therefore publishToSonatype / publishToMavenLocal)
when Gradle is running on JDK 11.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@donald-pinckney donald-pinckney requested a review from a team as a code owner April 16, 2026 19:55
@mjameswh
Copy link
Copy Markdown
Contributor

Superseded by #2845.

@mjameswh mjameswh closed this Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants