Use J.Literal.isLiteralValue(expression, null)

MSAL

Replace expression instanceof J.Literal && ((J.Literal) expression).getValue() == null with J.Literal.isLiteralValue(expression, null).

org.openrewrite.java.recipes.IsLiteralNullRecipe
mod run . --recipe=org.openrewrite.java.recipes.IsLiteralNullRecipe

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.