Wrap nullable thrown expressions in requireNonNull
ProprietaryWraps a provably-nullable throw operand in java.util.Objects.requireNonNull(...) (statically imported), turning throw ex; into throw requireNonNull(ex);. A throw of a null Throwable itself throws NullPointerException (the JVM dereferences the operand to raise it), so inside an annotated scope NullAway flags a nullable thrown value as an error; requireNonNull throws exactly where the bare throw already would, so runtime behavior is unchanged. The operand's nullness is resolved by attribution from the nullability model and a path-sensitive flow analysis (a value already null-checked on the path is not flagged). The fix never asserts non-null on a value that is genuinely nullable at the site. Idempotent and conservative; only Java sources are modified.
io. moderne. nullability. WrapNullableThrownExpressionInRequireNonNullOptional
Comma-separated package prefixes to limit the fix to (matching NullAway's AnnotatedPackages option). When unset, the recipe fixes all packages.
The non-null assertion form to emit at a wrap site. AUTO (the default) emits Preconditions.checkNotNull in a file that already imports Guava's Preconditions, otherwise Objects.requireNonNull. CAST_TO_NON_NULL is explicit-only (it is suppression-like — no runtime throw) and never auto-selected.
mod run . --recipe= io. moderne. nullability. WrapNullableThrownExpressionInRequireNonNullInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.