Errors beginner

Helpful NullPointerExceptions

JVM automatically tells you exactly which variable was null.

✕ Java 8
// Old NPE message:
// "NullPointerException"
// at MyApp.main(MyApp.java:42)
// Which variable was null?!
✓ Java 14+
// Modern NPE message:
// Cannot invoke "String.length()"
// because "user.address().city()"
// is null
// Exact variable identified!
🔍

Exact variable

The message names the null variable in the chain.

Faster debugging

No more guessing which of 5 chained calls was null.

🆓

Free upgrade

No code changes — just run on JDK 14+.

Old Approach
Cryptic NPE
Modern Approach
Detailed NPE
Since JDK
14
Difficulty
beginner
Helpful NullPointerExceptions
Available

Widely available since JDK 14 (March 2020)

How it works

Helpful NPEs describe which expression was null and what operation failed. This is enabled by default since Java 14 — no code change needed, just upgrade the JDK.

Share 𝕏 🦋 in