From ca7ca24549d85b3fe21f54102089cb71bf324457 Mon Sep 17 00:00:00 2001 From: Magnus Smith Date: Wed, 18 Dec 2024 13:20:05 +0000 Subject: [PATCH] feedback changes --- .../2024-17-10-taming-nullness-in-java-with-jspecify.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/_posts/2024-17-10-taming-nullness-in-java-with-jspecify.md b/_posts/2024-17-10-taming-nullness-in-java-with-jspecify.md index e3e621afb..d12b2f071 100644 --- a/_posts/2024-17-10-taming-nullness-in-java-with-jspecify.md +++ b/_posts/2024-17-10-taming-nullness-in-java-with-jspecify.md @@ -11,8 +11,6 @@ summary: This post is designed for Java developers who want to adopt JSpecify fo image: magnussmith/assets/containers.jpg --- -# Using JSpecify to Tame Nulls in Java - ## Introduction @@ -28,7 +26,7 @@ JSpecify introduces four key annotations to express nullness: - `@Nullable`: Indicates that a variable, parameter, or return value can be null. - `@NonNull`: Indicates that a variable, parameter, or return value cannot be null. -- `@NullMarked`: Marks a package or class that you're annotating to indicate that the remaining unannotated type usages are not nullable.. This reduces the noise from annotation verbosity. +- `@NullMarked`: Marks a package or class that you're annotating to indicate that the remaining unannotated type usages are not nullable. This reduces the noise from annotation verbosity. - `@NullUnmarked`: Explicitly marks a package or class as not using JSpecify's nullness annotations as the default. This is used for exceptions to `@NullMarked` packages. The goal is to allow for more predictable null handling, minimizing the need for runtime null checks and making nullness explicitly part of the contract of methods and fields. @@ -154,6 +152,7 @@ You can place `@NullMarked` or `@NullUnmarked` in a package-info.java file to af ~~~ All classes in the `com.example.myapp` package will now assume non nullable types by default unless explicitly overridden. + ### At the Module Level If your project is modularized, you can also use these annotations at the module level by adding `@NullMarked` or `@NullUnmarked` to the `module-info.java` file. @@ -168,9 +167,9 @@ If your project is modularized, you can also use these annotations at the module } ~~~ -This will make all types within the module are non nullable by default. +This will make sure all types within the module are non nullable by default. -Starting at the class level annotations and then moving to package or module annotations provides a way to apply nullness analysis in stages to what many be a large existing project. +Starting at the class level annotations and then moving to package or module annotations provides a way to apply nullness analysis in stages to what may be a large existing project. ## IntelliJ Null Analysis