`ExtractExplicitConstructorInvocationArguments` drops the extracted variable declaration when run via rewrite-maven-plugin
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- java
- Ambito
- build-system
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 156
- Fork
- 129
- Merge medio
- 7h 12m
- PR unite (30g)
- 43
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openrewrite/rewrite-migrate-java
-
bug
Difficoltà 3/5 Mezza giornata Idoneità per principianti 40/100
openrewrite/rewrite-migrate-java#1292 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
openrewrite/rewrite-migrate-java#1246 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 32/100
openrewrite/rewrite-migrate-java#1227 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
OptionalNotPresentToIsEmpty rewrites `!isPresent()` on a non-`java.util.Optional` type, producing uncompilable `isEmpty()`Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
openrewrite/rewrite-migrate-java#1146 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
openrewrite/rewrite-migrate-java#1119 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di openrewrite/rewrite-migrate-java
Issue simili
-
`timer` rule rejects dates the engine acceptsForse già presa @MFA-G l’ha presa oggi. Apertabug ready
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
camunda/bpmnlint-plugin-camunda-compat#281 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
status: waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
AOT compilation fails for derived delete queries returning SetForse già presa @ryujungkyun l’ha presa oggi. Apertastatus: waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
spring-projects/spring-data-jpa#4387 ·
I maintainer di solito rispondono entro 3 giorni