- By default any sort of Java reference is a platform type in Kotlin.
- Since Java does not allow for expressing type-safety, the null-checks for Java references are relaxed in Kotlin
- This affects Kotlin’s sought-after null-safety feature
- However, the null-checks can be made strict by adding the
-Xjsr305
compiler flag with thestrict
options
// build.gradle.kts
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
}
}