I can compile the following code which at runtime ...
# getting-started
b
I can compile the following code which at runtime will always end up with an NPE (getTransition returns null)
Copy code
@Test
    fun reproducibleNPE() {
        ZoneId.of("Europe/Berlin").rules.getTransition(LocalDateTime.MIN).isOverlap
    }
Looks like I can't trust Java platform calls. But what are the rules? When can I trust it?
m
This is explained in https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types In your case, looking at the Javadoc: • https://docs.oracle.com/javase/8/docs/api/java/time/ZoneId.html#getRules-- specifies that the return value is never null, so you can access this safely with .https://docs.oracle.com/javase/8/docs/api/java/time/zone/ZoneRules.html#getTransition-java.time.LocalDateTime- specifies that the returned value might be null, so you have to access this using ?.
b
Thank you