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
- 派生
- 565
- 平均合并
- 2 天 15 小时
- 30 天内合并 PR
- 65
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
diffplug/spotless 的其他 Issue
-
Add support for org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_record_parameter未关闭
难度 3/5 1-2 天 新手友好度 67/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
diffplug/spotless#3067 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 66/100
diffplug/spotless#3040 · 1 条评论 ·
维护者通常 1 天内回复
查看 diffplug/spotless 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 60/100
维护者通常 1 天内回复
-
[BUG] S3 CORS responses omit Access-Control-Allow-Credentials for matched origins可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
securityHeaders replaces a route's own Content-Security-Policy (0.9.9; weakens embedders' pages)未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
sqlcipher/sqlcipher-android#97 · 1 条评论 ·
-
area-integrations
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复