benf.org : other : cfr : auto-boxing. |
The compiler generates calls to valueOf (to box) and [type]value (to unbox) as described in lovely detail at the Java Tutorials, here.
If you tell CFR not to hide sugaring (with --sugarboxing false), it's really obvious to see what's going on ... and it's obvious why null checks are important when dealing with boxed values....
public Double foo(Integer i, Double d) { return d + i; }
public Double foo(Integer i, Double d){ return Double.valueOf((d.doubleValue() + i.intValue())); }
Last updated 03/2014 |