Hi all,

I like us using @Nullable as documentation.

It's a great added bonus to get build-time warnings of null-related errors. The question is which annotation will give the most support for IDEs and third party tools to do code analysis. Our org.jclouds.javax.annotation.Nullable is not understood by Eclipse, Intellij or FindBugs so +1 for replacing it.

There are way too many options out there [1]. I haven't tried antlr4 so would also appreciate a summary of why it's better than the other options.

Following Andrew Gaul's point, I'm not convinced about adding @NonNull all over the place. Most of our code is guaranteed to not return null. e.g. guava did not choose to use @NonNull on ImmutableList.of() or on Iterables.find(...)!

Guava chose to use javax.annotation.Nullable (though JSR-305 is now inactive).
That has good support in IDEs and tools like FindBugs.

Ignasi, for the Java 8 reference [2] it hasn't added @Nullable etc. It just added JSR-308 [3] to improve support for being able to use annotations in more places. The Check Framework that it links to adds yet another annotation: org.checkerframework.checker.nullness.qual.Nullable [4].

Aled

[1] http://stackoverflow.com/questions/4963300/which-notnull-java-annotation-should-i-use
[2] https://blogs.oracle.com/java-platform-group/entry/java_8_s_new_type
[3] http://types.cs.washington.edu/jsr308/
[4] http://types.cs.washington.edu/checker-framework/current/api/org/checkerframework/checker/nullness/qual/Nullable.html


On 11/08/2014 14:30, Zack Shoylev wrote:
Here are some questions then:

Should we better document @Nullable? 
https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/javax/annotation/Nullable.java

What jclouds annotation, if any, should we use to indicate a parameter or 
return type cannot be null?
________________________________________
From: Andrew Gaul [g...@apache.org]
Sent: Saturday, August 09, 2014 3:17 PM
To: dev@jclouds.apache.org
Subject: Re: antlr4 Annotation Processor

On Fri, Aug 08, 2014 at 04:57:41PM +0000, Jeremy Daggett wrote:
Several of us have chatted about using the antlr4 annotation processor [1] for 
@Nullable [2] and @NotNull [3] as a replacement for the jclouds @Nullable 
annotation [4]. The annotation we use now is essentially just a hint that 
something could be null.

This would require a additional 10k dependency on "antlr4-annotations-4.3.jar”. 
How does the community feel about using these compile time annotations for 2.0?
What problem does this solve?  Generally I believe that the complexity
of magical annotations discourages potential contributors more than it
increases code quality, so we should have a compelling reason to take
this dependency.

--
Andrew Gaul
http://gaul.org/

Reply via email to