Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366326 - Buildpath problem: type org.eclipse.jdt.annotation.NonNull cannot be resolved
Summary: Buildpath problem: type org.eclipse.jdt.annotation.NonNull cannot be resolved
Status: VERIFIED DUPLICATE of bug 366014
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.8 M5   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-11 05:14 EST by Andrey Loskutov CLA
Modified: 2012-01-23 01:00 EST (History)
3 users (show)

See Also:


Attachments
my project settings (26.83 KB, application/octet-stream)
2011-12-11 05:14 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:14:55 EST
Created attachment 208220 [details]
my project settings

After configuring a project to use NPE annotations, and using the *default* proposed "org.eclipse.jdt.annotation.*" types, a compilation error appears:

Buildpath problem: the type org.eclipse.jdt.annotation.NonNull, which is configured as a null annotation type, cannot be resolved

This should be avoided - either warn user that project does NOT have proposed jdt annotation types in the classpath (and discard the setting), or (better) ask and (if user agrees) automatically configure the project classpath by adding the missing library. 

[dream] As a non-plus-ultra feature, for a *plugin* project with enabled NPE options, add a new "org.eclipse.jdt.annotations" plugin to the workspace which would just contain the libraries, and add dependency to the MANIFEST.MF instead of adding project dependency via .classpath.

Right now by enabling NPE "default" settings for a project will always lead to compile error in Eclipse.
Comment 1 Stephan Herrmann CLA 2011-12-11 14:38:29 EST
Thanks for your suggestion. This is already being planned :)

*** This bug has been marked as a duplicate of bug 366014 ***
Comment 2 Stephan Herrmann CLA 2011-12-11 15:05:48 EST
(In reply to comment #0)
> [dream] As a non-plus-ultra feature, for a *plugin* project with enabled NPE
> options, add a new "org.eclipse.jdt.annotations" plugin to the workspace which
> would just contain the libraries, and add dependency to the MANIFEST.MF instead
> of adding project dependency via .classpath.

Some more bits of info:

The New&Noteworthy mention:
> In addition to enabling the null analysis, the annotations need to be on the
> Java build path of your project. The default annotations can be found in the
> org.eclipse.jdt.annotation JAR in the plugins directory, which can be
> consumed as an OSGi bundle or plain JAR."

This means using M4 you can already use the Require-Bundle you suggest,
but as Markus suggests in bug 366014:
> But for PDE, we should only add it as compile-time dependency
> ("additional.bundles = org.eclipse.jdt.annotation" in build.properties),
> not as OSGi Require-Bundle."

HTH