Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

google-java-format 1.37.0: NoSuchMethodError on JavaFormatterOptions$Style.valueOf (Style is now a record)

オープン 初心者向け
#3,126 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Goooler がすでに取り組んでいます。

2026年10月3日 から。

  • #1472 @Goooler による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
build-system

調査の方向性

google-java-format のスタイルが解決される GoogleJavaFormatFormatterFunc から始め、アダプターのリフレクションを google-java-format 1.37.0 の JavaFormatterOptions.Style API と比較します。報告されている Maven 設定で再現し、mvn spotless:check を実行します。完了条件は、バージョン 1.37.0 が InvocationTargetException なしで完了し、既存のスタイルオプションも引き続き機能することです。

索引モデルが issue の本文から書いたものです。

説明

Overriding the google-java-format version to 1.37.0 makes spotless:check fail with InvocationTargetException. Spotless then reports it as google-java-format(java.lang.reflect.InvocationTargetException) and gives no cause.

Environment

  • spotless-maven-plugin 3.10.3 (spotless-lib 4.10.3)
  • google-java-format 1.37.0 (works with 1.36.1)
  • JDK 21 locally, and the same failure on the CI runner

Config

<googleJavaFormat>
  <version>1.37.0</version>
  <reflowLongStrings>true</reflowLongStrings>
  <formatJavadoc>false</formatJavadoc>
</googleJavaFormat>

Cause
Running Maven with -Xlog:exceptions=info showed the wrapped error:

java.lang.NoSuchMethodError: 'JavaFormatterOptions$Style JavaFormatterOptions$Style.valueOf(java.lang.String)'

GoogleJavaFormatFormatterFunc calls JavaFormatterOptions.Style.valueOf(String). In 1.36.1, Style is an enum. In 1.37.0 it is a record (extends java.lang.Record, with a builder() and toBuilder()), and valueOf no longer exists. This looks related to the new --style=google|aosp flag. Style.GOOGLE and Style.AOSP still exist as static fields.

Ruled out

  • The javac --add-exports flags: the 1.37.0 formatter works with them.
  • Guava version: it works with 32.1.3, 33.2.1 and 33.6.0.
  • Missing APIs: Builder.style, formatJavadoc, Formatter(JavaFormatterOptions), RemoveUnusedImports, ImportOrderer.reorderImports(String, Style) and StringWrapper.wrap are all present in 1.37.0.

Repro
Set <version>1.37.0</version> on the googleJavaFormat step, then run mvn spotless:check.

The adapter will need to map the style name to the new Style type, for example with Style.GOOGLE and Style.AOSP, instead of calling valueOf.

Downstream, this is blocking a Renovate bump: bytestreams-io/codec-core#164.

主要言語
Java
スター
5.7k
フォーク
563
平均マージ
1日 18時間
マージ済み PR(30日)
53

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

diffplug/spotless のほかの issue

diffplug/spotless の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。