if (x.f != null) {
System.out.println(x.f.toString());
}
Apparently NullAway infers that x.f cannot be null inside the branch, so calling x.f.toString() is safe. However, strictly speaking, since field f is not final, it is possible that a different thread would modify it between the test and the call, resulting in a NullPointerException. Have you decided to just ignore such effects of multi-threading?
Hi, good point! Yes, we are deliberately ignoring multithreading, among many other things. We were aiming to catch the NPEs we see most often in practice while keeping the type system relatively simple. Based on our data from the field, I think NPEs due to multithreading and code like the example are fairly rare.