Upgrade AspectJ and fold mockito-inline into mockito-core for Java 25 - #1223
Merged
Conversation
…a 25 `mockito-inline` was discontinued after 5.2.0 once inline mocking became the default in `mockito-core`, so raising a shared Mockito version property past that leaves the dependency unresolvable. Renaming rather than removing keeps Mockito present in a module whose only declaration was the inline artifact. Neither AspectJ plugin compiles at Java 25 out of the box: both bundle aspectjtools 1.9.7, which rejects `-25`, so the compiler has to be pinned explicitly. The coordinate moves because `org.codehaus.mojo` defaults `complianceLevel` to 1.4 and always passes it, which contradicts a source level of 25; `dev.aspectj` leaves it unset and follows source and target instead.
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.
Two ways
UpgradeToJava25leaves a previously-building project unable to build. Both are inUpgradePluginsForJava25, inline alongside the existing plugin bumps, so no new recipe names are introduced.mockito-inlineis bumped to a version that was never publishedJava 25 needs the Mockito java agent wired into surefire, so the migration raises Mockito. Where a project keeps a single shared
${mockito.version}property that also feedsmockito-inline, the result does not resolve:org.mockito:mockito-inlinewas discontinued after 5.2.0 (2023-03-09) once inline mocking became the default inmockito-core. Any bump of a shared property past that breaks every module declaring it.Renaming rather than removing matters: a module whose only Mockito dependency is
mockito-inlinewould otherwise lose Mockito entirely.RemoveDuplicateDependencieshandles the case where the rename collides with an existingmockito-core. Both steps are ordered ahead of the version bump so they land in the same cycle.This mirrors what
org.openrewrite.java.testing.mockito.Mockito4to5Onlydoes upstream, inlined rather than composed because that recipe also drags a full Mockito 1→5 source migration into what is otherwise a build-file change.AspectJ cannot compile at Java 25
Verified against real compilers on Zulu 25 rather than release notes.
ajcfromaspectjtools:-25unrecognized single argument: "-25"-25 -source 25 -target 25-1.8 -source 25 -target 25Compliance level '1.8' is incompatible with source level '25'So the
aspectjtoolspin is mandatory, and so is rewritingcomplianceLevelwhere a project spells out1.8.The coordinate moves to
dev.aspectjon capability grounds.org.codehaus.mojodeclares@Parameter(defaultValue = "1.4") String complianceLeveland emits-<level>unconditionally, so every AspectJ module that does not spell outcomplianceLevelwould hard-fail the moment a Java-25-capable compiler is on the plugin classpath.dev.aspectjdeclares it with no default and falls back tosource/target, whichUpgradeJavaVersionhas already moved to 25.org.codehaus.mojo:aspectj-maven-pluginis not abandoned — 1.16.0 shipped 2026-01-18. But its Java 25 support (issue Migrate to sequenced collections in Java 21 / JEP 431 #243 / PR RemoveRuntime.runFinalizersOnExit()in upgrade to Java 11 #244) adds the string"25"toACCEPTED_COMPLIANCE_LEVEL_VALUESand nothing else, with no test, while still bundling aspectjtools 1.9.7. The reporter's original error is exactly what 1.9.7 produces, so that fix landed in the wrong place. Neither plugin reaches Java 25 without an explicitaspectjtoolsoverride.The coordinate change is a drop-in: same artifactId, same
goalPrefix, same goals, sameorg.codehaus.mojo.aspectj.*implementation classes, anddev.aspectjis a strict parameter superset.One deliberate limit: the
complianceLevelrewrite targets the plugin-level<configuration>only, not<executions>/<execution>/<configuration>.Tests
Three added to
UpgradeToJava25Test: shared version property withmockito-inline, the dedupe path, and the old AspectJ coordinate withcomplianceLevel 1.8. Full suite: 318 classes, 1935 tests, 0 failures.Found by compiling the output of
UpgradeToJava25across a set of open source repositories.