Contact Us About Sponsorship

Questions about Micronaut Foundation sponsorship?

Please complete this form, and we’ll follow up with you shortly.

[hubspot type=form portal=4547412 id=a7b3ddfa-64b0-47fd-8358-45fa6a09456a]

Micronaut 5 adoption of the JSpecify nullability annotations

by Sergio Del Amo Caballero Tags:

JSpecify 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.