Hacker News new | ask | show | jobs
by savanu 1903 days ago
So you are really looking for compiler checks for null? Kind of like kotlin?

var truthy = null; // Compile fails

var nullable? = null; // Compile passes

You don't need value types for this?

1 comments

That's not exactly the same thing... It can also (again I don't know if this is part of the jep or not) be used to perform stack based destructors (finalize) and then Java could implement RAII. Reading the jep it discusses perhaps rejecting finalize as function on primitive objects, so this might not be in scope.

Additionally, the type is also lighter weight than an Object and should be stack allocated, so there are memory advantages to not having to use boxed types as well.