eclipse-tycho/tycho

Confusing warning or wrong use of system JDK in the compiler plugin?

Closed this issue · 0 comments

Maybe I don't get how the use of JDK by the compiler plugin should work (I'm using Tycho 4.0.6), but, https://tycho.eclipseprojects.io/doc/latest/tycho-compiler-plugin/compile-mojo.html#useJDK says

Which JDK to use for compilation. Default value is SYSTEM which means the currently running JDK.

In GitHub Actions I setup Java 21 as the JDK, which is also reported by Maven correctly:

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: /home/runner/.m2/wrapper/dists/apache-maven-3.9.6-bin/3311e1d4/apache-maven-3.9.6
Java version: 21.0.2, vendor: Eclipse Adoptium, runtime: /usr/lib/jvm/temurin-21-jdk-amd64

So I'd assume Tycho will use this one, since I haven't configured useJDK.

However, during the build I see:

Warning:  Using JavaSE-17 to fulfill requested profile of JavaSE-11. This might lead to faulty dependency resolution, consider defining a suitable JDK in the toolchains.xml.

This comes from this code

which, I seem to understand, searches for JDKs and stops as soon as it finds one higher than the profile of the currently compiled bundle. Since also Java 17 is installed in GitHub Actions (though it's not the set as the default, see above), Tycho is going to use Java 17 instead of Java 21?

By the documentation above I'd assume it should use the JDK set in the system (Java 21).

Or is just a misguided warning message?

Due to some compilation failures later in the build, it looks like it's really using Java 17 instead of Java 21 (the compilation fails because it cannot find the ArrayList.getLast method, introduced in Java 21).

Should I set a toolchain explicitly?

By the way, in our project, Xtext, we still use Java 11 as the required Java, but we'd like to test with Java 21.

thanks in advance