GoogleCloudPlatform / GoogleCloudPlatform/google-cloud-eclipse

Investigate using null analysis via annotations

Open
#430 7 comments 0 reactions 0 assignees View on GitHub
cleanup priority: p4
Dominant language
Java
Stars
90
Forks
52
PR merge metrics
No merged PRs in 30d

Description

JDT supports using JSR305-like annotations for indicating whether methods and field can return or hold `null` values.
- [Eclipse Help: Using Null Annotations](http://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.user/tasks/task-using_null_annotations.htm?cp=1_3_9_0)

We can use FindBugs/JSR305-style `javax.annotation.Nullable` and `Nonnull` annotations and/or the Eclipse JDT equivalents `org.eclipse.jdt.annotations.Nullable`, and `NonNull`. JDT supports specifying multiple annotations so we could mix both (or use libraries using either).

The JSR305-style annotations:
- 👍 FindBugs will use them too
- 👎 [imperfect match to Eclipse JDT null analysis](https://sourceforge.net/p/findbugs/bugs/1355/)

JDT annotations:
- 👍 @NonNullByDefault covers method return values too
- 👍 under Java 8, supports [annotating type uses](http://help.eclipse.org/mars/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/task-using_null_type_annotations.htm), which allows things like `int processWithoutNulls (@NonNull List<@NonNull Integer> ints)` to guarantee that `null` won't be present in `ints`
- 👍 👎 Unsure if we can configure FindBugs to use these annotations though [it seems some are using them](https://sourceforge.net/p/findbugs/bugs/1425/)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.