Preserve Java 25 constructor extraction statements - #1206
Draft
martinfrancois wants to merge 1 commit into
Draft
Conversation
4 tasks
martinfrancois
force-pushed
the
agent/repro-extract-constructor-undefined-locals
branch
2 times, most recently
from
August 16, 2026 02:53
9d9ca3a to
412694d
Compare
martinfrancois
force-pushed
the
agent/repro-extract-constructor-undefined-locals
branch
from
August 16, 2026 12:23
412694d to
d2f4a8d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suggested review order: 18 of 52 (Score: 6.5)
Review first: openrewrite/rewrite-static-analysis#976
What's changed?
Preserves the local declarations inserted before Java 25 explicit constructor invocations. The recipe now replaces the constructor arguments before inserting the Java 25 statements, allowing both transformations to use
JavaTemplatewithout reparsing away the declarations.What's your motivation?
Recipe:
org.openrewrite.java.migrate.lang.ExtractExplicitConstructorInvocationArguments.I found this by running
org.openrewrite.java.migrate.lang.ExtractExplicitConstructorInvocationArgumentsfromorg.openrewrite.recipe:rewrite-migrate-java:3.40.0onCodexAppServerClient.javain Symphony-Trello ata8013f27with Java 25. I reproduced the same result with the latest released recipe artifact,org.openrewrite.recipe:rewrite-migrate-java:3.42.0. The recipe changed 11 files, and./mvnw -DskipTests compilethen reported undefined generated identifiers in production code.Before
Actual after the recipe
Expected after the recipe
The transformed constructor references
clock1without declaring it. The same mechanism generated other missing names, includingworkflowConfig1,healthChecker1, andrepositorySources1, so the checkout no longer compiles.Confirmed real-world execution
CodexAppServerClient.javaata8013f27.martinfrancois/symphony-trello@a8013f27.Anything in particular you'd like reviewers to focus on?
Please review the transformation order. Replacing arguments first lets the pre-Java-25 parse shape remain valid for that template; inserting the Java 25 declarations last preserves them. The Java-25-only focused suite passes with both steps implemented through
JavaTemplate.Have you considered any alternatives or workarounds?
Constructing identifiers and variable declarations directly avoids the reparse, but OpenRewrite's template abstraction provides attributed nodes and preserves framework conventions when the operations are ordered safely.
Any additional context
Pre-existing tests changed:
ExtractExplicitConstructorInvocationArgumentsTest.java.extractWithSourcePathWideningSupertype(updated).martinfrancois/symphony-trello@a8013f27org.openrewrite.recipe:rewrite-migrate-java:3.40.0org.openrewrite.recipe:rewrite-migrate-java:3.42.0ExtractExplicitConstructorInvocationArgumentsTest, enabled only on Java 25 or laterThis change was prepared with AI assistance. I reviewed the target execution evidence, implementation, tests, and contribution text.
Checklist
./gradlew buildlocally, and committed any resulting changes torecipes.csv