Aren’t calls to Java APIs automatically nullable? ...
# announcements
p
Aren’t calls to Java APIs automatically nullable? Have I just discovered a bug?
Copy code
// automatically non-null
val handler = Thread.getDefaultUncaughtExceptionHandler()
// no warning, everything compiles, crashes at runtime
handler.uncaughtException(thread, throwable)

// alt + enter -> "specify type explicitly" suggests nullable type
val handler: Thread.UncaughtExceptionHandler? = Thread.getDefaultUncaughtExceptionHandler()
// Error: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Thread.UncaughtExceptionHandler?
handler.uncaughtException(thread, throwable)