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

Bug 366326

Summary: Buildpath problem: type org.eclipse.jdt.annotation.NonNull cannot be resolved
Product: [Eclipse Project] JDT Reporter: Andrey Loskutov <loskutov>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, srikanth_sankaran, stephan.herrmann
Version: 3.8   
Target Milestone: 3.8 M5   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
my project settings none

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