Bug 579402 - [null][external] External annotations doesn't work when custom annotations are used
Summary: [null][external] External annotations doesn't work when custom annotations ar...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.23   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: 2022-03-24 05:54 EDT by Björn Michael CLA
Modified: 2024-05-07 11:59 EDT (History)
1 user (show)

See Also:


Attachments
Repro project (52.24 KB, application/x-zip-compressed)
2022-03-24 05:54 EDT, Björn Michael CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Michael CLA 2022-03-24 05:54:06 EDT
Created attachment 288282 [details]
Repro project

The attached project uses custom annotations from JSR-305 for Null analysis (Nullable: javax.annotation.Nullable, NonNull: javax.annotation.Nonnull, NonNullByDefault: ea.definitions.GoodByeNull).

E.g. annotated subclass of ColumnLabelProvider 
@GoodByeNull
public class MyColumnLabelProvider extends ColumnLabelProvider {
	@Override
	protected void initialize(ColumnViewer viewer, @Nullable ViewerColumn column) {
		...            
	}

	@Override
	public @Nullable String getText(Object element) {
		...
		return null;
	}

}
leads to following errors/warnings:

MyColumnLabelProvider
=====================
* Illegal redefinition of parameter viewer, inherited method from CellLabelProvider does not constrain this parameter
* Illegal redefinition of parameter element, inherited method from ColumnLabelProvider does not constrain this parameter

GoodByeNull
===========
* The nullness annotation 'Nonnull' is not applicable at this location

It seems the external annotations aren't applied to ColumnLabelProvider and CellLabelProvider resp.
When annotations from org.eclipse.jdt.annotation package are used then errors disappear.
Comment 1 Adam Gent CLA 2022-05-17 11:24:34 EDT
A long time ago I had similar problems and I recall Stephen mentioning problems when using annotations that are NOT TYPE_USE like JSR 305.

That is the default annotations (not the extra ones) need to be TYPE_USE.

Try using TYPE_USE ones like checker, jspecify, eclipse's or intellij's newer annotations.
Comment 2 Eclipse Genie CLA 2024-05-07 11:59:51 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.