Leave a comment that opens with /*** out of javadoc formatting - #74
Merged
Merged
Conversation
With javadoc formatting on, a banner such as
/*************************
* Copyright
*
* Some Company
*************************/
was taken for javadoc because it starts with "/**": the row of
asterisks moved onto a line of its own, and its paragraphs became <p>
tags. The javadoc formatter has nothing to improve in a comment like
that.
This ports upstream commit 37171795 by cushon (google-java-format
1.8): a comment whose fourth character is another asterisk is not
javadoc. That holds with javadoc formatting off as well, where it
decides how blank lines around the comment are treated: a blank line
between such a banner and the declaration after it is now kept, as
after any other block comment, instead of being removed as it would be
after javadoc. The empty() expectation changes accordingly, and a test
pins the banner.
Of the 15,747 files of the JDK 21 sources, 43 format differently, by
70 blank lines more in all and no other change; every one of them is
in the input, after a banner comment. The four of those files that
change again on a second run did so on main already.
abashev
added a commit
to openjavaformat/docs
that referenced
this pull request
Sep 25, 2026
…grate Two more changes on the formatter's main branch move output away from palantir-java-format 2.98.0, and Migrate lists every such difference. openjavaformat/open-java-format#76 brings over palantir 2.99.0's one change: a switch expression that initializes a variable or a field starts on the declaration's line, 57 declarations in 51 files of the JDK 21 sources. openjavaformat/open-java-format#74 stops counting a comment that opens with /*** as javadoc, so a blank line between such a banner and the declaration after it stays: 70 blank lines in 43 files, all of them in the source. Both join the cast fix as not yet released, and the corpus paragraph gives their numbers.
abashev
added a commit
to openjavaformat/docs
that referenced
this pull request
Sep 25, 2026
2.98.0.4 is out on GitHub, Maven Central and the Gradle Plugin Portal, so the pages now install it. It carries the three output changes that Migrate listed as not yet in a release: the cast fix (openjavaformat/open-java-format#78), the switch expression on the declaration's line (openjavaformat/open-java-format#76) and the /*** banner that no longer counts as javadoc (openjavaformat/open-java-format#74). Each now says it applies since 2.98.0.4, and the corpus paragraph no longer calls them unreleased. The GitHub Action page keeps 2.98.0.3 as the default of the action's version input, because the action itself still defaults to it.
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.
Brings over upstream commit google/google-java-format@37171795 (google-java-format 1.8).
The bug
With javadoc formatting on (
JavaFormatterOptions.formatJavadoc(true)), a banner such aswas taken for javadoc because it starts with
/**: the row of asterisks moved onto a line of its own, and its paragraphs became<p>tags. The javadoc formatter has nothing to improve in a comment like that.From upstream, with the author kept
empty()expectation ofJavadocFormattingTestchanges with it:/***/stays as it is.Added here
bannerCommentIsNotJavadocinJavadocFormattingTest, the banner above with javadoc formatting on.What changes with javadoc formatting off
The same check decides how blank lines around a comment are treated. A blank line between such a banner and the declaration after it is now kept, as after any other block comment, instead of being removed as it would be after javadoc; a banner with no blank line after it stays as it was.
Checked
./gradlew :open-java-format:teston JDK 21: 1498 tests, all green.