|
|
|
|
|
by Cthulhu_
3116 days ago
|
|
In this case the most pragmatic thing to do is to ensure nothing in your application can ever be null - use asserts during development, empty lists, null objects, etc. Also never catch NPE's, if there is one after all those precautions, it's a developer error / bug and should be punished as such. The problem with optionals - as Sonar will complain about - is that people will call `.get()` on an Optional without first checking `.isPresent()` for example. Lots of things in the language that allow you to shoot yourself in the foot that other languages have solved. |
|
Also, isn't there a static code analysis tool that checks at compile-time that reference variables annotated as @non_nullable can never be null?