Class HelpfulNullPointerExceptionExamples

java.lang.Object
net.jrodolfo.java_evolution.java14.HelpfulNullPointerExceptionExamples

public class HelpfulNullPointerExceptionExamples extends Object
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.

  • Constructor Details

    • HelpfulNullPointerExceptionExamples

      public HelpfulNullPointerExceptionExamples()
  • Method Details

    • triggerHelpfulNullPointerException

      public String 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