Bug 547825 - External annotation impositions on derived classes are errors rather than warnings
Summary: External annotation impositions on derived classes are errors rather than war...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.10   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-31 10:47 EDT by Ed Willink CLA
Modified: 2023-05-16 19:02 EDT (History)
0 users

See Also:


Attachments
Repro project (6.36 KB, application/x-zip-compressed)
2019-05-31 10:47 EDT, Ed Willink CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2019-05-31 10:47:47 EDT
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.
Comment 1 Ed Willink CLA 2019-05-31 10:54:55 EDT
(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.
Comment 2 Eclipse Genie CLA 2021-05-21 11:32:59 EDT
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.
Comment 3 Eclipse Genie CLA 2023-05-16 19:02:52 EDT
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.