Community
Participate
Working Groups
From bug 367154 comment 1: > Is this case already captured in a bug? > > @NonNullByDefault > public class ShowNPE2 { > public Object foo(Object o1, final boolean b) { > o1 = null; // MISSING NPE warning > System.out.println(o1.toString()); > return null; // Correct warning > > } > } This test reveals an obvious omission inside AbstractMethodDeclaration.addParameternonNullAnnotation which can be easily fixed: update the tagBits of argument.binding. I should also add a test for the inverse: arg is nonnull from default, passed to a method requiring nonnull. Expecting this to fail currently, too.
Created attachment 208637 [details] tests & fix (In reply to comment #0) > This test reveals an obvious omission inside > AbstractMethodDeclaration.addParameternonNullAnnotation > which can be easily fixed: update the tagBits of argument.binding. The patch does this at the call site in MethodBinding.fillInDefaultNonNullness > I should also add a test for the inverse: > arg is nonnull from default, passed to a method requiring nonnull. > Expecting this to fail currently, too. Test has been added, my prediction was wrong, though: this case was already handled via AbstractMethodDeclaration.analyseArguments() (which uses MethodBinding.parameterNonNullness instead of tagBits). Aggressive tests are currently running.
(In reply to comment #1) > > I should also add a test for the inverse: > > arg is nonnull from default, passed to a method requiring nonnull. > > Expecting this to fail currently, too. > > Test has been added, my prediction was wrong, though: this case was > already handled via AbstractMethodDeclaration.analyseArguments() > (which uses MethodBinding.parameterNonNullness instead of tagBits). Yes, we'd already tested this particular case.
Released for 3.8 M5 via commit 3a3faf3d0aa82cf2ed2b8375e651ef0b429b1314
Verified for 3.8 M5 using build id: I20120122-2000