Name: rmT116609 Date: 03/07/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
A DESCRIPTION OF THE PROBLEM :
It would be nice to add the following convienience method to Boolean.
public static Boolean getBoolean(boolean b) {
return (b ? Boolean.TRUE : Boolean.FALSE);
}
While not a significant piece of code, this would clean up a lot of places where this same logic happens today. Even better it would encourage people to use the TRUE and FALSE constants rather than just creating new Booleans as they
often do today.
This bug can be reproduced always.
CUSTOMER WORKAROUND :
Currently people do one of two things
public void foo(boolean b) {
Boolean b1 = new Boolean(b);
}
public void bar(boolean b) {
Boolean b1 = (b ? Boolean.TRUE : Boolean.FALSE);
}
If this RFE is implemented they could instead do:
public void baz(boolean b) {
Boolean b1 = Boolean.getBoolean(b);
}
Which has the cleanliness of foo(), but function of bar().
(Review ID: 143890)
======================================================================