https://kotlinlang.org logo
#getting-started
Title
# getting-started
i

iari

02/02/2022, 11:08 AM
Was stuff in
kotlin.io.path
removed in 1.6 ? These do not work anymore for me:
Path.readBytes()
Path.absolutePathString()
Path.writeBytes(ByteArray)
I can't find hints about it in changelogs
b

Bart Kleijngeld

02/02/2022, 11:11 AM
I think you mean to import this one instead:
Copy code
import java.nio.file.Path
Also, as I understand it it's a method on the instance, so you can't import
readBytes
like that, but should instantiate the
Path(...)
first and call the method on that.
i

iari

02/02/2022, 11:14 AM
It worked in 1.5
these are extension methods
e

ephemient

02/02/2022, 11:14 AM
Bart, no. Paths is the static helper to access NIO paths, and readBytes is a Kotlin extension function
👍 2
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/ they should still be there, but perhaps your project is somehow not configured for Java 7+ target?
i

iari

02/02/2022, 11:15 AM
it was configured for java 8 before, now its java17
b

Bart Kleijngeld

02/02/2022, 11:17 AM
Ah, okay. Learned something myself then 🙂
e

ephemient

02/02/2022, 11:17 AM
what matters here is what Kotlin is targeting as that affects the default stdlib artifact it pulls in, unless you explicitly disable that or add a stdlib dependency yourself
i

iari

02/02/2022, 11:26 AM
Copy code
compileKotlin {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "17"
    }

    dependsOn(compileSass.get())
}
Kotlin does target 17
also this is part of the gradle
Copy code
java.sourceCompatibility = JavaVersion.VERSION_17
And @ephemient I doubt this has to do with it, I never get something like
Unknown JVM target version
k

Klitos Kyriacou

02/02/2022, 12:27 PM
It works on my machine (with IDEA 2021.3.2, Kotlin 1.6.10 and Java 17). Try invalidating caches and restarting.
6 Views