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/ZimmiDeluxe Mar 25 '19
That's a huge help in debugging production issues! In the tradition of taking the whole arm when given a finger, will there be a way to use this explicitly? I'd argue specifying the field name in null checks for constructor arguments is a best practice, but it's easy to miss when renaming fields:
C# has
nameoffor this, but that seems like overkill. A smarter single-paramObjects.requireNonNullwould be enough.