Title: Option to keep a single marker annotation on the field's line · Issue #159 · openjavaformat/open-java-format · GitHub
Open Graph Title: Option to keep a single marker annotation on the field's line · Issue #159 · openjavaformat/open-java-format
X Title: Option to keep a single marker annotation on the field's line · Issue #159 · openjavaformat/open-java-format
Description: Upstream: palantir#1782 Kind: idea | Priority: low palantir-java-format#1782 (closed unmerged on 2026-10-17) lets a field with exactly one argument-less annotation keep it on the same line (@Mock private Foo foo;), reusing the predicate ...
Open Graph Description: Upstream: palantir#1782 Kind: idea | Priority: low palantir-java-format#1782 (closed unmerged on 2026-10-17) lets a field with exactly one argument-less annotation keep it on the same line (@Mock p...
X Description: Upstream: palantir#1782 Kind: idea | Priority: low palantir-java-format#1782 (closed unmerged on 2026-10-17) lets a field with exactly one argument-less annotation keep it on the same line (@Mock p...
Opengraph URL: https://github.com/openjavaformat/open-java-format/issues/159
X: @github
Domain: redirect.github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Option to keep a single marker annotation on the field's line","articleBody":"**Upstream:** https://github.com/palantir/palantir-java-format/pull/1782 \n**Kind:** idea | **Priority:** low\n\n[palantir-java-format#1782](https://github.com/palantir/palantir-java-format/pull/1782) (closed unmerged on 2026-10-17) lets a field with exactly one argument-less annotation keep it on the same line (`@Mock private Foo foo;`), reusing the predicate that locals and parameters already use. Fields with annotation arguments, several annotations, or lines that would overflow stay one-per-line. The author themselves flags it as a maintainer taste call, because the existing rule (\"field annotations are always vertical\") was a deliberate choice.\n\nWhy it matters to us: our `JavaInputAstVisitor` still hard-codes vertical annotations for fields (near line 3807), so this would be a deliberate style divergence from palantir, only worth it if our users ask for it (Mockito and injection annotations are the typical case). Upstream gave no reason beyond taste, and our recent lambda-parameter change (#103) shows we are open to inline annotations where they are clearly short.\n\nAffected files: `open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java`, field-annotation test data.\n\n**Before** (how it is formatted today; the field rule is hard-coded vertical in our code):\n```java\nclass Test {\n `@Mock`\n private Foo foo;\n\n `@Mock`\n private Bar bar;\n}\n```\n**After** (with the change):\n```java\nclass Test {\n `@Mock` private Foo foo;\n `@Mock` private Bar bar;\n}\n```\n\nSuggested action: watch; ignore unless users request it, and then consider it as an opt-in setting rather than a default change.\n\n---\n_Filed from an upstream-watch ticket after manual review._","author":{"url":"https://github.com/abashev","@type":"Person","name":"abashev"},"datePublished":"2026-10-25T19:22:18Z","url":"https://github.com/openjavaformat/open-java-format/issues/159"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0574606f-bd3d-d05f-cd74-7868407f1e77 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCF6:1004C8:1E59E:27A7C:6AFBD591 |
| html-safe-nonce | 00a42d0ff22f4aef04f62acd7d2bf19a5c29842164601cf977c9d2fd663f986f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0Y2OjEwMDRDODoxRTU5RToyN0E3Qzo2QUZCRDU5MSIsInZpc2l0b3JfaWQiOiI1ODQxMDMyMDA2OTkwNzg1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6f62099a3e9bad453ac5ed6c8d3da0d8946f51170eeca7e45305a1dc509212a3 |
| hovercard-subject-tag | issue:6028321829 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/openjavaformat/open-java-format/159/issue_layout |
| twitter:image | https://opengraph.githubassets.com/82614ae46abf3aaf2785624a1622301b9595f6a9f2238a50125c3f0ff340d331/openjavaformat/open-java-format/issues/159 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/82614ae46abf3aaf2785624a1622301b9595f6a9f2238a50125c3f0ff340d331/openjavaformat/open-java-format/issues/159 |
| og:image:alt | Upstream: palantir#1782 Kind: idea | Priority: low palantir-java-format#1782 (closed unmerged on 2026-10-17) lets a field with exactly one argument-less annotation keep it on the same line (@Mock p... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abashev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 18742cb872ec73544356e60359266b67aafece70c4ce008042e06227924cdd07 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 820be804f18e1ef3940bd74a00d41d73d02e2b91 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width