google / google/auto

AutoValue null annotations in Eclipse

Open
#1,634 2 comments 0 reactions 0 assignees View on GitHub
Component: value P3
Dominant language
Java
Stars
10.6k
Forks
1.2k
Avg merge
6h 32m
Merged PRs (30d)
13

Description

Hi,

in Eclipse there is a setting to ignore optional compile errors, that can be configured for the generated sources.
In my projects those are always on, because AutoValue generates problems.

What cause the problems:
See the attached example...
[AutoValueNNBD.zip](https://github.com/google/auto/files/13327678/AutoValueNNBD.zip)
In this minimal example class, the generated code has 4 errors and 5 warnings.

In Eclipse (JDT) there are 3 null annotations: `@NonNull`, `@Nullable` and `@NonNullByDefault`
The `@NonNullByDefault` can be put onto field/method/class or event the package. Like in this example I have put it into the package-info.java.

In the example, I created a `AutoValue_KeyValueProposal.java`, to illustrate how it should look like from my POV to make it compile error free.

1. Local variable instead of accessing the field twice for null-check then use
2. All builder field to be `@Nullable`
3. No `@NonNull` ever if the `@NonNullByDefault` is active

regards
Frank

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.