Community
Participate
Working Groups
In the following example: package confusing; import java.util.ArrayList; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; public abstract class Confusing { abstract int unannotated(ArrayList<String> list); @NonNullByDefault public void f(boolean x) { ArrayList<String> list = x ? null : new ArrayList<>(); while (true) { unannotated(list); } } } A bogus message is reported for the list argument in the unannotated(list)-invocation: Null type mismatch: required '@NonNull ArrayList<String>' but the provided value is inferred as @Nullable If "while" is replace by "if" the correct problem is reported: Unsafe null type conversion (type annotations): The value of type 'ArrayList<@NonNull String>' is made accessible using the less-annotated type 'ArrayList<String>'
This is a recent regression, scheduling for RC1.
New Gerrit change created: https://git.eclipse.org/r/158118
(In reply to Eclipse Genie from comment #2) > New Gerrit change created: https://git.eclipse.org/r/158118 Some explanations to facilitate reviewing: 1. Deferred checking via LoopingFlowContext did not yet handle the new NullAnnotationMatching.Severity.UNCHECKED_TO_UNANNOTATED. To do so, the NullAnnotationMatching status is now propagated through this chain: FlowContext.internalRecordNullityMismatch() FlowContext.recordNullReference() LoopingFlowContext#nullAnnotationStatuses LoopingFlowContext#complainOnDeferredNullChecks() ProblemReporter.nullityMismatchingTypeAnnotation() This fairly mechanical change fixes the regression. 1.a: to make rerouted problems conform to old behavior, the *FlowContext needs to update NAM.nullStatus, which is known only during complainOnDeferredNullChecks(). 2. The same was needed for FinallyFlowContext, as demonstrated by the 2nd added test. 3. The above caused an undesired change of error message in NTAT.testBug466556Loops(): since we now route error reporting through nullityMismatchingTypeAnnotation() we lost the message about free type variable. Fixed in the ProblemReporter. 4. Item (3) caused a "collateral improvement": a better message is now also given for NTAT.testBug466562, test expectation has been adjusted.
Manoj, Jay, Till: This regression fix needs a code review and +1 from a project lead. Would be great if one of you finds the time for RC1, who will it be? :) See comment 3 for some explanations.
Thanks, Till for the review. @Manoj, @Jay, all we need now is +1 from a project lead :)
Gerrit change https://git.eclipse.org/r/158118 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=f451606a372bf23d021449d82dc3e2fdc2c7b68f
(In reply to Stephan Herrmann from comment #5) > Thanks, Till for the review. > > @Manoj, @Jay, all we need now is +1 from a project lead :) Done and submitted. Thanks Stephan!
(In reply to Manoj Palat from comment #7) > (In reply to Stephan Herrmann from comment #5) > > Thanks, Till for the review. > > > > @Manoj, @Jay, all we need now is +1 from a project lead :) > > Done and submitted. Thanks Stephan! thanks