Repository navigation
Support JDK 27 (JDK-8372948, JDK-8268850) - #1786
slachiewicz wants to merge 3 commits into
Conversation
|
Thanks for your interest in palantir/palantir-java-format, @slachiewicz! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
Generate changelog in
|
This comment was marked as resolved.
This comment was marked as resolved.
|
Any idea if/when this change will be merged and released? Looking forward to updating our code base to Java 27 and this is the primary blocker. |
Bring over upstream palantir#1707 (Java 25 syntax) and palantir#1786 (JDK 27 end positions)
dd9e5dc to
12d6431
Compare
|
What's the current status of this PR? I see the CLA was signed by OP, and the changelog entry was updated, although no checks seem to have picked that up. |
12d6431 to
bcd6cba
Compare
|
@talios The change is ready and rebased on develop, and the CLA is signed. What's left needs a maintainer: start the CircleCI build, which doesn't run for this fork PR, and tick Fix + Generate changelog entry in the changelog-app comment above, which only repo admins can edit. @crogoz @pkoenig10, could one of you take a look? |
JDK 26 is out of support now that 27 is released. Spotless is skipped on the JDK 27 jobs only: palantir-java-format crashes there until palantir/palantir-java-format#1786 is released.
|
Pushed two more commits: |
The profile applies to local builds as well as CI, so the -Dspotless.skip arguments leave the workflow. Drop it once maven-parent ships a palantir-java-format that runs on JDK 27 (palantir/palantir-java-format#1786).
The profile applies to local builds as well as CI, so the -Dspotless.skip arguments leave the workflow. Drop it once maven-parent ships a palantir-java-format that runs on JDK 27 (palantir/palantir-java-format#1786).
JDK 26 is out of support now that 27 is released. Spotless is skipped on the JDK 27 jobs only: palantir-java-format crashes there until palantir/palantir-java-format#1786 is released.
The javadoc report forks a build that runs spotless:check, which crashes on JDK 27 like the main build (palantir/palantir-java-format#1786).
The profile applies to local builds as well as CI, so the -Dspotless.skip arguments leave the workflow. Drop it once maven-parent ships a palantir-java-format that runs on JDK 27 (palantir/palantir-java-format#1786).
JDK 26 is out of support now that 27 is released. Spotless is skipped on the JDK 27 jobs only: palantir-java-format crashes there until palantir/palantir-java-format#1786 is released.
The profile applies to local builds as well as CI, so the -Dspotless.skip arguments leave the workflow. Drop it once maven-parent ships a palantir-java-format that runs on JDK 27 (palantir/palantir-java-format#1786).
palantir-java-format crashes on JDK 27 (palantir/palantir-java-format#1786). Drop the profile once maven-parent ships a fixed release.
JDK 26 is out of support now that 27 is released. Spotless is skipped on the JDK 27 jobs only: palantir-java-format crashes there until palantir/palantir-java-format#1786 is released.
JDK 26 is out of support now that 27 is released. Spotless is skipped on the JDK 27 jobs only: palantir-java-format crashes there until palantir/palantir-java-format#1786 is released.
The profile applies to local builds as well as CI, so the -Dspotless.skip arguments leave the workflow. Drop it once maven-parent ships a palantir-java-format that runs on JDK 27 (palantir/palantir-java-format#1786).
|
Hopefully this and #1786 can get merged and released soon. |
|
hey @slachiewicz thanks for putting this PR up! I think circleci has not run because of the permission error see here: |
|
yes thanks. looks like my account on cirle is blocked. Feel free to cherry-pick or revirite my PR - that woudl be faster. |
|
Hi @slachiewicz, |
JDK-8372948 removed EndPosTable and JCCompilationUnit.endPositions and re-ordered the four-argument ParserFactory.newParser. Trees now resolves the end-position API once through a method handle and all three call sites go through it; Trees.newParser passes the parser flags in the order each JDK generation expects.
JDK 27 gives var declarations a VarTypeTree type instead of null, which the
visitors scanned to nothing ("expected token: 'var'"). Check for var before
the declared type, as google-java-format#1342 does; the binding-pattern check
compares the kind by name because Tree.Kind.VAR_TYPE is new in JDK 27.
Fixes palantir#1799
7f81fe6 to
b33ccd9
Compare
|
So close.. I thought the changelog was updated? Not sure why that check is failing now, or the policy-bot? |
Trees reaches EndPosTable, JCTree.getEndPosition(EndPosTable) and JCCompilationUnit.endPositions through method and var handles, which native-image cannot resolve without metadata; google-java-format needed the same three entries (google/google-java-format@ff157e3e46).
b33ccd9 to
30289db
Compare
|
@crogoz @pkoen CircleCI is green now. Two checks need a maintainer: |
Before this PR
JDK-8372948 (JDK 27) removed
EndPosTableandJCCompilationUnit.endPositions, soTrees.getEndPosition,StringWrapperandRemoveUnusedImportsfail withNoSuchFieldErroron JDK 27. The same change re-ordered the four-argumentParserFactory.newParser, soFormatterwas passingparseModuleInfo=trueon JDK 27 without noticing. Fixes #1785.JDK-8268850 (also JDK 27) gives
vardeclarations aVarTypeTreetype instead ofnull, so the visitors scanned it to nothing and everyvarfailed withexpected token: 'var'. Fixes #1799.After this PR
==COMMIT_MSG==
Support JDK 27 (JDK-8372948, JDK-8268850)
Treesnow looks up the end-position API once through a method handle:JCTree.getEndPosition()on JDKs withoutEndPosTable, andgetEndPosition(unit.endPositions)via aVarHandleon older ones. All three call sites go through it, andTrees.newParserpasses the parser flags in the order each JDK generation expects. Same approach as google/google-java-format#1328.vardeclarations, for-each variables, lambda parameters and record patterns check forvarbefore the declared type, as google/google-java-format#1342 does. The native image registersEndPosTable,JCTree.getEndPosition(EndPosTable)andJCCompilationUnit.endPositions, which the handles reach reflectively (google/google-java-format@ff157e3e46).==COMMIT_MSG==
Verified:
./gradlew :palantir-java-format:check→ 1405 tests pass; on JDK 27 the built CLI formats the repo's 383 test inputs identically to JDK 21, includingvarin locals, for-each loops, lambdas and record patterns. The native image was not built locally.Possible downsides?
The handle is resolved from class presence, not from the runtime version number, so an early-access build that has one half of JDK-8372948 but not the other would fail at class init instead of at the first formatted file. No such build exists in the released tags.
On JDK 27
JCTree.getEndPosition()returns the start position where the old API returned-1(NOPOS); none of the call sites relies on-1.This change was created with AI assistance.