Preventing null pointer exceptions at compile time
summary
Tool demo shows a Nullness Checker from CheckerFramework.org that enforces a nullness type system at compile time, integrating with javac, Eclipse, IntelliJ, and build tools. It finds real bugs (JUnit crashes, field-initialization and new-array例 issues), has uncovered hundreds of bugs in millions of lines, and produces a formal proof that no null pointer exceptions remain once annotations and a few fixes are added. Expect about 1 annotation per 75 LOC in practice and the ability to prove absence of NPEs for annotated code.
AI-written summary · about
chapters (18)
- 0:00Intro
- 1:09Java's type system is too weak
- 4:07Specification 1: non-null parameter
- 4:18Specification 2: nullable parameter
- 10:43Solution: Pluggable Type Checking
- 11:48Optional Type Checking
- 12:52The Checker Framework
- 14:17Benefits of type systems
- 16:32Comparison: other nullness tools
- 23:00Java 8 extends annotation syntax
- 23:57Java 6 & 7 compatibility (or avoid dependency on Checker Framework)
- 28:36Lazy initialization and persistence across side effects
- 39:49Map key example
- 41:48Optional checks
- 42:16Cost of software failures
- 43:01Example: Regex Checker
- 43:18Tips for pluggable type-checking
- 46:00Pluggable type-checking improves code
related talks
44mThe long good-bye to NPE
36mJSpecify: Getting Rid of the Billion-Dollar Mistake in Java for Good This Time
53mNulls are dead
36mRetrofitting Null-Safety into Java
41mNull Safety in Java with JSpecify and NullAway
31mError Prone: Google's Secret Weapon for Bug-Free Lines of Code
56mValhalla Nullness Emotion
48mNull-safe applications with Spring Boot 4
