Null-Safety on Steroids

Session Type: 
Standard Talk [25 minutes]
Speakers

One of the major features in Eclipse Juno is the improved null-analysis in the Java Development Tools (JDT). At first it sounds really amazing: You just put a few annotations into your code and the compiler will tell you up-front when you try to access a null value. NullPointerExceptions are history, aren't they?

In this session I want to outline the pros and cons of the approach that was implemented by the Eclipse JDT. I will demonstrate how powerful the NPE detection is and on the other hand show its limits when it comes to multi project setups, library or framework development and working with existing code bases. To circumvent those, I implemented a small compiler extension that combines the static analysis of the JDT with pragmatic runtime assertions. These close the gap between the static and dynamic nature of Java programs and greatly simplify the live of us Java developers. It follows a few principles:

  1. Interfaces define a contract: All implementations should be validated against that contract.
  2. Don't impose restrictions on the used annotations. Being it Findbugs, (the dormant) JSR 305
    or JDTs annotation library: All of these should work seamlessly together.
  3. Fail early! A meaningful exception can save us from hours of debugging.

If you want to learn more about static and runtime NPE prevention, this session is right for you.

Schedule info

Room: 
Silchersaal
Status: 
Accepted

Audience

Track: 
Eclipse Technology
Experience level: 
Intermediate

Copyright © 2012 The Eclipse Foundation. All Rights Reserved.