Community
Participate
Working Groups
Created attachment 278793 [details] Repro project The attached project has some @NonNull external annotations for java.util.Set. It also has a MySet implementation that does not explicitly comply with the external annotations. This results in a couple of errors expecting the explicit annotations. e.g the annotation iterator ()Ljava/util/Iterator<TE;>; ()L1java/util/Iterator<TE;>; and the code @Override public Iterator<T> iterator() { return Collections.emptyIterator(); } gives the error: "The return type is incompatible with '@NonNull Iterator<T>' returned from Set<T>.iterator() (mismatching null constraints)" Since external annotations are a non-standard Java overlay, it seems undesirable that a general purpose implementation such as MySet should have to use non-standard facilities. Rather the 'missing' annotations should provoke warning diagnistcs leaving the programmer free to provide the annotations or to suppress the warnings.
(2019-06M3) Even if annotations are applied, it does to appear to be possible to annotate @Override public <T2> T2[] toArray(T2[] a) { return Collections.emptySet().toArray(a); } consistent with the external annotation that a is non-null. A warning seems unavoidable.
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.