S
Sideswipe
I have this code:
public Boolean getValue(ItemAttributeSource source) {
Currency c = FIXED_SHIPPING_CHARGE.getValue(source);
return (c != null ? c.compareTo(c.getUnit().ZERO_VALUE) > 0 :
null);
}
it compiles happy and runs fine on RHEL3 using JDK 1.6.0_03.
This same exact code throws a NullPointerException on Windows XP JDK
1.6.0_02 (same problem happened on 1.5) because of this autoboxing
behavior:
Boolean a = null;
boolean b = a;
System.out.println(b); // NPE here as expected
So, what's happening is that on linux the Type of the 3rd operand is
determined and the 2nd is boxed to it
On windows, the second operand type is determined (primitive boolean)
and then the 3rd operand is boxed to it which is producing a NPE.
Also, on Linux it compiles fine and figures out the correct boxing
type is Boolean (that is the return type). On Windows it requires an
explicit cast of the second operand to (Boolean) to make this work.
Can someone explain this to me?
Christian Bongiorno
http://christian.bongiorno.org
public Boolean getValue(ItemAttributeSource source) {
Currency c = FIXED_SHIPPING_CHARGE.getValue(source);
return (c != null ? c.compareTo(c.getUnit().ZERO_VALUE) > 0 :
null);
}
it compiles happy and runs fine on RHEL3 using JDK 1.6.0_03.
This same exact code throws a NullPointerException on Windows XP JDK
1.6.0_02 (same problem happened on 1.5) because of this autoboxing
behavior:
Boolean a = null;
boolean b = a;
System.out.println(b); // NPE here as expected
So, what's happening is that on linux the Type of the 3rd operand is
determined and the 2nd is boxed to it
On windows, the second operand type is determined (primitive boolean)
and then the 3rd operand is boxed to it which is producing a NPE.
Also, on Linux it compiles fine and figures out the correct boxing
type is Boolean (that is the return type). On Windows it requires an
explicit cast of the second operand to (Boolean) to make this work.
Can someone explain this to me?
Christian Bongiorno
http://christian.bongiorno.org