jspecify-nullness
Installation
SKILL.md
JSpecify Nullness (Java)
Quick start
- Add
org.jspecify:jspecify:1.0.0as a visible API dependency for Java libraries. - Prefer
@NullMarkedat package or class scope; add@Nullableonly wherenullis allowed. - Treat unannotated types outside
@NullMarkedas unspecified nullness, not non-null. - Decide generic bounds deliberately:
<T extends @Nullable Object>accepts nullable type arguments;<T>does not in a null-marked scope. - Keep
@Nullable/@NonNullin JSpecify-recognized type-use locations, especially for arrays, nested types, type arguments, and bounds. - Read
references/jspecify-nullness.mdbefore substantial annotation, migration, or tooling advice.
Workflow
- Confirm consumer constraints: nullness checker, Kotlin compiler behavior, and annotation processors.
- Add the JSpecify dependency without hiding it from downstream users.
- Annotate nullable types first, then add
@NullMarkedat class or package scope. - Fix generics: choose nullable/non-null bounds and annotate type-variable uses only when the use differs from the type argument.
- Compile examples for syntax, then run a JSpecify-aware nullness analyzer and fix findings before expanding scope.