google-java-format 1.37.0: NoSuchMethodError on JavaFormatterOptions$Style.valueOf (Style is now a record)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 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-exportsflags: 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)andStringWrapper.wrapare 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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
diffplug/spotless のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
diffplug/spotless#3125 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add support for org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_record_parameterオープン
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
Maven plugin: Maven 4 warns about Plexus `@Component` injection対応中かも @Goooler が 4 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
diffplug/spotless#3121 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
diffplug/spotless の issue をすべて見る
似ている issue
-
new feature
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/rocketmq-dashboard#5594 ·
メンテナーはふだん 3 日以内に返信
-
bug pkg:sdk
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aws/aws-durable-execution-sdk-java#773 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
PCL-Community/PCL-CE#3652 ·
メンテナーはふだん 1 日以内に返信
-
TaskSecret.vue: replace explicit `any` with real types対応中かも @prayas-bit が今日担当しました。 オープンarea/frontend good first issue kind/cooldown
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
kestra-io/kestra#20352 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信