`ExtractExplicitConstructorInvocationArguments` drops the extracted variable declaration when run via rewrite-maven-plugin
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- java
- Área
- build-system
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Java
- Estrellas
- 156
- Forks
- 129
- Merge medio
- 7 h 12 min
- PR fusionados (30 d)
- 43
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openrewrite/rewrite-migrate-java
-
bug
Dificultad 3/5 Medio día Aptitud para principiantes 40/100
openrewrite/rewrite-migrate-java#1292 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
openrewrite/rewrite-migrate-java#1246 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 32/100
openrewrite/rewrite-migrate-java#1227 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
OptionalNotPresentToIsEmpty rewrites `!isPresent()` on a non-`java.util.Optional` type, producing uncompilable `isEmpty()`Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
openrewrite/rewrite-migrate-java#1146 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 50/100
openrewrite/rewrite-migrate-java#1119 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de openrewrite/rewrite-migrate-java
Issues similares
-
RRateLimiter acquire methods accept negative permits and raise available permits above the rate.Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 4 días
-
README 中的代码语言数量与当前目录不一致Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
krahets/hello-algo#1993 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
NationalSecurityAgency/ghidra#9884 ·
Los mantenedores suelen responder en 2 días
-
Status: Pending Review Type: Feature Request
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
OpenRefine/OpenRefine#8019 ·
Los mantenedores suelen responder en 1 día
-
[TEMP] pin maven version to 3.9.xPosiblemente ocupada @petrenyi-mark la tomó hoy. Abierto
Dificultad 2/5 Menos de una hora Aptitud para principiantes 62/100