Bug 366327 - Guess available NonNull annotations
Summary: Guess available NonNull annotations
Status: REOPENED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2011-12-11 05:37 EST by Andrey Loskutov CLA
Modified: 2020-06-10 03:35 EDT (History)
3 users (show)

See Also:


Attachments
my project settings (26.83 KB, application/octet-stream)
2011-12-11 05:37 EST, Andrey Loskutov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2011-12-11 05:37:47 EST
Created attachment 208221 [details]
my project settings

After configuring a project to use NPE annotations, the *default* "org.eclipse.jdt.annotation.*" types are always proposed, even if the project already uses other annotation types like those from JSR-305 (javax.annotation.NonNull etc). This leads to the bug 366326 (Buildpath problem: the type org.eclipse.jdt.annotation.NonNull cannot be resolved)

This should be avoided - a quick query if some well known types are on the project classpath could be done before proposing jdt annotation types.
In case there are known annotations available, those should be used in the preference page as default.
Comment 1 pascal christoph CLA 2015-10-08 09:54:04 EDT
This Bug is still active. Using java8 features like using a stream and converting that into a string array:

 (new ArrayList<>()).stream().toArray(String[]::new);

The workaround I use is to disable the "annotation-based null analysis" in project->properties->java-compiler...
Comment 2 Stephan Herrmann CLA 2015-10-09 02:42:44 EDT
(In reply to pascal christoph from comment #1)
> This Bug is still active. Using java8 features like using a stream and
> converting that into a string array:
> 
>  (new ArrayList<>()).stream().toArray(String[]::new);
> 
> The workaround I use is to disable the "annotation-based null analysis" in
> project->properties->java-compiler...

How does this relate to the selection of annotation types (JDT vs. FindBugs etc.)?

Perhaps you intended to drop this comment in another bug? :)

Also, I'm not even sure what bug you are seeing regarding your example.
Comment 3 Stephan Herrmann CLA 2015-10-09 02:44:44 EDT
I think this needs to be implemented in JDT/UI as part of the preference dialog.
Comment 4 pascal christoph CLA 2015-10-09 03:25:54 EDT
@stephan I copied the report to bug 366014.
Comment 5 Stephan Herrmann CLA 2015-10-09 03:47:24 EDT
(In reply to pascal christoph from comment #4)
> @stephan I copied the report to bug 366014.

And after seeing the error message I filed bug 479389 :)
Comment 6 Stephan Herrmann CLA 2020-06-10 03:35:24 EDT
.