what is difference between target language version...
# community-support
e
what is difference between target language version and toolchain version? Does it mean toolchain set will ignore my global jdk and use the version from toolchain?
c
Unclear what “global jdk” means - there’s the JDK that Gradle itself is running with, and zero or more toolchain JDKs used for tasks. When using a toolchain it uses that specified version/vendor, ignoring the JDK that Gradle itself is using.
e
Thanks
v
Never use target version. If you want to compile with a newer JDK but target an older JDK, use the newer JDK as toolchain and set the
release
to the older JDK, or you easily end up with code compiled against change API that cannot run on the intended target version. But to answer the question, toolchain is the JDK that is used, target version is, what is given to
-target
e
That was my question
👌 1
So you saying even if I set target I can still have issues with the newer JDK
and safe is always use toolchain approach for release
v
If you use a new jdk and -target but no bootstrap classpath you compile against the API of the new jdk
So you get a result with food Java file version, but using API that does not exist in the old version or changed incompatibly
c
I personally don’t use tool chains, preferring to use the ‘release’ setting. Good write up here: https://jakewharton.com/gradle-toolchains-are-rarely-a-good-idea/. Others may prefer to compile with tool chains.
👍 1
v
If you use
--release
you also compile against the old API, in addition to what
-target
alone would have done
e
Thanks, I thought that target is not only bytecode but also API availability check
v
So either is a toolchain of your target version and be done, it if you insist on using a newer toolchain, use
release
, not *Compatibility
e
I saw the Jake's article yesterday
v
And I almost fully disagree with him :-)
🙌 1
It's a very one-side and opinionated post and most points are inho mostly irrelevant. 🤷‍♂️
1