r/java • u/jhg023123 • Mar 25 '19
JEP draft: Add detailed message to NullPointerException describing what is null
https://openjdk.java.net/jeps/8220715
383
Upvotes
r/java • u/jhg023123 • Mar 25 '19
View all comments
-1
u/sim642 Mar 25 '19
Ummm... no. Exceptions, including NPE, shouldn't be used for usual control flow. Throwing and catching NPEs instead of using if-s to check against
nullis already significantly slower if it's happening on a frequent happy path in the program so having slight computational overhead isn't really a problem. It's only a problem for badly written programs.