error-prone icon indicating copy to clipboard operation
error-prone copied to clipboard

Increasing minimum supported JDK to JDK 21 (and dropping support for JDK 17)

Open cushon opened this issue 8 months ago • 4 comments
trafficstars

The minimum supported JDK to run Error Prone will eventually be updated from JDK 17 to JDK 21. This is tentatively planned for September 2025.

This bug is intended to collect input from the community. (Previously for the upgrade to JDK 17: #3803)

Note that using a newer JDK version to run javac during the build doesn't prevent building code that is deployed to earlier versions, the compiler just has to be configured with --release (or -source/-target/-bootclasspath). For example, it's supported to use the JDK 21 javac and pass --release 8 to compile Java 8 code that is deployed to a JDK 8 runtime.

If you're currently running Error Prone on JDK 17, do you have a timeline for upgrading to a newer version?

cushon avatar Mar 04 '25 15:03 cushon

Mockito uses ErrorProne. We don't update it as often as other dependencies, since it often requires manual resolution. As such, we are on 2.23.0. When we got around to resolving it manually, we realized that the minimum version is now JDK 17: https://github.com/mockito/mockito/pull/3515

Given that Mockito is one of those projects that still supports older Java projects, we are currently on JDK 11. We do see that other popular projects move to JDK 17 (Spring, JUnit, AssertJ), whereas we usually take a more conservative approach. ByteBuddy (fundamental for Mockito) still supports Java 8.

We have discussed updating the baseline of Mockito to JDK 17. We updated our baseline last in Mockito 5 released in January 2023. Given that projects like Spring (https://spring.io/blog/2022/03/28/an-update-on-java-17-adoption), JUnit (https://github.com/junit-team/junit5/issues/4246) and AssertJ (https://github.com/assertj/assertj/issues/3442) all converge on Java 17, I think 17 for us the most likely candidate. If ErrorProne updates to 21, then we are left out to use ErrorProne for the next couple of years, which I consider quite a pity.

See also this question why not to choose 21 as the baseline for all of these projects.

TimvdLippe avatar Mar 14 '25 09:03 TimvdLippe

@TimvdLippe do you think the part about "using a newer JDK version to run javac during the build doesn't prevent building code that is deployed to earlier versions, the compiler just has to be configured with --release" could apply to mockito? It looks like Mockito's CI is already using JDK 17 and then configuring Gradle to run tests on older versions:

  • https://github.com/mockito/mockito/blob/0215884a5e68016504be98599b3045070a558002/.github/workflows/ci.yml#L53
  • https://github.com/mockito/mockito/blob/0215884a5e68016504be98599b3045070a558002/buildSrc/src/main/kotlin/mockito.test-launcher-conventions.gradle.kts#L9

cushon avatar Mar 14 '25 17:03 cushon

Ah I had forgotten we did that (oops). In that case, it's not as bad as I initially thought it would. Still, I think as a JVM community we benefit from choosing 1 baseline version. For now, that appears to be JDK 17, so I rather have us all use JDK 17 as our baseline to build artifacts etc.

If ErrorProne ends up bumping, then yes in theory Mockito can update as well. Whether we will do so, I don't know yet, as I would like to discuss that with other open source maintainers first.

TimvdLippe avatar Mar 15 '25 15:03 TimvdLippe

@TimvdLippe FWIW, the Javadoc issues I fixed last year (mockito/mockito#3226 and mockito/mockito#3230) forced Mockito to use Java 21 at least when releasing.

In AssertJ, we decided to adopt the latest LTS to build the project, and we haven't encountered issues so far.

scordio avatar Mar 16 '25 11:03 scordio

I'm going to make another release of Error Prone soon, and then will likely try updating the minimum supported version to JDK 21 for the next release after that.

cushon avatar Sep 17 '25 02:09 cushon

@cushon it may be good to add in the 2.43.0 release notes that Error Prone now requires JDK 21+.

msridhar avatar Oct 22 '25 18:10 msridhar

Isn't it a breaking change? Shouldn't it be a new major version?

Projects that have Dependabot / Renovate will have a good time...

remal avatar Oct 22 '25 19:10 remal

@cushon it may be good to add in the 2.43.0 release notes that Error Prone now requires JDK 21+.

Thanks, I added a note to https://github.com/google/error-prone/releases/tag/v2.43.0

cushon avatar Oct 22 '25 20:10 cushon

Can we have a new major version?

remal avatar Oct 22 '25 20:10 remal

Hi, it appears both the Wiki and the documentation for installation on the website still say Java 17 is supported.

I would fork to update those and raise a PR but I cannot find where they are defined in the repository.

ascopes avatar Nov 08 '25 10:11 ascopes

Hi, it appears both the Wiki and the documentation for installation on the website still say Java 17 is supported.

There's a PR to update the docs that I will get merged soon: https://github.com/google/error-prone/pull/5308. I also updated the wiki, thanks.

cushon avatar Nov 08 '25 11:11 cushon