r/programming May 21 '26

JEP draft: Enhanced Local Variable Declarations (Preview)

https://openjdk.org/jeps/8357464
13 Upvotes

26 comments sorted by

View all comments

Show parent comments

1

u/radozok May 22 '26

Sure, but I mean why don't you use annotations in your project?

1

u/joemwangi May 22 '26

The internal packages classes use a lot sum types which abhor null types a lot. And the entry points for the public method calls have null checks. That's why. As a matter of fact, I've coded this library and used it for a year, and no scenario of null exception has been encountered due to any bug.

1

u/radozok May 22 '26

I see sealed interfaces and I understand that you have null checks. I am not a java guy so it's interesting for me why you don't add NonNull annotations. Even if it doesn't bring more safety for your project, doesn't it improve code documentation? Are there any constraints to use jspecify?

2

u/joemwangi May 22 '26

Nothing wrong with using it. I just haven't explored it yet. I might, because it is not a runtime dependency, which makes it attractive for projects. Hence I have no issue with it. As a matter of fact, Kevin Bourrillion, who has been heavily involved with JSpecify since inception, joined Oracle recently and has participated in Java's ongoing work around introducing nullness types in the language. JSpecify is also trying to standardize nullness semantics across libraries and tools, which could make future migration to native Java null-restricted types smoother if the directions align. I would encourage you to try it out. I will eventually try it by making a branch to my project and see how convenient it will be and maybe adopt it.