Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to enable null annotations on types?
How to enable null annotations on types? [message #1273325] Wed, 19 March 2014 22:23 Go to next message
Tom van den Bege is currently offline Tom van den BegeFriend
Messages: 9
Registered: July 2009
Junior Member
With the release of Eclipse's java 8 support, I understood that null annotations on types were possible, as described here.

I have installed JDK8, and the Java 8 feature patch for Eclipse Kepler.

I was expecting to be able to declare a list that does not allow nulls like this:

List<@NonNull String> nonulls;


However, the compiler tells me that "The annotation @NonNull is disallowed for this location" Sad

My project is configured to use compiler compliance level 1.8, and the org.eclipse.jdt.annotation jar is included in the class path.

What am I missing here?

Regards,
Tom

[Updated on: Thu, 20 March 2014 10:56]

Report message to a moderator

Re: How to enable null annotations on types? [message #1273698 is a reply to message #1273325] Thu, 20 March 2014 11:47 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5467
Registered: July 2009
Senior Member
You need to make sure that your project uses the 2.0 version of JDT
annotation! You have both installed with the feature patch.

Tom

On 19.03.14 15:23, Tom van den Bege wrote:
> With the release of Eclipse's java 8 support, I understood that null
> annotations on types were possible,
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=392099.
>
> I have installed JDK8, and the
> https://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_For_Kepler for
> Eclipse Kepler.
>
> I was expecting to be able to declare a list that does not allow nulls
> like this:
>
>
> List<@NonNull String> nonulls;
>
>
> However, the compiler tells me that "The annotation @Nullable is
> disallowed for this location" :(
>
> My project is configured to use compiler compliance level 1.8, and the
> org.eclipse.jdt.annotation jar is included in the class path.
>
> What am I missing here?
>
> Regards,
> Tom
Re: How to enable null annotations on types? [message #1273782 is a reply to message #1273698] Thu, 20 March 2014 14:34 Go to previous messageGo to next message
Tom van den Bege is currently offline Tom van den BegeFriend
Messages: 9
Registered: July 2009
Junior Member
I have added the annotations jar using Quick Fix, which allows you to automatically add the jar to the classpath. Maybe this is not the correct jar? Can you explain where I can find the correct jar?


Thanks a lot,
Tom
Re: How to enable null annotations on types? [message #1273795 is a reply to message #1273782] Thu, 20 March 2014 14:53 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5467
Registered: July 2009
Senior Member
Should be at the same location but with version number 2.0.0

Tom

On 20.03.14 07:34, Tom van den Berge wrote:
> I have added the annotations jar using Quick Fix, which allows you to
> automatically add the jar to the classpath. Maybe this is not the
> correct jar? Can you explain where I can find the correct jar?
>
>
> Thanks a lot,
> Tom
Re: How to enable null annotations on types? [message #1273950 is a reply to message #1273795] Thu, 20 March 2014 19:54 Go to previous messageGo to next message
Tom van den Bege is currently offline Tom van den BegeFriend
Messages: 9
Registered: July 2009
Junior Member
Great, that works!

For anyone having similar problems:

Don't use Quick Fix to add the annotations jar to your build path, but manually copy it from your Eclipse installation. It is located in the 'plugins' directory: org.eclipse.jdt.annotation_2.0.0.v20140317-1808.jar

Thanks,
Tom
Re: How to enable null annotations on types? [message #1273965 is a reply to message #1273950] Thu, 20 March 2014 20:15 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5467
Registered: July 2009
Senior Member
I guess a bug should be filed against JDT to add the correct annoation
if the project is on Java8 compilance level!

Tom

On 20.03.14 12:54, Tom van den Bege wrote:
> Great, that works!
>
> For anyone having similar problems:
>
> Don't use Quick Fix to add the annotations jar to your build path, but
> manually copy it from your Eclipse installation. It is located in the
> 'plugins' directory: org.eclipse.jdt.annotation_2.0.0.v20140317-1808.jar
>
> Thanks,
> Tom
Re: How to enable null annotations on types? [message #1274067 is a reply to message #1273950] Fri, 21 March 2014 00:11 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1035
Registered: July 2009
Senior Member
Don't use Quick Fix to add the annotations jar to your build path, but manually copy it from your Eclipse installation. It is located in the 'plugins' directory: org.eclipse.jdt.annotation_2.0.0.v20140317-1808.jar


The quick fix should indeed add the 2.0.0 lib to your project if the project is configured for Java 8.
If that doesn't happen its a bug.

If you have a few more details a bug in bugzilla would be appreciated.

Stephan
Previous Topic:JDK8 patch requires uninstalling Groovy, Grails, Spring Roo, AJDT
Next Topic:eclipse doesn't run with Java 7 update51
Goto Forum:
  


Current Time: Wed Nov 26 09:13:53 GMT 2014

Powered by FUDForum. Page generated in 0.02170 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software