Java 25: strip javac's EOI sentinel from /// markdown doc comment text - #8565
Merged
Merged
Conversation
`DCTree.DCRawText#getContent()` can return the content of a `///` markdown
doc comment with javac's `LayoutCharacters.EOI` (0x1A) sentinel appended --
its escape lookahead runs past the end of the comment buffer. It shows up
when the content ends in a backslash, e.g. a banner comment:
////Section\\\\
which round-trips with a trailing 0x1A and fails the print idempotency
check. Reproduces on JDK 25 and 26, so this needs handling on our side.
Strip a trailing sentinel in `visitText`, which every raw content string
passes through. Leaving it in place corrupts the text and also
desynchronizes the cursor, since the sentinel is not present in `source`.
Only the Java 25 parser is affected; `///` doc comments are JDK 23+.
Member
Author
|
Split out of #8564 — unrelated root cause, so it can land independently. |
timtebeek
commented
Aug 19, 2026
Comment on lines
+1069
to
+1071
| // `DCRawText#getContent()` can return the content of a markdown (`///`) doc comment with javac's | ||
| // end-of-input sentinel appended, e.g. when the content ends in a backslash. The sentinel is not | ||
| // present in `source`, so leaving it in place both corrupts the text and desynchronizes the cursor. |
Member
Author
There was a problem hiding this comment.
Couldn't really find a good way to shorten this oddity to two lines or less
Member
Author
There was a problem hiding this comment.
Shortened to two lines in 670e4ef — kept that it's javac's doing, which API, the trailing-backslash trigger, and the cursor consequence:
// javac can append its end-of-input sentinel to `DCRawText#getContent()` for `///` doc comments,
// e.g. when the content ends in a backslash. It is absent from `source`, so it also skews the cursor.Rebased onto your eb860a2 rather than force-pushing over it.
greg-at-moderne
approved these changes
Aug 20, 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.
A
///markdown doc comment whose content ends in a backslash round-trips with a stray0x1Aappended, so the file fails the print idempotency check:ParseFailuresrows from a large ingest. Split out of Java: fix two comment-scanning defects that drop modifiers from the LST #8564, which fixes two unrelated comment-scanning defects in the same area.Root cause
This one is upstream in javac, not in our code — we copy the string it hands us.
com.sun.tools.javac.tree.DCTree.DCRawText#getContent()can return the content of a JEP 467 markdown doc comment with javac'sLayoutCharacters.EOI(0x1A) sentinel appended; its escape lookahead runs past the end of the comment buffer. Visible with a plainDocTreesprobe, no OpenRewrite involved:Confirmed on both JDK 25.0.3 and JDK 26.0.1, so it isn't something we can wait out upstream. I'll report it to OpenJDK separately.
Reproducer
prints back as
///x\<0x1A>.The practical trigger is a doc comment ending in backslashes. Banner comments hit this, because four-or-more leading slashes still start with
///and javac therefore classifies them as markdown doc comments rather than ordinary line comments:The exact javac predicate is erratic — trailing runs of 1, 2, 4, 5, 7 and 8 backslashes leak but 3 and 6 do not;
///a\bleaks while///a\bcand///a\*bdo not — so this strips defensively rather than trying to model the condition.Fix
Strip a trailing sentinel in
visitText(String), the single point every raw content string passes through. Leaving it in place corrupts the text and also desynchronizes the cursor, since the sentinel isn't present insource.Scope
///comments throughReloadableJava25JavadocVisitor. Last good release is 8.75.11 — before that these lines stayed plainTextComments and round-tripped fine.Java 25 parser only, since
///doc comments are JDK 23+.Testing
Three new tests in
JavadocTest.MarkdownDocComment; all three fail onmainand pass with the fix.rewrite-java-25:compatibilityTestgreen.