Skip to content

Proposal: Switch to a provided JSR305 artifact for nullability + package annotations #5341

Closed
@ZacSweers

Description

@ZacSweers

I'd like to propose switching away from the current custom @Nullable and @NonNull annotations and using a combination of a provided JSR305 dependency (that is, only compileOnly and not actually packaged, but still visible to static analysis tools).

This would provide two main benefits:

  • Use of a standard @Nullable annotation (Guava uses the same one). Currently anyone that uses other annotations gets burdened with fully-qualified copies of RxJava's due to IDE autocomplete, and it's a nuisance to clean it up.
  • Use of package-level annotations to make the default for everything @NonNull. You could use @ParametersAreNonnullByDefault for just parameters, or also have a separate artifact with a custom @EverythingIsNonNullByDefault annotation like here that would also cover fields and return types. This would obviate the need for using @NonNull entirely, and is respected by most conventional static analysis tools.
  • Potential improvements for interoperability with (Rx)Kotlin - https://youtrack.jetbrains.com/issue/KT-10942

I know RxJava prefers to have no dependencies, but I think that having this as a provided dependency is a good middle ground for the value it provides.

Other prior reading:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions