I’m looking at warnings from null analysis and I found some cases that are difficult to manage.
For example in the attached code where are fields are @NonNull
JDT is not capable to detect that Map.getOrDefault can’t return a null value and it gives a warning.
And if I remove the @Nullable from the map then the second method complains about the else if is dead code because can’t be true.
How do you proceed in these cases? Just put a @SuppressWarnings(“null”) is fine?
I suppose that I can introduce a getOrDefault method in my class to get ride of the warning, but it seems an antipattern for me to create more code to solve limitations of the static null analysis.