Skip to content

refactor: migrate nullability annotations from SpotBugs to JSpecify#3907

Merged
jknack merged 1 commit intomainfrom
3906
Apr 18, 2026
Merged

refactor: migrate nullability annotations from SpotBugs to JSpecify#3907
jknack merged 1 commit intomainfrom
3906

Conversation

@jknack
Copy link
Copy Markdown
Member

@jknack jknack commented Apr 18, 2026

Replaces legacy JSR-305/SpotBugs annotations with the modern JSpecify standard across the framework. This resolves longstanding JPMS split-package warnings (javax.annotation), lightens the dependency tree, and modernizes null-safety contracts.

Core & Global Changes:

  • Removed spotbugs-annotations and jsr305 dependencies entirely.
  • Added org.jspecify:jspecify as the unified nullability standard.
  • Swapped @ReturnValuesAreNonnullByDefault for @NullMarked in packages.
  • Cleaned up redundant @NonNull annotations. JSpecify's @NullMarked applies a non-null default to the entire scope (returns, parameters, and fields), making explicit non-null declarations unnecessary.

jooby-apt (Annotation Processing):

  • Added support for Type-Use annotations.
  • Processors now correctly check both the element declaration AND the underlying return/parameter types (asType().getAnnotationMirrors()) to resolve nullability, fixing the visibility gap between legacy declaration annotations and modern type-use annotations.

jooby-openapi (ASM Bytecode Parsing):

  • Overhauled parameter annotation extraction to gather type annotations (visibleTypeAnnotations & invisibleTypeAnnotations) alongside standard parameter arrays.

  • Hardened nullability detection: replaced hardcoded JetBrains/SpotBugs descriptors with flexible substring matching ("Nullable", "NonNull", "NotNull"). The OpenAPI generator is now fully library-agnostic and will correctly parse JSpecify, JetBrains, Lombok, or SpotBugs annotations.

  • fix nullability: replace spotbugs annotations with jspecify #3906

Replaces legacy JSR-305/SpotBugs annotations with the modern JSpecify
standard across the framework. This resolves longstanding JPMS split-package
warnings (javax.annotation), lightens the dependency tree, and modernizes
null-safety contracts.

Core & Global Changes:
- Removed `spotbugs-annotations` and `jsr305` dependencies entirely.
- Added `org.jspecify:jspecify` as the unified nullability standard.
- Swapped `@ReturnValuesAreNonnullByDefault` for `@NullMarked` in packages.
- Cleaned up redundant `@NonNull` annotations. JSpecify's `@NullMarked`
  applies a non-null default to the entire scope (returns, parameters,
  and fields), making explicit non-null declarations unnecessary.

jooby-apt (Annotation Processing):
- Added support for Type-Use annotations.
- Processors now correctly check both the element declaration AND the
  underlying return/parameter types (`asType().getAnnotationMirrors()`)
  to resolve nullability, fixing the visibility gap between legacy
  declaration annotations and modern type-use annotations.

jooby-openapi (ASM Bytecode Parsing):
- Overhauled parameter annotation extraction to gather type annotations
  (`visibleTypeAnnotations` & `invisibleTypeAnnotations`) alongside
  standard parameter arrays.
- Hardened nullability detection: replaced hardcoded JetBrains/SpotBugs
  descriptors with flexible substring matching ("Nullable", "NonNull",
  "NotNull"). The OpenAPI generator is now fully library-agnostic and
  will correctly parse JSpecify, JetBrains, Lombok, or SpotBugs annotations.

- fix  #3906
@jknack jknack added this to the 4.5.0 milestone Apr 18, 2026
@jknack jknack merged commit d8b0bed into main Apr 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nullability: replace spotbugs annotations with jspecify

1 participant