Skip to content

Promote @ElementTypesAreNonnullByDefault to the package level, replacing @ParametersAreNonnullByDefault. - #7566

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_707958845
Dec 20, 2024
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_707958845

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Promote @ElementTypesAreNonnullByDefault to the package level, replacing @ParametersAreNonnullByDefault.

We've annotated individual classes that haven't been annotated for nullness as @NullUnmarked. That will likely take precedence over @ElementTypesAreNonnullByDefault. Even if it does not, it will take precedence over @NullMarked, to which we will be migrating soon.

I normally recommend annotating individual classes with @NullMarked, rather than packages. However, because Guava supports Java 8, and because users sometimes use reflection to inspect arbitrary annotations on Guava's classed (such as by using Mockito to mock them), there is some danger in annotating individual classes with @NullMarked, whose @Target includes MODULE, which isn't available under Java 8.

RELNOTES=n/a

…acing `@ParametersAreNonnullByDefault`.

We've annotated individual classes that haven't been annotated for nullness as `@NullUnmarked`. That will likely take precedence over `@ElementTypesAreNonnullByDefault`. Even if it does not, it will take precedence over `@NullMarked`, to which we will be migrating soon.

I normally recommend annotating individual classes with `@NullMarked`, rather than packages. However, because Guava supports Java 8, and because users sometimes use reflection to inspect arbitrary annotations on Guava's classed (such as by using Mockito to mock them), there is some [danger](https://github.com/jspecify/jspecify/wiki/version-compatibility#runtime) in annotating individual classes with `@NullMarked`, whose [`@Target` includes `MODULE`](https://jspecify.dev/docs/api/org/jspecify/annotations/NullMarked.html), which isn't available under Java 8.

RELNOTES=n/a
PiperOrigin-RevId: 708300606
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant