Upgrade Mockito to 5.17.x in Java 25 migration recipe#1041
Merged
Conversation
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.
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.
Summary
5.17.xupgrade toUpgradePluginsForJava25recipe alongside the existing Byte Buddy upgradeProblem
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 classfailures for any test that mocks classes under Java 25.While the recipe already upgrades
byte-buddy*to1.17.x, Mockito bundles its own Byte Buddy and older Mockito versions can pull in an incompatible version through dependency resolution.Solution
Add
UpgradeDependencyVersionfororg.mockito:mockito-*to5.17.x— the minimum minor version that bundles Byte Buddy 1.17.6+ with full Java 25 support.Test plan