GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Option to keep a single marker annotation on the field's line · Issue #159 · openjavaformat/open-java-format

Option to keep a single marker annotation on the field's line #159

New issue
Copy link
New issue
Copy link
Open
Open
Option to keep a single marker annotation on the field's line#159
Copy link
Labels
enhancementNew feature or requestNew feature or request

Description

@abashev
abashev
opened on Oct 25, 2026
Issue body actions

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 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.

Why 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.

Affected files: open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java, field-annotation test data.

Before (how it is formatted today; the field rule is hard-coded vertical in our code):

class Test {
    `@Mock`
    private Foo foo;

    `@Mock`
    private Bar bar;
}

After (with the change):

class Test {
    `@Mock` private Foo foo;
    `@Mock` private Bar bar;
}

Suggested action: watch; ignore unless users request it, and then consider it as an opt-in setting rather than a default change.


Filed from an upstream-watch ticket after manual review.

Activity

  1. abashev
    added
    enhancementNew feature or requestNew feature or request
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.