Skip to content

A 17.X.X release line: the formatter on Java 17, backported from 21.X.X #293

Backlog

Description

@abashev

Why

The first version number is the Java version the formatter is built for, so 21.x does not load on JDK 17 to 20, and those JDKs are where much of the Maven world builds:

That match does not last: 21.1.0 already changed the output, and every later minor version will too. A 17 line with the same output gives such builds one formatter on every leg: 17.x on JDK 17 to 20, 21.x on 21 and later.

Proposal

A branch 17.X.X, cut from the 21.1.2 tag, where the formatter is built and tested on Java 17 only and released by tag, as 21.X.X is.

Versions. 17.<minor>.<build>, by the rules in Versions. The minor number follows the 21 line's: 17.1.x formats every file that javac 17 parses exactly as 21.1.x does, so the first release is 17.1.0. The build number counts the 17 line's own releases.

What the branch builds.

  • Only the jars a build on the JVM loads: open-java-format and open-java-format-spi. The Gradle plugin, open-java-format-jdk-bootstrap, the IntelliJ IDEA and Eclipse plugins, the native image, the WebAssembly module and the benchmarks stay on 21.X.X: the IDE plugins run in the IDE's JVM, and the native binary and the module do not depend on the user's JDK, so the 21 line's serve every user.
  • Temurin 17 everywhere: mise.toml, JavaLanguageVersion.of(17) in open-java-format.java-conventions.gradle, and a JDK17_HOME in gradle.properties in place of JDK21_HOME and GRAALVM_HOME. Gradle 9 itself runs on 17.
  • Compiling for 17 lists the code to rewrite: the record patterns in switch over BreakBehaviour in BreakBehaviour.java and doc/Level.java, and whatever else the compiler finds. Java21InputAstVisitor goes, since it is built on javac 21's trees (PatternCaseLabelTree, DeconstructionPatternTree, ConstantCaseLabelTree, AnyPatternTree), and with it the tests behind @EnabledForJreRange(min = JAVA_21) and later.
  • Formatter already picks Java14InputAstVisitor below JDK 21 (Formatter.java#L143-L149). On JDK 21 and later the 21 line formats switch and case through Java21InputAstVisitor, so the 17 line formats them through other code. The corpus check under "Done when" is what shows that the output is the same.

CI. ci.yml already runs on every *.X.X push. On 17.X.X:

  • build on JDK 17, the one required check;
  • no jdk matrix (25, 26, 27, 28-ea), no native and no wasm: the line runs on JDK 17 to 20 and builds no image;
  • the ruleset "Default branch" covers 21.X.X only, so 17.X.X gets the same rules: pull requests, signed commits, build, no force push, no deletion;
  • Dependabot and update-pr-branch.yml stay on 21.X.X. A dependency update the 17 line needs comes over as a backport.

Release by tag. release.yml runs on every tag, from the tagged commit, so a 17.* tag runs the branch's own copy. It keeps the release notes check, signing, the jars deployment and the publish job, and the draft GitHub release with the notes and the runnable -all.jar. It drops the native images and their deployment, the .deb packages, the WebAssembly module, the Gradle Plugin Portal and the JetBrains Marketplace. In open-java-format.release-conventions.gradle, branch = '21.X.X' becomes 17.X.X.

The GitHub release is not marked Latest (JReleaser's makeLatest), so releases/latest keeps pointing at the 21 line. The Homebrew tap, the Scoop bucket and the apt repository already move only to a higher version (follow-releases.yml), so a 17.x release leaves them alone.

Backports. A change on 21.X.X that changes the output, or fixes a crash or a security issue, gets a backport pull request to 17.X.X (git cherry-pick -x), labelled backport 17.X.X. A 17 minor version is released once every output change of the 21 minor version it follows is in. New syntax that javac 17 cannot parse, the IDE and Gradle plugins, the native image and the packages stay on 21.X.X.

Docs. On the branch, the README and CLAUDE.md say what the line is for and that it builds on Temurin 17. On 21.X.X, Versions names the 17 line. On openjavaformat.dev, the Spotless page shows a JDK 17 profile with 17.x in place of the palantir-java-format fallback, and how to keep Dependabot from offering 21.x to it.

To decide

  • The Gradle plugin. Gradle 9 runs on Java 17, and a Gradle daemon on 17 cannot load the 21 line's plugin. Left out until someone asks?
  • How long the line lives. For example until apache/maven-parent moves its JDK floor to 21, with the last release announced in the README.
  • fmt-maven-plugin. It is built for Java 21 too (java.version 21 in its POM). A 17 line there belongs in that repository; Spotless with groupArtifact works with the 17 line as it is.

Alternatives looked at

  • Keep falling back to palantir-java-format on JDK 17 to 20. What the Plexus and MojoHaus parents do today. The two legs agree only until the next minor version of the 21 line.
  • Check the format only on JDK 21 and later. No work, but apache/maven-parent has a JDK 17 leg only, so it would check nothing.
  • Run the 21 line from a JDK 17 build in another process. Spotless runs its palantirJavaFormat step inside the build's JVM. Its nativeCmd step can call the native binary, but then every machine that builds needs the binary installed.

Done when

  • 17.X.X exists with the rules of 21.X.X, and its build runs on JDK 17 only;
  • a 17.1.0 tag publishes dev.openjavaformat:open-java-format and open-java-format-spi 17.1.0 to Maven Central and a draft GitHub release with the runnable jar, nothing else, and Latest stays on the 21 line;
  • 17.1.0 on JDK 17 and 21.1.2 on JDK 21 give the same output on the JDK 17 src.zip and the Gradle sources jars;
  • Spotless 3.12.0 with groupArtifact dev.openjavaformat:open-java-format and version 17.1.0 passes spotless:check on JDK 17 on a project that 21.1.2 formatted;
  • the README and the Spotless page on openjavaformat.dev describe the line.

Activity

  1. added
    enhancement
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions