Why jvmTarget attribute doesn't work?


#1

A Gradle project. Kotlin version is 1.1.51.
From the guide: Bytecode version is defined by jvmTarget, and jvmTarget default value is 1.6. so the bytecode default value should be 50. right?
My JDK is 1.8, and I don’t define jvmTarget value(I also try to define jvmTarget is “1.6”). but I always get bytecode version is 52. (my command is javap -verbose xxx.class).
What is the true meaning of jvmTarget?
How to generate class which is compiled using jdk1.8 and run in jdk1.6?


#2

Bytecode version is defined by jvmTarget, and jvmTarget default value is 1.6. so the bytecode default value should be 50. right?

Right, that’s how it should be.

If you observe different behavior, please provide a simplified project where it happens and we’ll investigate.


#3

sorry, I am wrong.
The class file is compiled by IDE, instead of Gradle, so I get wrong bytecode version.
After I perform gradle build, the bytecode version is 50.