Hi, I am having a problem where users are having i...
# multiplatform
l
Hi, I am having a problem where users are having issues with using the inline functions in Kamel I think due to the fact that I built and published releases with java sdk 17. Is the only solution to downgrade to java sdk 1.8 on my machine for people to be able to universally use kamel on any jvm target? The relevant issue. https://github.com/Kamel-Media/Kamel/issues/53#issuecomment-1697839927
e
no, it should be fine if you explicitly specify jvmTarget
👍 1
any value ≤ the toolchain in use should work
m
Could it be that you are hit by this error: https://youtrack.jetbrains.com/issue/KTIJ-20816/Bogus-error-Cannot-inline-bytecode-built-with-JVM-target-11-into-bytecode-that-is-being-built-with-JVM-target-1.8. I have the same problem with some external library which is causing this issue and and as a temporary fix I add this line
Copy code
@file:Suppress("INLINE_FROM_HIGHER_PLATFORM") // Remove once KTIJ-20816 is fixed.
at the top of each affected file.
e
(well, and ≥ 1.6 or 1.8)
as a library producer you should generally set as low of a target as reasonably possible to allow use by the most consumers
👍 2
you'd have the same issue with plain old Java too
l
@ephemient thanks for the advice. Another question what’s the difference between setting the jvmTarget vs the new option to set a jvm toolchain?
s
Someone please correct me because I might be wrong. As far as I understand the JVM toolchain specifies the JDK version and flavour of JDK to be used to build the project. Let's say you have OpenJDK 17 installed but you need to use OpenJDK 11 to compile the project, you can specify that on the JVM toolchain configuration and the kotlin gradle plugin will download and use the OpenJDK 11 to compile/run a task. But the jvmTarget specifies the version of the generated JVM bytecode during compilation. Again I might be wrong, but I think any higher version of JDK can generate bytecode compatible with any lower version. You can use jdk17 and you can generate bytecode for Java 11 or 1.8.
e
but yeah you're partly correct
Kotlin doesn't have Java's source compatibility version, but instead has Kotlin language version and Kotlin API version, plus the same bytecode target version and then the behavioral differences between JVM versions
for example, https://youtrack.jetbrains.com/issue/KTOR-3358 is an example where compiling with a newer JDK results in different behavior (failure to link) on older JVMs, even if the bytecode target is older, because the standard classpath has changed
that can be solved with `javac -release`/`kotlinc -Xjdk-release`, or using an older JDK to begin with
l
Got it, thanks for the info 🙏