Skip to content

Restore enum-compatible methods on JavaFormatterOptions.Style - #1472

Closed
Goooler wants to merge 1 commit into
google:masterfrom
Goooler:style-enum-compat
Closed

Goooler wants to merge 1 commit into
google:masterfrom
Goooler:style-enum-compat

Conversation

@Goooler

@Goooler Goooler commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Style was changed from an enum to a record, which removed the implicit enum methods. Tools such as Spotless call Style.valueOf(String) to map user configuration to a style, and fail with NoSuchMethodError against the new version.

`Style` was changed from an enum to a record, which removed the implicit
enum methods. Tools such as Spotless call `Style.valueOf(String)` to map
user configuration to a style, and fail with `NoSuchMethodError` against
the new version.
@Goooler Goooler changed the title Restore enum-compatible methods on JavaFormatterOptions.Style Restore enum-compatible methods on JavaFormatterOptions.Style Oct 3, 2026
yagipass added a commit to yagipass/errorprone-tidy that referenced this pull request Oct 8, 2026
## Why

Java formatting was only checked by the treefmt pre-commit hook.
Contributors without Nix, and commits made with `--no-verify`, could
land unformatted Java, and CI did not catch it.

## What

- Apply Spotless with google-java-format. `./gradlew build`, and so CI,
now runs `spotlessCheck`, and `./gradlew spotlessApply` formats the
sources.
- Remove google-java-format from treefmt, so Spotless is the only Java
formatter and `nix fmt` formats only Nix.
- Update CONTRIBUTING.md to match.

## Trade-offs

- google-java-format is pinned to 1.36.1. Spotless 8.10.3 fails on
1.37.0 with `NoSuchMethodError`, because `JavaFormatterOptions.Style`
became a record
([diffplug/spotless#3126](diffplug/spotless#3126),
fix proposed in
[google/google-java-format#1472](google/google-java-format#1472)).
Dependabot's bump to 1.37.0 will fail CI until one of them ships.
- The pre-commit hook no longer checks Java formatting, so violations
surface at `./gradlew build` or in CI. Running `spotlessCheck` in the
hook was rejected because it starts Gradle on every commit. Keeping
google-java-format in both treefmt and Spotless was rejected because the
two versions would drift apart as nixpkgs updates.
- `build.gradle.kts` is still not formatted by any tool.

## Verification

Checked:

- The existing sources, formatted with 1.37.0 by treefmt, pass
`spotlessCheck` with 1.36.1 unchanged.
- Misformatting `FinalClass.java` makes `./gradlew build` fail at
`spotlessJavaCheck`, and `./gradlew spotlessApply` restores the original
file.
- `nix flake check` passes, and `nix fmt` processes only Nix files.

Not checked:

- `nix flake check` on aarch64-linux and x86_64-linux.
copybara-service Bot pushed a commit that referenced this pull request Oct 9, 2026
`Style` was changed from an enum to a record, which removed the implicit enum methods. Tools such as Spotless call `Style.valueOf(String)` to map user configuration to a style, and fail with `NoSuchMethodError` against the new version.

- Refs #1465 (comment)
- Closes diffplug/spotless#3126.

Fixes #1472

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1472 from Goooler:style-enum-compat ab11ed6
PiperOrigin-RevId: 996054769
copybara-service Bot pushed a commit that referenced this pull request Oct 9, 2026
`Style` was changed from an enum to a record, which removed the implicit enum methods. Tools such as Spotless call `Style.valueOf(String)` to map user configuration to a style, and fail with `NoSuchMethodError` against the new version.

- Refs #1465 (comment)
- Closes diffplug/spotless#3126.

Fixes #1472

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1472 from Goooler:style-enum-compat ab11ed6
PiperOrigin-RevId: 996054769
copybara-service Bot pushed a commit that referenced this pull request Oct 13, 2026
`Style` was changed from an enum to a record, which removed the implicit enum methods. Tools such as Spotless call `Style.valueOf(String)` to map user configuration to a style, and fail with `NoSuchMethodError` against the new version.

- Refs #1465 (comment)
- Closes diffplug/spotless#3126
- Closes #1478

Fixes #1472

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1472 from Goooler:style-enum-compat ab11ed6
PiperOrigin-RevId: 996054769
@Goooler

Goooler commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Finally, CI is green fow now in #1477.

copybara-service Bot pushed a commit that referenced this pull request Oct 13, 2026
`Style` was changed from an enum to a record, which removed the implicit enum methods. Tools such as Spotless call `Style.valueOf(String)` to map user configuration to a style, and fail with `NoSuchMethodError` against the new version.

- Refs #1465 (comment)
- Closes diffplug/spotless#3126
- Closes #1478

Fixes #1472

COPYBARA_INTEGRATE_REVIEW=#1472 from Goooler:style-enum-compat ab11ed6
PiperOrigin-RevId: 998277114
@Goooler
Goooler deleted the style-enum-compat branch October 13, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants