Gradle javaToolChains - output is misleading

I’m trying out the new support for Java toolchains

>gradle -q javaToolchains

 + Options
     | Auto-detection:     Enabled
     | Auto-download:      Enabled

 + Zulu JDK 1.8.0_275
     | Location:           C:\Program Files\Zulu\zulu-8
     | Language Version:   8
     | Vendor:             Zulu
     | Is JDK:             true
     | Detected by:        Current JVM

 + Zulu JDK 15.0.1
     | Location:           C:\Program Files\Zulu\zulu-15
     | Language Version:   15
     | Vendor:             Zulu
     | Is JDK:             true
     | Detected by:        Windows Registry

I put this in my build.gradle file:

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(15)
        vendor = JvmVendorSpec.matching("Zulu")

However, that results in:

* What went wrong:
A problem occurred evaluating root project 'LS2'.
> Could not resolve all dependencies for configuration ':jarClasspath'.
   > Failed to calculate the value of task ':compileJava' property 'javaCompiler'.
      > No compatible toolchains found for request filter: {languageVersion=15, vendor=matching('Zulu'), implementation=vendor-specific} (auto-detect true, auto-download true)

If I remove the vendor = JvmVendorSpec.matching("Zulu") part it works (and picks that JDK anyway).

Why is Gradle printing a vendor name with gradle -q javaToolchains that can’t be used to match the vendor with JvmVendorSpec.matching(<name>)?

It turns out that java.vendor is “Azul Systems, Inc.” That is what I would expect the output of gradle -q javaToolchains to show, and it does in fact work when I change the build script to have vendor = JvmVendorSpec.matching("Azul")

Agreed, it is confusing.

Here is the mapping of the real vendors to their display names

You should be able to use this as well, which works for the known vendors and “sees through” the display name mapping:

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(15)
        vendor = JvmVendorSpec.AZUL

Thanks, that helps, However, I think it is a bug to list ‘Zulu’ as a ‘vendor’. That is the name of the product, not the vendor. Same with a few of the others. ‘Amazon’ is the vendor, ‘Amazon Corretto’ is the product for example. Though at least in that case picking ‘Amazon’ would get you a match.
Why would Gradle talk about matching the java.vendor system property and not use those values when listing JDKs? It’s purposely created confusion.

It would also help if there were links at Toolchains for JVM projects ( to the JavaDocs for JvmVendorSpec so we don’t have to dig so hard to find the known vendors. I even tried searching for JvmVendorSpec where it says “search the docs” at the top left of that page and no additional hits were found.

It’s also a shame that auto-download doesn’t work for Azul or Bellsoft JDKs. I like to use their JDKs that include JavaFX as it is just simpler to have the JavaFX modules included. Particularly since jmod packages are not available as a dependency, so it is a manual process to set up a build environment that can jlink a JRE that includes JavaFX.

I suggest you raise an issue(s) in github.