Skip to content

Strip trailing asterisks before */ in Javadoc comments - #115

Merged
abashev merged 1 commit into
mainfrom
gjf-1474-trailing-asterisks
Oct 9, 2026
Merged

abashev merged 1 commit into
mainfrom
gjf-1474-trailing-asterisks

Conversation

@abashev

@abashev abashev commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Port of google/google-java-format#1474 (Liam Miller-Cushon, merged upstream 2026-10-06; author kept on the commit).

With Javadoc formatting on, a decorative closing delimiter such as /** ... **/ kept the extra asterisk as comment text and came out as /** ... * */. stripJavadocBeginAndEnd now drops any run of * directly before the closing */.

In this fork the method lives in JavadocLexer, not JavadocFormatter, otherwise the change is upstream's four lines.

Done test-first: trailingAsterisksBeforeClose (upstream's case) and trailingAsterisksOnTheirOwnLine ( ***/ on its own line) both failed with * */ before the fix. Full module suite: 1611 tests, 0 failures.

Only reachable through JavaFormatterOptions.formatJavadoc(true); the CLI and plugins are unaffected.

Decorative closing delimiters such as `/** ... **/` previously had the trailing
asterisk retained as comment body content, resulting in `/** ... * */`.

Ported from google/google-java-format#1474 (commit 2957b192). In this fork
stripJavadocBeginAndEnd lives in JavadocLexer; the tests were written first
and failed with `* */` before the change.
@abashev
abashev merged commit 444ffbc into main Oct 9, 2026
16 checks passed
@abashev
abashev deleted the gjf-1474-trailing-asterisks branch October 9, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants