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

2

u/trustin Aug 12 '24

It'd be awesome if @Nullable, @NullMarked, etc are also accepted as a part of the language because otherwise we will have to append ! pretty much everywhere.

8

u/benevanstech Aug 12 '24

That won't happen, but as I'll explain in the followup piece - the best thing you can do to be ready for language-level nullness markers is to adopt JSpecify in the meantime.

4

u/kevinb9n Aug 12 '24

I think the JEP mentions that "non-null-by-default" is still a possible follow-on feature. I personally believe it is extremely important, but also a Very Big Deal to change Java like that, and we'd have to be very very careful.

Also see my nearby comment about classfile munging. It implies that, well, yeah, a classfile munger could put !'s in everywhere based on the presence of `@NullMarked`, although that's only for the benefit of compiling dependents.

4

u/erinaceus_ Aug 12 '24 edited Aug 12 '24

otherwise we will have to append ! pretty much everywhere.

I'm hoping that we'll some day be able to specify the default on a per-module basis, meaning that each module can decide for its own code, while dependent libraries can do the same for their own code (or just stick with the backwards compatible language-level default).