`ExtractExplicitConstructorInvocationArguments` drops the extracted variable declaration when run via rewrite-maven-plugin
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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分
- マージ済み PR(30日)
- 43
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 32/100
openrewrite/rewrite-migrate-java#1227 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
OptionalNotPresentToIsEmpty rewrites `!isPresent()` on a non-`java.util.Optional` type, producing uncompilable `isEmpty()`再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 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
-
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 日以内に返信
-
bug untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
opensearch-project/search-relevance#618 ·
メンテナーはふだん 3 日以内に返信