Community
Participate
Working Groups
In the following example in which the toString() method is coded to avoid a crash if invoked prematurely by the debugger during construction: package bug; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; public class NonNullBug { protected final @NonNull String s; public NonNullBug(@NonNull String s) { this.s = s; } @Override public String toString() { @Nullable String s2 = s; return s2 != null ? s2.toString() : super.toString(); } } JDT gives: Redundant null check: The variable s2 cannot be null at this location on the return line. This is incorrrct because the user has declared that s2 can be null. Rather there should be a warning on the s2 = s declaration that s2 cannot be null providing an opportunity for the user to apply a suppress null warning annotation to allow the above code to function as intended without any warnings.
Use org.eclipse.jdt.annotation.Checks.isNull(Object)
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
The original problem has not been addressed by comment #1. Rather a suggestion to code differently is given. Alternative code will indeed often avoid a bug, but the bug still needs to be addressed. The suggested alternative has stronger org.eclipse.jdt.annotation dependency, requiring a mandatory rather than optional bundle.