Build and test on Java 25 with rewrite-java-25 - #1061
Merged
Conversation
timtebeek
marked this pull request as draft
July 23, 2026 17:37
timtebeek
marked this pull request as ready for review
July 24, 2026 22:40
timtebeek
marked this pull request as draft
July 24, 2026 22:41
Swap the test parser from `rewrite-java-21` to `rewrite-java-25` and override the toolchain to 25 (the `recipe-library` plugin pins it to 21), mirroring rewrite-migrate-java. CI now provisions JDK 25 and 21 via the shared workflow. The three java-21 -> java-25 fallout failures (AssertToAssertions, MockitoWhenOnStaticToMockStatic, JMockitMockUpToMockito) were all caused by the parser dropping a method invocation's type when an argument type was unresolvable. That is now fixed upstream in openrewrite/rewrite#8318, so no recipe or test changes are needed here.
timtebeek
force-pushed
the
tim/migrate-to-java-25
branch
from
July 24, 2026 23:37
4172c98 to
8489fcd
Compare
timtebeek
marked this pull request as ready for review
July 25, 2026 07:06
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.
What
Migrate the build and test suite to a Java 25 toolchain using the
rewrite-java-25parser (replacingrewrite-java-21), mirroring howopenrewrite/rewrite-migrate-javadoes it. This unblocks recipes/tests that rely on Java 22+ language features (e.g. unnamed_variables).Changes
build.gradle.kts:rewrite-java-21→rewrite-java-25, and override the toolchain to 25. Theorg.openrewrite.build.recipe-libraryplugin pins the toolchain to 21, so swapping the dependency alone is not enough..github/workflows/ci.yml: passjava_version: 25 / 21to the sharedci-gradle.yml, mirroring rewrite-migrate-java, so CI provisions JDK 25 (the toolchain has no auto-download resolver configured).Fallout fixed
Running the full suite on JDK 25 surfaced exactly three failures, all pre-existing java-21 → java-25 parser attribution differences (no recipe-logic behavior change):
AssertToAssertionsTest.migratesAssertStatementsWithMissingTypeInfo— the java-25 parser leavesassertNotNull(UnknownType.unknownMethod())unattributed (the erroneous argument prevents overload resolution), so both the type-based matcher andChangeMethodTargetToStaticmiss. Added a fallback inAssertToAssertionsthat swaps the statically-importedorg.junit.Assert.<m>fororg.junit.jupiter.api.Assertions.<m>when the call has no method type.MockitoWhenOnStaticToMockStaticTest.shouldShareSingleMockedStaticForConsecutiveStubbingsOfSameClass— the still-usedimport static org.mockito.Mockito.mockStaticwas dropped (non-compiling). The recipe generates themockStaticcall, so the import is now added unconditionally (onlyIfReferenced=false).JMockitMockUpToMockitoTest.mockUpMultipleTest— dropped still-usedmock/AdditionalAnswers.delegatesToimports (non-compiling). Root cause: the mockedFoo/Barwere defined as separate sources, so their types weren't on theJavaTemplateparser classpath; java-25 (stricter than java-21) then left the generatedmock/mockConstructionWithAnswer/delegatesTocalls unattributed, and the composite'sRemoveUnusedImportsunfolded theMockito.*star import and stripped the null-typed imports. The recipe output was already correct — the fix definesFoo/Baras nested classes (mirroring the passingmockUpStaticMethodTest'sMyClazz) so the types resolve. Verified in isolation that java-25 attributes these calls fine for any classpath-resolvable type.Verification
Full suite green on JDK 25 — 1731 tests, 0 failures.
Follow-up
main, PR MockitoWhenOnStaticToMockStatic: name unnamed_variable when reusing MockedStatic #1060 (fix for MockitoWhenOnStaticToMockStatic fails when using unnamed var (_) notation #1051) should be rebased and reduced to just the recipe fix + its tests, since it currently carries the samebuild.gradle.ktsbump.