The Groovy test runner has this entry in the pom.xml:
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
I believe these map to the -source and -target flags of javac.
JVM people: is there a good reason to target such an old version? We are currently looking at upgrading from JDK 21 to 24.
I’ll give my standard advice. Bump up the versions slowly until something breaks. Then you have your answer. 
I think the file means Maven’s compiler only accepts incoming Java 11-compatible APIs and emits bytecode that would work with the Java 11 runtime. So you could use JDK 24 as long as only JDK 11 stuff reaches the compiler. Otherwise, you need to update the targeted version. Maven is for building and running the test runner and wouldn’t directly run the student code. So I think you only need to update this if the project runner dependencies need it. I am not a JVM person though.
1 Like
I don’t think there is a good reason for 11. It looks like a leftover from the project template, and it does have an effect, so I’d raise it together with the JDK.
A few things I checked in the test runner image:
The pom does build student code. bin/run.sh copies /root/pom.xml into the solution folder and runs mvn test there, so this file is the build for every submission.
The setting goes to the Groovy compiler, not javac. The exercises have no Java sources. GMavenPlus picks up maven.compiler.target as its target bytecode version. With the current image (Groovy 4.0.24, JDK 21) I compiled a small file with different values:
maven.compiler.target |
Class file version |
record Point(int x, int y) {} |
| 11 (current) |
55 (Java 11) |
plain final class, not a java.lang.Record |
| 17 |
61 (Java 17) |
real java.lang.Record |
| 21 |
65 (Java 21) |
real java.lang.Record |
| 25 |
fails |
GMavenPlus 4.0.1: Unrecognized target bytecode: '25' |
So today a student who writes a record gets Groovy’s emulated version rather than a native one. It doesn’t limit which JDK APIs they can call: those come from the JDK the runner runs on.
What actually limits the JDK version is Groovy. Groovy 4.0.24 can’t read JDK 25 class files (Unsupported class file major version 69), as noted in the GitHub issue. To target 25, GMavenPlus needs a newer version as well; I haven’t tried which one.
On the JDK choice: 24 is not an LTS release, so 25 seems the better goal.
I also tried the runner with Groovy 6.0.0 and JDK 25, and all 67 example solutions pass. Details are in my comment on the issue. With Groovy 6, a target of 11 is raised to 17 anyway, since that is its minimum.
3 Likes
Apologies, that was a typo. 25 was always the intention.