top | item 38129357

(no title)

lbalazscs | 2 years ago

The latest Mockito works with Java 21; you'll just see a warning about the usage of the bytebuddy agent. In the future, you'll need to explicitly approve the loading of agents (you can call it "magic"), which will improve the security of your programs.

discuss

order

cesarb|2 years ago

> The latest Mockito works with Java 21

That was not the case a couple of days ago when I last looked; I see now that they released Mockito 5.7.0 two days ago, which probably fixes this issue. But that still shows my point: for every new Java LTS, you have to either fix some breakage, or update some library you depend on to a new version (which might then require further changes to your code, or even dropping compatibility with some older Java LTS).

Edit: I just tried with the latest Mockito (5.7.0), and it still gave me the same "Java 21 (65) is not supported by the current version" error, when run without the magic system property. It seems something else earlier in the dependencies had a dependency on an older release of byte-buddy, so I will have to manually upgrade byte-buddy, and hope that it doesn't break that earlier dependency.

krzyk|2 years ago

You have to update dependencies that depend on bytecode, like ASM, bytebuddy or aspectj. Those deps upgrades in 99% cases don't break the library that uses them.

I upgraded to JDK 21 on the day of release and haven't had issues with mockito (or spring, hibernate, junit, etc.)

marginalia_nu|2 years ago

I haven't really experienced this. I'm on Java 21 and haven't had any problems with Mockito what so ever.

I needed to bump the version of guice, but beyond that it was a very smooth transition.