robstoll
05/05/2020, 8:23 PMtargetCompatiblity in my build.gradle to be 8 but do not define kotlinOptions.jvmTarget to be 1.8, so it should be 1.6 per default, what is the compiler supposed to generate?
I am asking because I came across java.util.function.Consumer in the resulting byte code and this one was introduced in 1.8ilya.gorbunov
05/05/2020, 8:32 PMjvmTarget option value, so if it's 1.6, then the resulting bytecode will be compatible with JVM 1.6.
You can meet j.u.function.Consumer type in the compiled code, however, if you use JDK 1.8 or greater in the compile classpath and use API either from that JDK or other java dependencies that takes it as a parameter. The path to JDK can be overridden with jdkHome option.Shawn
05/06/2020, 12:05 AMsourceCompatibility and targetCompatibility come into play then? I’ve seen them in various build.gradle[.kts] files, but if kotlinc only cares about jvmTarget then how did we get these extraneous properties?ilya.gorbunov
05/06/2020, 4:20 AMrobstoll
05/06/2020, 6:04 AMj.u.function.Consumer directly and I can see it in my jar not in the jdk8 jarilya.gorbunov
05/06/2020, 6:05 AMrobstoll
05/06/2020, 6:09 AMrobstoll
05/06/2020, 6:15 AMrobstoll
05/06/2020, 6:16 AMrobstoll
05/06/2020, 6:16 AMrobstoll
05/06/2020, 6:16 AMrobstoll
05/06/2020, 6:17 AMrobstoll
05/06/2020, 6:18 AMjvmTarget is set somewhere to 1.8robstoll
05/06/2020, 6:32 AMafterEvaluate {
println("kotlin jvmTarget: " + compileKotlin.kotlinOptions.jvmTarget)
}
kotlin jvmTarget: 1.6Shall I file a bug?
ilya.gorbunov
05/06/2020, 6:42 AMforEachRemaining iterator member function is used instead of the imported extension ch.tutteli.kbox.forEachRemaining.ilya.gorbunov
05/06/2020, 6:45 AMjvmTarget option affects what bytecode version is produced by the compiler, not what subset of API is visible in the JDK. If you need your code being actually runnable on JVM 6, it makes sense to specify the path to JDK 6 to Kotlin compiler with the jdkHome compiler option.robstoll
05/06/2020, 6:54 AMilya.gorbunov
05/06/2020, 7:36 AMrobstoll
05/06/2020, 7:49 AMilya.gorbunov
05/06/2020, 8:59 PM