Support JDK27: end positions moved from EndPosTable to JCTree.endpos

JDK27 removed com.sun.tools.javac.tree.EndPosTable and stores end
positions directly on tree nodes (JDK-8372948). Lombok resolved that
class in a static initializer and rethrew on failure, so the processor
never initialized and every compilation on JDK27 failed.

- Javac: probe for EndPosTable; when absent, use the no-arg
  DiagnosticPosition.getEndPosition() and write JCTree.endpos directly
- CommentCatcher: skip setting genEndPos where the field no longer exists
- new java27 parser factory: JDK27 dropped the keepEndPositions
  parameter from JavacParser and ParserFactory.newParser
- DocCommentIntegrator: implement the new no-arg getEndPosition()
- PrettyPrinter: drop an unused reflective getEndPosition lookup that
  would fail class init on JDK27
- add an opt-in test.javac27 target

Fixes #4072
This commit is contained in:
Danish Nawab committed 2026-08-24 11:06:20 +02:00
1 parent af01b7a27b
commit 10ab92b5d9
8 files changed
+188 -35

No files matched your search

+5
View File
@@ -167,6 +167,11 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
<test.javacX version="26" />
</target>
<!-- 27 is non-LTS, not yet released -->
<target name="test.javac27" depends="test.compile, test.formatter.compile" description="runs the tests on your default VM, using javac27 as underlying compiler">
<test.javacX version="27" />
</target>
<target name="test.javacCurrent" depends="test.compile, test.formatter.compile" description="runs the tests on your default VM, using its javac as underlying compiler">
<echo>Running TestJavac on JVM${ant.java.version}, with the javac built into your VM distributon.</echo>
<junit haltonfailure="yes" fork="true" forkmode="once">