Repository navigation
Build, test and run the 17 line on JDK 17 - #298
Merged
Merged
Conversation
…hmarks out The 17 line builds what a build on JDK 17 loads: the formatter, its SPI, jdk-bootstrap and the Gradle plugin. The other modules come with the 21 line. They stay in the tree, commented out in settings.gradle, so that a backport that touches them applies as it is; the Gradle plugin and jdk-bootstrap no longer ask for the native image they would test against.
Their releases are built for Java 21 and do not load on JDK 17, and the code they would check is checked on 21.X.X: it comes to the 17 line only as backports. forbidden-apis stays, it runs on JDK 17. config/checkstyle stays in the tree.
javac 17 has no record patterns and no type patterns in switch: BreakBehaviour.Json, the two switches over BreakBehaviour in Level and XmlUtils.printInline become instanceof chains that throw in the last branch, CDATASection still before Text, which it also is. ExecutorService is AutoCloseable since Java 19, so Main.formatFiles shuts the pool down in a finally, and CaseFile takes List.get for getFirst and getLast.
javac 17 cannot compile Java21InputAstVisitor, which is built on the syntax trees of JDK 21, so the 17 line deletes it, and Formatter.visitorFor takes JavaInputAstVisitor whatever the JDK. On JDK 21 and later 17.x formats the syntax of Java 17 through it, as FormatterCasesJava17Test checks on the 21 line; newer syntax needs 21.x. visitorFor keeps its signature, and the tests for JDK 21 and later stay: they do not run on JDK 17, and backports apply to them as they are.
The toolchain, the test JVM and the JDK that mise installs are 17, and Gradle looks for JDK17_HOME alone. The released gradle-open-java-format that formats this repository is built for Java 21 and does not load on Gradle with JDK 17, so the 17 line applies none until 17.1.0 is out; until then, changes made on the branch are formatted with the 21 line's -all.jar. Every other build plugin loads on JDK 17 as it is. One test fails here, a semicolon between imports, which javac 17 accepts and javac 21 rejects; the next commit rejects it as javac 21 does.
JLS 7.3 allows no semicolon after the package and import declarations. From Java 21 javac reports a run of them, at its first, when an import or a declaration that starts with an identifier, a record or a module, comes after it; javac 17 takes them all. The 17 line finds those runs among the JCSkips of javac 17's tree and reports them with javac 21's message, line and column, among javac's own errors in the order of the file, so that a file that 21.x rejects fails on 17.x the same way. Where javac reports them itself, from JDK 21 on, it adds none. ExtraneousSemicolonsTest takes every expectation from 21.1.2 on JDK 21, through formatSource and formatSourceAndFixImports, and straySemicolonBetweenImportsReportsTheParseError passes again.
javadoc reads a reference to an anchor of a type, {@link Set##anchor}, from JDK 20 on. javac 21 parses it as a
reference whose qualifier is Set, and RemoveUnusedImports keeps the import of Set; javac 17 keeps the whole tag
as an erroneous tree, so the 17 line took the import for unused and removed it. Found on Guava's
ImmutableCollection, the only file of 76,612 where 17.x on JDK 17 and 21.1.2 on JDK 21 differed.
The 17 line now reads the first name of such a reference from the erroneous tree, in {@link}, {@linkplain} and
@see alike, as visitReference does on JDK 21. The new case under test-cases-java17/imports is 21.1.2's output.
The 17 line builds and tests on JDK 17 alone, so CI has one job, build, on JDK 17, the check the ruleset of 17.X.X requires. The jobs for the newer JDKs, the native image and the WebAssembly module are gone, and so is mise run ci:native; ci:build no longer pins the path of a JDK 21 in act. CodeQL and the dependency submission set up JDK 17 too.
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this PR
17.X.Xis 21.X.X as it is (#293): it builds on JDK 21, with the IDE plugins, the native image and the WebAssembly module, and a Gradle daemon or a Maven build on JDK 17 cannot load what it makes (class file 65).After this PR
The 17 line builds, tests and runs on JDK 17 alone. It changes only what JDK 17 cannot build, so that backports from 21.X.X apply as they are.
settings.gradle, with the twoformatterNativeImageblocks that pointed at the native image.config/checkstylestays in the tree.mise.tomlandgradle.properties(JDK17_HOME). Every other build plugin loads on JDK 17 as it is. The releasedgradle-open-java-format:21.0.2that formats this repository does not, so the branch applies none until 17.1.0 is out; until then, changes made here are formatted with the 21 line's-all.jar.switch:BreakBehaviour.Json, two switches inLevelandXmlUtils.printInlinebecomeinstanceofchains.Mainshuts its pool down in afinally(ExecutorServiceisAutoCloseablesince 19), andCaseFileusesList.get.Java21InputAstVisitoris deleted, andFormatter.visitorFortakesJavaInputAstVisitoron every JDK. The tests for JDK 21 and later stay as they are and skip themselves on 17.ExtraneousSemicolonsfinds those runs in javac 17's tree and reports them as javac 21 does, among javac's own errors in the order of the file.ExtraneousSemicolonsTesttakes every expectation from 21.1.2 on JDK 21, andstraySemicolonBetweenImportsReportsTheParseErrorpasses again.{@link Set##anchor}, which javadoc reads from JDK 20 on, so the 17 line removed the import ofSetthat 21.1.2 keeps.RemoveUnusedImportsnow reads the type from the erroneous tree in{@link},{@linkplain}and@see, with a case undertest-cases-java17/imports.build, on JDK 17; CodeQL and the dependency submission on 17 too. Thejdk,nativeandwasmjobs are gone, and so ismise run ci:native.Checked on Temurin 17.0.17:
./gradlew checkpasses (core 1445 tests, Gradle plugin 182, jdk-bootstrap 6), and every class of the four jars is class file 61. The branch's-all.jaron JDK 17 and 21.1.2's on JDK 21 give the same output on 76,612 files, the JDK 17src.zip(java.base,jdk.compiler) and 400 sources jars from the Gradle cache:diff -rqis empty, and the same 18 files, templates that are no Java, fail on both.mise run ci:lintpasses.Possible downsides?
CaseTree.getLabels()andCaseLabelTreeare a reflective preview API; it is a warning only, three of them.mise run ci:buildno longer pins a JDK 21 path inside act; I have not run it locally.