Skip to content

AutoValue null annotations in Eclipse #1634

@frankbenoit

Description

@frankbenoit

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
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions