File: NullablePrimitiveArray.md

package info (click to toggle)
error-prone-java 2.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 23,204 kB
  • sloc: java: 222,992; xml: 1,319; sh: 25; makefile: 7
file content (13 lines) | stat: -rw-r--r-- 738 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
For `@Nullable` type annotations (such as
`org.checkerframework.checker.nullness.qual.Nullable`), `@Nullable byte[]` means
a 'non-null array of nullable bytes', and `byte @Nullable []` means a 'nullable
array of non-null bytes'. Since primitive types cannot be null, the former is
incorrect.

Some other nullness annotations (such as `javax.annotation.Nullable`) are
_declaration_ annotations rather than _type_ annotations. Their meaning is
different: For such annotations, `@Nullable byte[]` refers to 'a nullable array
of non-null bytes,' and `byte @Nullable []` is rejected by javac. Thus, this
check never reports errors for usages of declaration annotations.

See also: https://checkerframework.org/manual/#faq-array-syntax-meaning