ParallelStreams.kts:41:15: error: calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'
IntStream.range(0,10).parallel().forEach{a ->
^
Ok ... I'm not trying to compile for 1.6.
File > Project Structure > Project has project sdk 1.8 and language level 8.
File > Project Structure > Modules > Kotlin has target platform: JVM 1.8.
File > Project Structure > Facets > Kotlin has target platform: JVM 1.8.
File > Settings > Compiler > Kotlin Compiler has target jvm version 1.8.
My gradle build file ...
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.0'
}
group 'foo'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-script-runtime:1.3.0"
//networking
implementation 'com.mashape.unirest:unirest-java:1.4.9'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
I'm running out of places to check for 1.8.
And yes, I have tried invalidating the cache and restarting Intellij. It does nothing to resolve this issue.
Add sourceCompatibility and targetCompatibility for Java 1.8:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.0'
}
group 'foo'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
// Add compatibility
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-script-runtime:1.3.0"
//networking
implementation 'com.mashape.unirest:unirest-java:1.4.9'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
With .kts just use this:
tasks {
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}
// I am using latest dsl and gradle
val kotlinVersion = "1.3.30"
val gradleVersion = "5.4+"
Since compilation tasks are generated for all relevant configurations it is likely that just changing compileKotlin and compileTestKotlin isn't enough.
Try using task filtering to configure all KotlinCompile task instances:
tasks.withType(KotlinCompile) {
kotlinOptions.jvmTarget = "1.8"
}