Support for Java 21 (new LTS)?

xKiv

Active member
I hadn't tried Java 21 (I'll need to upgrade Gradle), but I know we haven't touched the menus in ages.

Warnings for building with 21:
1) current-er gradle requires that tasks always have defined order of execution. Older gradle already gave warning about this, 8.5 upgrades them to errors. I added the following:

Code:
startScripts.mustRunAfter shadowJar
distTar.mustRunAfter shadowJar
startShadowScripts.mustRunAfter jar

2) java 21 (at least the adoptium version?) removed some method that's use by google-java-format in the version used by com.diffplug.spotless 6.12.0 (which is what cleanly checked out mafia build.gradle has) -> breaks build when calling googleJavaFormat

3) after upgrading java to 21, gradle to 8.5, and spotless to 6.23.3: calling spotless finds several new violations in build.gradle (I just followed the patches that it spat out at me - it was just line formatting), and once I fixed those it found so many new violations in java files that I gave up and just commeted out the line that calls googleJavaFormat
 

MCroft

Developer
Staff member
Based on the findings of @xKiv above, it's non-trivial to switch our dev environment to Java 21, although it seems as if users can use java 21 (adoptium`s version, at least).

I don't know of any compelling reasons to switch, but if someone does have a good case for doing so, there's apparently some work to do.
 

heeheehee

Developer
Staff member
I upgraded Gradle to 8.8, and Spotless no longer finds any violations with openjdk21.

However, I'm seeing several test failures due to Mockito being unable to mock certain standard library classes. It seems that for some strange reason, mockito-inline in the central maven repo is stuck on 5.2.0 (seems like it was always meant to be a temporary package), when other mockito libraries have been updated to 5.12.

When I update the dependency to 'org.mockito:mockito-core:5.12.0', I get different test failures that will probably need more time to figure out what's wrong.

Those tests pass when using openjdk17, though, but RabbitHoleManagerTest.canAutomateChessPuzzleFromRelayBrowser() then fails (which then succeeds again when I drop the version of mockito-core to 5.2.0, or when I upgrade back up to 5.8.0). I'll look at this some more later.
 

fronobulax

Developer
Staff member
Those tests pass when using openjdk17, though, but RabbitHoleManagerTest.canAutomateChessPuzzleFromRelayBrowser() then fails (which then succeeds again when I drop the version of mockito-core to 5.2.0, or when I upgrade back up to 5.8.0). I'll look at this some more later.

The relay automation tests are the source of frequent intermittent failures exposed by https://github.com/kolmafia/kolmafia/pull/1889 although they have been observed elsewhere as well. Anecdotally they are more likely to fail on Windows.
 
Top