Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 366327

Summary: Guess available NonNull annotations
Product: [Eclipse Project] JDT Reporter: Andrey Loskutov <loskutov>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: REOPENED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: christoph, jarthana, stephan.herrmann
Version: 3.8Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
my project settings none

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
.