Skip to content

Replace JetBrains nullness annotations with JSpecify - #680

Open
koppor wants to merge 1 commit into
vsch:masterfrom
koppor:jspecify-annotations
Open

Replace JetBrains nullness annotations with JSpecify#680
koppor wants to merge 1 commit into
vsch:masterfrom
koppor:jspecify-annotations

Conversation

@koppor

@koppor koppor commented Sep 6, 2026

Copy link
Copy Markdown

🤖 Nullness is currently expressed with org.jetbrains:annotations, which only JetBrains tooling treats as authoritative; JSpecify is the vendor-neutral standard that IntelliJ, Eclipse, NullAway, Error Prone and Kotlin all understand, so switching makes the API contract usable by every consumer (addresses #418). Every src/main package is now @NullMarked — non-null becomes the default, which lets ~730 @NotNull annotations be deleted outright — and @Nullable is swapped to org.jspecify; flexmark-util-sequence and flexmark-util-experimental keep the JetBrains jar for @Contract and @TestOnly, which JSpecify has no equivalent for. No behaviour changes: the annotations carry CLASS retention and are not read at runtime.

Test steps:

  • mvn test -Dsurefire.useFile=false — all modules pass.
  • flexmark-profile-pegdown errors on JDK 17 (parboiled cannot generate org.pegdown.Parser$$parboiled); this reproduces identically on unmodified master and is unrelated to this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PnkbonPy2LuAic9fPP9Xpi

JSpecify is the vendor-neutral nullness standard understood by IntelliJ,
Eclipse, NullAway, Kotlin and Error Prone, so annotating with it makes the API
contract usable by every consumer rather than only by JetBrains tooling. Every
package under src/main is now @NullMarked, which makes non-null the default and
lets ~730 @NotNull annotations be deleted outright; @nullable is kept where a
value may be absent. flexmark-util-sequence and flexmark-util-experimental keep
the JetBrains jar for @contract and @testonly, which have no JSpecify
equivalent.

JSpecify's @nullable is TYPE_USE only, so a few declarations had to move the
annotation into the type position: `byte @nullable []` for a nullable array and
`Map.@nullable Entry` for a nested type.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PnkbonPy2LuAic9fPP9Xpi
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.

1 participant