spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Adopt `JSpecify` for nullness

Open qwertycxz opened this issue 5 months ago • 7 comments

Since javax is deprecated. We should migrate from javax to jakarta.

This is not necessary. But I'd love to contribute if you want. :)

qwertycxz avatar Jul 29 '25 16:07 qwertycxz

I don't know what javax to jakarta means.

nedtwigg avatar Jul 29 '25 16:07 nedtwigg

@nedtwigg I believe that @qwertycxz is referring to all the javax.* annotations we use like javax.annotation.Nullable. They've been replaced with the jakarta.* package over the last few years as part of Oracle handing over Java EE to the Eclipse Foundation under the new name "Jakarta". This name change was some for copyright or trademark reasons, IIRC.

Long story short, Spring, Quarkus, etc. seem to use jakarta.* annotations nowadays, with Dagger 2 due to eventually adopt them too, so the OP is gently encouraging us to adopt Jakarta annotations, too.

That being said, for nullness specifically, JSpecify is the de facto standard nowadays, so we should migrate to JSpecify and adopt Jakarta to fill in any gaps.

What do you think? :)

jbduncan avatar Jul 29 '25 16:07 jbduncan

I've followed the JSpecify nullness project, happy to take a PR for that. Find-replacing javax. to jakarta. seems like more churn than it's worth.

nedtwigg avatar Jul 29 '25 17:07 nedtwigg

This would be not easy. I'm not sure if SpotBug support JSpecify. We may need EISOP as a new null checker.


Update: Here's a SpotBug plugin for JSpecify. But it was archived?


Update 2: A relative issue here.

qwertycxz avatar Jul 30 '25 14:07 qwertycxz

Looks like there's two gradle plugins supporting JSpecify to some level out of the box:

  • https://github.com/tbroyer/gradle-nullaway-plugin
  • https://github.com/kelloggm/checkerframework-gradle-plugin

I have used @tbroyer stuff in the past, I think he's very good.

nedtwigg avatar Jul 30 '25 23:07 nedtwigg

This would be not easy. I'm not sure if SpotBug support JSpecify. We may need EISOP as a new null checker.

Update: Here's a SpotBug plugin for JSpecify. But it was archived?

Update 2: A relative issue here.

Good observation about SpotBugs and JSpecify. I know that the SpotBugs team used to be part of the JSpecify committee, but they're no longer mentioned on the JSpecify website, so maybe there was a falling out or a difference in views on how nullness analysis should be done. So @nedtwigg's suggestion to use either NullAway or Checker Framework (ideally on top of SpotBugs) sounds good to me. 👍

jbduncan avatar Aug 03 '25 12:08 jbduncan

What do you think about Spring’s nullability-plugin (https://github.com/spring-gradle-plugins/nullability-plugin)? Its repository code looks quite concise.

mymx2 avatar Aug 28 '25 08:08 mymx2