Skip to content

Upgrade Mockito to 5.17.x in Java 25 migration recipe#1041

Merged
timtebeek merged 1 commit intomainfrom
upgrade-mockito-java25
Apr 2, 2026
Merged

Upgrade Mockito to 5.17.x in Java 25 migration recipe#1041
timtebeek merged 1 commit intomainfrom
upgrade-mockito-java25

Conversation

@timtebeek
Copy link
Copy Markdown
Member

Summary

  • Adds Mockito 5.17.x upgrade to UpgradePluginsForJava25 recipe alongside the existing Byte Buddy upgrade

Problem

Mockito's inline mock maker relies on Byte Buddy for bytecode manipulation. Byte Buddy versions bundled with Mockito before 5.17.0 only understand classfile version 66 (Java 22), but Java 25 emits classfile version 69. This causes Byte Buddy to abort instrumentation, resulting in Mockito cannot mock this class failures for any test that mocks classes under Java 25.

While the recipe already upgrades byte-buddy* to 1.17.x, Mockito bundles its own Byte Buddy and older Mockito versions can pull in an incompatible version through dependency resolution.

Solution

Add UpgradeDependencyVersion for org.mockito:mockito-* to 5.17.x — the minimum minor version that bundles Byte Buddy 1.17.6+ with full Java 25 support.

Test plan

  • Existing tests pass
  • Recipe CSV validation passes

Mockito's inline mock maker relies on Byte Buddy, but versions before
5.17.0 bundle a Byte Buddy that only supports classfile version 66
(Java 22). Java 25 emits classfile version 69, causing Byte Buddy to
abort instrumentation and Mockito to fail with "cannot mock this class".

Mockito 5.17.0+ bundles Byte Buddy 1.17.6+ which supports Java 25.
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Apr 2, 2026
@timtebeek timtebeek merged commit ed7df0d into main Apr 2, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Apr 2, 2026
@timtebeek timtebeek deleted the upgrade-mockito-java25 branch April 2, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant