Micronaut 5 adoption of the JSpecify nullability annotations
by Sergio Del Amo CaballeroJSpecify nullability annotations have emerged as the standard way to define nullability constraints in Java APIs using annotations. We have migrated Micronaut’s internal APIs to use JSpecify nullability annotations.
If you were using Micronaut nullability annotations, replace usages of io.micronaut.core.annotation.Nullable with org.jspecify.annotations.Nullable, and usages of io.micronaut.core.annotation.NonNull with org.jspecify.annotations.NonNull.
Fully Qualified Types
When specifying a fully qualified type, with Micronaut nullability annotations you could write:
public ReadBuffer adapt(@NonNull io.micronaut.core.io.buffer.ByteBuffer<?> buffer) {
With JSpecify, you need to write:
public ReadBuffer adapt(io.micronaut.core.io.buffer.@NonNull ByteBuffer<?> buffer) {
Inner classes
For inner classes, with Micronaut annotations you could write:
public FileChangedEvent(@NonNull Path path, @NonNull WatchEvent.Kind eventType) {
With JSpecify, you need to write:
public FileChangedEvent(@NonNull Path path, WatchEvent.@NonNull Kind eventType) {
Read more about the JSpecify Micronaut integration.