mkodekar / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Improved nullability annotations #1812

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There are a number of distinct issues here, and it's not really fair of me to 
mark them all as duplicates. However, we've got at least 7 bugs filed, and in 
broad strokes, they come down to 3 basic points:

1. Annotate return types as @Nullable/@NonNull more consistently.
2. Follow the annotation interpretations used by different versions of Findbugs 
/ by Eclipse / by the Checker Framework.
3. Take advantage of more annotation and a more sophisticated type system 
(typically the Checker Framework). (Or, in some cases, introduce extra 
interfaces to Guava with different annotations on each.)

Kevin is likely to attempt to do some of (1), but we will never get it 100% 
unless we do (2) or (3), both of which look more difficult than we expect to 
take on soon.

Again, I apologize for the oversimplification of collapsing these all to one 
bug. I'm just trying to better capture the way we think of the situation, which 
is basically "annotation some return types, then give up for a while."

Original issue reported on code.google.com by cpov...@google.com on 21 Jul 2014 at 8:03

GoogleCodeExporter commented 9 years ago
Issue 1811 has been merged into this issue.

Original comment by cpov...@google.com on 21 Jul 2014 at 8:05

GoogleCodeExporter commented 9 years ago
Issue 1810 has been merged into this issue.

Original comment by cpov...@google.com on 21 Jul 2014 at 8:05

GoogleCodeExporter commented 9 years ago
Issue 1677 has been merged into this issue.

Original comment by cpov...@google.com on 21 Jul 2014 at 8:06

GoogleCodeExporter commented 9 years ago
Issue 1278 has been merged into this issue.

Original comment by cpov...@google.com on 21 Jul 2014 at 8:06

GoogleCodeExporter commented 9 years ago
Issue 1221 has been merged into this issue.

Original comment by cpov...@google.com on 21 Jul 2014 at 8:06

GoogleCodeExporter commented 9 years ago
Issue 920 has been merged into this issue.

Original comment by cpov...@google.com on 21 Jul 2014 at 8:06

GoogleCodeExporter commented 9 years ago
Issue 1279 has been merged into this issue.

Original comment by cpov...@google.com on 21 Jul 2014 at 8:06

GoogleCodeExporter commented 9 years ago
In our main Java application we drew a line in the sand to minimize null values 
in every class. This involved implementing the Null Object pattern in many 
cases but mostly being consistent with our annotations. 

We started by creating the missing package-level annotations 
FieldsAreNonnulByDefault and ReturnValuesAreNonnullByDefault and ensuring they 
are applied to every package along with ParametersAreNonnullByDefault. From 
there it was easy: apply CheckForNull whenever null is allowed. 

The beauty of this approach is that anyone reading the code knows what to 
expect in the absence of an annotation. If most elements allow null, create 
your own defaults, but I highly recommend using the same default for fields, 
parameters, and return values. Mixing defaults across the three will only cause 
confusion.

I would be happy to help out in this endeavor because I feel it would help lots 
of developers use this awesome library.

Original comment by dharkn...@gmail.com on 22 Jul 2014 at 1:36

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:08

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07