Title: Keep the comment prefix when wrapping a markdown docstring (palantir #1776) by abashev · Pull Request #102 · openjavaformat/open-java-format · GitHub
Open Graph Title: Keep the comment prefix when wrapping a markdown docstring (palantir #1776) by abashev · Pull Request #102 · openjavaformat/open-java-format
X Title: Keep the comment prefix when wrapping a markdown docstring (palantir #1776) by abashev · Pull Request #102 · openjavaformat/open-java-format
Description: Port of palantir#1776 by asm0dey, cherry-picked with the author kept. It fixes palantir#1803: from JDK 23 on, javac hands a run of /// markdown doc lines over as one comment token, every line after the first still carries its source indentation, and JavaCommentsHelper.wrapLineComments read the slash prefix, and the width budget, from that untrimmed line. The prefix came back empty, so the wrapped remainder was written out as bare code. Reproduced on main (2fbf175) The class from palantir#1803, formatted on JDK 25 and 27, comes out exactly as reported: /// @param b Aaaaaaa aaaaaaaaaa aaaaaaaaaaaaa aaaaaa aaaaaaaaaaaaaa aaaaaaaaa, aaaaaa aaaaaaaaa (aaaaaaaa XXXXXXXX aaaaaaa) public record Yyy(String a, String b) {} javac then fails with ';' expected. The default CLI run reports the same errors and exits with 2, because the import pass re-parses the broken result; that is the crash the issue shows in Spotless. On JDK 21 each /// line is its own token and the output is right. It is not only a contrived case: in the JDK 27 sources, jdk.compiler/com/sun/source/tree/VariableTree.java has a 141-column /// line. On JDK 27, main turns its overflow into bare text and the CLI refuses the file with = expected; with this change the overflow wraps as a /// line. The change wrapLineComments trims the line before reading the prefix and measuring it: six lines in JavaCommentsHelper. From the upstream description: a continuation line keeps /// when it wraps; a line at the column limit is no longer wrapped (the indentation was counted twice); an unbreakable token is left long instead of becoming an empty /// followed by bare text; ///foo becomes /// foo on every line of the run, so the same source no longer formats differently depending on whether the running JDK hands the run over as one token or one per line. Tests: JavaCommentsHelperTest builds the multi-line token directly, so the JDK 21 test task covers the bug; four of its six tests fail on main. The end-to-end test in FormatterTest is gated at JDK 23 and runs in the JDK 25, 26 and 27 jobs. Adapted to the fork Style.OJF for Style.PALANTIR. The fork's JavaCommentsHelper takes the JavaInput rather than a line separator, so the test builds one from class T {}. The test class and its methods are package-private and final, as the Picnic rules JUnitClassModifiers and JUnitMethodDeclaration demand. No changelog entry: the fork keeps none. Checks :open-java-format:test on JDK 21 (gated test skipped), 25 and 27 (gated test passes): 1604 tests, 0 failures. The issue's class on JDK 25 and 27: compiles, a second run changes nothing, and the default run agrees with the run that skips the import passes. Corpora formatted with main's jar and this branch's jar on the matching runtime: JDK 21 (15,747 files) and JDK 25 (15,368) identical; JDK 27 (15,310): one file differs, the VariableTree.java above, which main could not format at all.
Open Graph Description: Port of palantir#1776 by asm0dey, cherry-picked with the author kept. It fixes palantir#1803: from JDK 23 on, javac hands a run of /// markdown doc lines over as one comment token, every line after...
X Description: Port of palantir#1776 by asm0dey, cherry-picked with the author kept. It fixes palantir#1803: from JDK 23 on, javac hands a run of /// markdown doc lines over as one comment token, every line after...
Opengraph URL: https://github.com/openjavaformat/open-java-format/pull/102
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f005887d-9780-a86f-5657-169a59872fd1 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D0CE:202797:6BA80:93C51:6AFBC76A |
| html-safe-nonce | da6f36293b410f8655ba460fd34afdfdaa6891cf8014b4e15fc1a150d85ed43b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMENFOjIwMjc5Nzo2QkE4MDo5M0M1MTo2QUZCQzc2QSIsInZpc2l0b3JfaWQiOiI5MDYzMzg3MjgxNDIyNTM0NTA2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d132ee2cacb45b779362f8fff224b9711669053e48f9520089ca1f5afdc4fd27 |
| hovercard-subject-tag | pull_request:4728672289 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/openjavaformat/open-java-format/pull/102/files |
| twitter:image | https://avatars.githubusercontent.com/u/214171?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/214171?s=400&v=4 |
| og:image:alt | Port of palantir#1776 by asm0dey, cherry-picked with the author kept. It fixes palantir#1803: from JDK 23 on, javac hands a run of /// markdown doc lines over as one comment token, every line after... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | d440bda0d812801778b27bfe9f7c1ce9ff22420c73f6f95150c4fcbca311c50b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git |
| octolytics-dimension-user_id | 325177626 |
| octolytics-dimension-user_login | openjavaformat |
| octolytics-dimension-repository_id | 1288055459 |
| octolytics-dimension-repository_nwo | openjavaformat/open-java-format |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 214273098 |
| octolytics-dimension-repository_parent_nwo | palantir/palantir-java-format |
| octolytics-dimension-repository_network_root_id | 214273098 |
| octolytics-dimension-repository_network_root_nwo | palantir/palantir-java-format |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2c43021aed8695990c86c0eaaedc600bfeffec36 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width