If you run the following code,
public class Foo{
    public static void main(String[] args){
        int id = new Bar().getId(); // throws unexpected NullPointerException
    }
    private static class Bar{
        private final Integer id;
        public Bar(){
            this(null);
        }
        public Bar(Integer id){
            this.id = id;
        }
        public Integer getId(){
            return id;
        }
    }
}
you will get the following stacktrace,
Exception in thread "main" java.lang.NullPointerException
    at Foo.main(Foo.java:3)
How come there's no compiler warning or anything? IMHO it's a pretty nasty subtlety with unboxing, or maybe I'm just naive.
Adding on to the answer provided by @Javier, if you're using Eclipse, you need to do the following to enable this:
- Navigate to Window > Preferences > Java > Compiler > Errors/Warnings
 - Expand Potential programming problems
 - Toggle Boxing and unboxing conversions to either "Warning", or "Error"
 - Tap "OK"