`ExtractExplicitConstructorInvocationArguments` drops the extracted variable declaration when run via rewrite-maven-plugin
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- java
- 领域
- build-system
调研方向
Start by reading the ExtractExplicitConstructorInvocationArguments recipe and its extractMethodInvocationArgument test, which the issue says passes. Compare the test’s rewrite result with a run through rewrite-maven-plugin 6.46.1 using the supplied Java 25 example. Done means the extracted variable declaration appears before the explicit super or this invocation, so the transformed source compiles.
由索引模型根据 Issue 内容生成。
描述
What version of OpenRewrite are you using?
rewrite-maven-plugin6.46.1rewrite-migrate-java3.42.1 (latest published on Maven Central)- Java 25 (
maven.compiler.release=25)
What is the smallest, simplest way to reproduce the problem?
pom.xml with only this recipe active:
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.46.1</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.lang.ExtractExplicitConstructorInvocationArguments</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-migrate-java</artifactId>
<version>3.42.1</version>
</dependency>
</dependencies>
</plugin>
Source (this is the input of the recipe's own extractMethodInvocationArgument test):
import java.util.Objects;
class Parent {
Parent(String name) {
}
}
class Child extends Parent {
Child(String name) {
super(Objects.requireNonNull(name));
}
}
Run mvn rewrite:run.
What did you expect to see?
Child(String name) {
String name1 = Objects.requireNonNull(name);
super(name1);
}
What did you see instead?
Child(String name) {
super(name1);
}
The argument is replaced by a reference to a local variable, but the declaration is never inserted, so the result does not compile (cannot find symbol: variable name1).
The same happens with this(..) delegation (this(Executors.newSingleThreadScheduledExecutor()) becomes this(s1)) and with static calls (super(String.valueOf(1)) becomes super(v)). It is not specific to lambdas.
Additional context
- The corresponding unit test passes upstream, so the problem seems specific to a real run through the Maven plugin rather than
RewriteTest. - I could not test 3.46.0, since it is not yet on Maven Central. The only commit touching the recipe between 3.42.1 and 3.46.0 is #1235 (skip non-Java sources), which looks unrelated.
- No existing issue found for this recipe.
- 主要语言
- Java
- 星标
- 159
- 派生
- 130
- 平均合并
- 7 小时 12 分钟
- 30 天内合并 PR
- 43
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openrewrite/rewrite-migrate-java 的其他 Issue
-
AddJaxwsRuntime recipe injects legacy JAX-WS 2.3 runtime on JAX-WS 4.0 / Jakarta projects, causing a dependency resolution conflict可能已有人在做 @mohitduhan19 今天认领。 未关闭bug
难度 3/5 半天 新手友好度 40/100
openrewrite/rewrite-migrate-java#1292 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 68/100
openrewrite/rewrite-migrate-java#1246 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 32/100
openrewrite/rewrite-migrate-java#1227 · 2 条评论 ·
维护者通常 1 天内回复
-
OptionalNotPresentToIsEmpty rewrites `!isPresent()` on a non-`java.util.Optional` type, producing uncompilable `isEmpty()`可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 70/100
openrewrite/rewrite-migrate-java#1146 · 3 条评论 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 50/100
openrewrite/rewrite-migrate-java#1119 · 5 条评论 ·
维护者通常 1 天内回复
查看 openrewrite/rewrite-migrate-java 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
MCModderAnchor/TACZ#758 ·
-
agent-java community triage
难度 2/5 1-3 小时 新手友好度 72/100
elastic/apm-agent-java#4594 ·
维护者通常 1 天内回复
-
area/plugin good first issue
难度 2/5 1-3 小时 新手友好度 85/100
kestra-io/plugin-soda#137 ·
-
area/plugin good first issue
难度 2/5 1-3 小时 新手友好度 82/100
kestra-io/plugin-aws#816 ·
维护者通常 2 天内回复
-
area/plugin good first issue
难度 2/5 1-3 小时 新手友好度 88/100
kestra-io/plugin-kestra#200 ·
维护者通常 1 天内回复