migrator / guava-libraries-2

Guava: Google Core Libraries for Java 1.6+
0 stars 0 forks source link

Improved nullability annotations #14

Open migrator opened 9 years ago

migrator 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."

relevance: 48

migrator commented 9 years ago

summary: Not Defined Issue 1811 has been merged into this issue.

status Not Defined creator: cpov...@google.com created at: Jul 21, 2014

migrator commented 9 years ago

summary: Not Defined Issue 1810 has been merged into this issue.

status Not Defined creator: cpov...@google.com created at: Jul 21, 2014

migrator commented 9 years ago

summary: Not Defined Issue 1677 has been merged into this issue.

status Not Defined creator: cpov...@google.com created at: Jul 21, 2014

migrator commented 9 years ago

summary: Not Defined Issue 1278 has been merged into this issue.

status Not Defined creator: cpov...@google.com created at: Jul 21, 2014

migrator commented 9 years ago

summary: Not Defined Issue 1221 has been merged into this issue.

status Not Defined creator: cpov...@google.com created at: Jul 21, 2014

migrator commented 9 years ago

summary: Not Defined Issue 920 has been merged into this issue.

status Not Defined creator: cpov...@google.com created at: Jul 21, 2014

migrator commented 9 years ago

summary: Not Defined Issue 1279 has been merged into this issue.

status Not Defined creator: cpov...@google.com created at: Jul 21, 2014

migrator commented 9 years ago

summary: Not Defined

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.

status Not Defined creator: dharkn...@gmail.com created at: Jul 21, 2014

migrator commented 9 years ago

Past Events: action:mentioned user: kevinb@google.com at: null referenced issue: null