Hi, i know kotlin is a null safe language, but jvm has recently (JDK14) added Helpful NPE (for NullPointer exceptions thrown by JVM https://openjdk.java.net/jeps/358) which will describe precisely which variable is null. Can we get the same message in the NPE thrown by kotlin compiler in the following scenario?
suresh
10/21/2021, 4:54 PM
Copy code
fun main() {
println(Customer().address!!.country!!.name)
}
data class Customer(val address: Address? = null) {
inner class Address(val country: Country? = null)
inner class Country(val name: String)
}
suresh
10/21/2021, 4:56 PM
Kotlin stacktrace
Copy code
Exception in thread "main" java.lang.NullPointerException
at dev.suresh.misc.HelpfulNPE.run(HelpfulNPE.kt:7)
JDK 17 stacktrace
Copy code
java.lang.NullPointerException: Cannot read field "name" because "address.country" is null
at dev.suresh.npe.HelpfulNPE.main(HelpfulNPE.java:7)