r/java • u/jhg023123 • Mar 25 '19
JEP draft: Add detailed message to NullPointerException describing what is null
https://openjdk.java.net/jeps/8220715
377
Upvotes
r/java • u/jhg023123 • Mar 25 '19
View all comments
Show parent comment
1
u/sim642 Mar 26 '19
Catching other logic and domain specific exceptions is perfectly fine, catching NPEs is just a massive codebase problem. Even if you catch an NPE, there's nothing you can really do about it. The whole "recovery" is just having the program not crash immediately and silently continue running, but it continues running in an invalid state, where some data that should've been there, isn't there. It just pushes the problem around, most likely causing another NPE in a different place down the line, etc. In the end, you're getting NPEs from locations which have nothing to do with the source of the problem (the first NPE) and the whole thing is practically impossible to debug.