Class HelpfulNullPointerExceptionExamples
java.lang.Object
net.jrodolfo.java_evolution.java14.HelpfulNullPointerExceptionExamples
Demonstrates helpful
NullPointerException messages, introduced in
Java 14.
Before Java 14, a null pointer failure inside a chained expression often
produced a generic message. Developers had to debug the expression to figure
out which value was null.
Java 14 improved JVM diagnostics so the exception message can describe which
part of a chained access was null. The feature does not prevent null
values, but it makes failures easier to diagnose.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAddress with a city value used by the null-pointer diagnostic example.static classCustomer with an address reference used to trigger nested null access. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIntentionally dereferences a nested null value so tests can inspect the helpful exception message.
-
Constructor Details
-
HelpfulNullPointerExceptionExamples
public HelpfulNullPointerExceptionExamples()
-
-
Method Details
-
triggerHelpfulNullPointerException
Intentionally dereferences a nested null value so tests can inspect the helpful exception message.- Returns:
- never returns when the default sample data is used
-