See slide 17 of https://oracleus.activeevents.com/2014/connect/fileDownload/...
Though I do recall a long time ago reading about some JVM switches that allow that data to be accessed but with performance issues. Can't recall where I read that.
I hope I will be wrong.
ps: a language where non-nullable references are the thing would be the best.
As I see: unfortunately without algebraic types you cannot solve this properly, even if you address the lacking points in Optional<T>