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 — Treat a single upper case letter as a type name in a dotted chain by abashev · Pull Request #70 · openjavaformat/open-java-format

Conversation

@abashev

@abashev abashev commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Brings over google/google-java-format#731, a fix from google-java-format 1.14.

The bug

A dotted name is broken after its type-name prefix, and the prefix is found from the case of each segment: com.example.Foo.bar is a package, a class and a member. A single upper case letter such as Android's R counted as an all-caps constant, so a long resource reference found no prefix and broke at every dot:

    int resourceId = com.some
            .extremely
            .verbose
            .pkg
            .name
            .R
            .string
            .some_extremely_long_resource_identifier_that_exceeds_the_column_limit;

From upstream, with the author kept

  • Treat single-character upper case identifiers as UpperCamelCase google/google-java-format#731 by Liam Miller-Cushon, commit authored by them: a single upper case letter is UpperCamelCase in TypeNameClassifier, so the chain keeps com.some.extremely.verbose.pkg.name.R.string together and breaks once, before the last segment. The upstream golden b26306390 and the two TypeNameClassifierTest assertions come with it, with the expected output in this project's style.

Checked

  • The golden and the from("A") assertion fail on main and pass with the change.
  • ./gradlew :open-java-format:test on JDK 21: 1501 tests, all green.
  • The 15,747 files of the JDK 21 sources format exactly as before: no chain in the JDK turns on a single-letter class name.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cushon @abashev
Treat a single upper case letter as a type name in a dotted chain
010cef1
A dotted name is broken after its type-name prefix, and the prefix is
found from the case of each segment: "com.example.Foo.bar" is a package,
a class and a member. A single upper case letter such as Android's R
counted as an all-caps constant, so in
"com.some.extremely.verbose.pkg.name.R.string.some_resource" no prefix
was found and the name broke at every dot, one segment per line.

This ports google/google-java-format#731 by Liam Miller-Cushon: a
single upper case letter is UpperCamelCase, so the chain keeps
"com.some.extremely.verbose.pkg.name.R.string" together and breaks
before the last segment. The golden b26306390 and the two
TypeNameClassifierTest assertions come from upstream, with the
expected output in this project's style.

The 15,747 files of the JDK 21 sources format exactly as before.
@abashev
abashev merged commit b1f0450 into main Sep 25, 2026
15 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@abashev
abashev deleted the single-letter-type-name branch September 25, 2026 07:51
abashev added a commit to openjavaformat/docs that referenced this pull request Sep 25, 2026
@abashev
List the class name and tab fixes on Migrate, with a link for each ch…
1627ba4
…ange

2.98.0.4 carries two more fixes that change code palantir-java-format
2.98.0 has already formatted: a one-letter class name such as Android's
R no longer counts as a constant in a dotted name
(openjavaformat/open-java-format#70), and tabs at the end of a line in a
comment are dropped (openjavaformat/open-java-format#73). Neither shows
on the JDK 21 sources, which have no such dotted name and no comment
ending in a tab, and the corpus paragraph now says so. The other fixes
of 2.98.0.4 leave code that palantir-java-format has already formatted
as it is, so they stay off the list.

Every item now links the pull request behind it. The string fix went to
main without one, so it links the issue it closed,
openjavaformat/open-java-format#32.

The GitHub Action page gives 2.98.0.4 as the default of the version
input, as the action's main branch now does
(openjavaformat/open-java-format-action@83d0df8).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@abashev @cushon
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.
You are visitor 01402503 — 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.