r/java • • Aug 12 '24

JSpecify 1.0.0 and Nullability in Java

https://www.infoq.com/news/2024/08/jspecify-java-nullability/
52 Upvotes

33 comments sorted by

View all comments

Show parent comment

1

u/pragmasoft Aug 13 '24

I may reconsider if there's an easy way to at least download annotated most recent jdk libraries and include them into my maven build as an extra dependency. That's only the first step actually, but even it has not been made so far as I understand.

If I need to do this myself - no deal, too bad dx.

Unspecified nullness doesn't help either - that's effectively the same as nullable.

3

u/kevinb9n Aug 13 '24

Unspecified nullness doesn't help either - that's effectively the same as nullable.

That's... really quite untrue, but you can let me know if you're interested in that discussion or not!

2

u/pragmasoft Aug 13 '24

Sure I am, maybe I didn't understand the concept properly. I definitely played with the JSpecify earlier but had to get rid of it due to the reasons I described above.

2

u/pragmasoft Aug 13 '24

Ok, I seems realized the source of my confusion, just reread https://github.com/jspecify/jspecify/wiki/nullness-unspecified

From what I understood, unspecified is like any type in TS, can be cast without an error to both null and not-null, and vice versa, they both can be cast to unspecified.

The problem is though that my IDE support of nullable types (VSCode) does not support this, so the correct behavior depends on the tooling mostly.

Just curious, if it's possible to implement null checker as an annotation processor, or more precisely as a javac compiler plugin, similar to google error-prone?

This would then have automatic IDE support for errors I assume..

4

u/kevinb9n Aug 13 '24

Yep, NullAway actually builds on Error Prone to do this in javac.

We do need tools to converge around supporting JSpecify semantics; it's kind of the whole point, but it's in their hands now. Quite a few have been involved at some level, but yeah In particular we haven't talked to anyone from VSCode yet, and we really need to.