I can see that @Nullable
and @Nonnull
annotations could be helpful in preventing NullPointerException
s but they do not propag
What I do in my projects is to activate the following option in the "Constant conditions & exceptions" code inspection:
Suggest @Nullable annotation for methods that may possibly return null and report nullable values passed to non-annotated parameters
When activated, all non-annotated parameters will be treated as non-null and thus you will also see a warning on your indirect call:
clazz.indirectPathToA(null);
For even stronger checks the Checker Framework may be a good choice (see this nice tutorial.
Note: I have not used that yet and there may be problems with the Jack compiler: see this bugreport