IntelliJ's nullity analysis is useful, but limited. It has weak handling for maps.
If you wish to obtain guarantees about code that uses maps, you could use the Nullness Checker, which includes a map key analysis.
It isn't built into IntelliJ, but you can integrate it with IntelliJ or run it as a separate tool.
Given this code:
import java.util.HashMap;
import java.util.Map;
public class MapGetTest {
void m() {
Map<String, String> simpleMap = new HashMap<>();
String thisWillBeNull = simpleMap.get("key");
int l = thisWillBeNull.length();
}
}
You can run this command:
javac -processor nullness MapGetTest.java
and the result is:
MapGetTest.java:8: error: [dereference.of.nullable] dereference of possibly-null reference thisWillBeNull
int l = thisWillBeNull.length();
^
1 error