The most of java library don't have the nullable annotations so the kotlin compilator can't throw error with a possible null.
Will be interesting can add manually the annotations in our project as the extension methods.
When you make the definition, the compiler throw error if you don't check the null
val a = LibraryClass()
val b = a.fooMethod() //compilation error