Mark Phillips wrote:
I just downloaded FindBugs and ran it on a project of mine, and I
noticed a behavior that may be a bug or a feature, or a don’t care.
The project is a J2ME application, which as you probably know,
contains a stripped down version of the JSDK. I mounted the jar file
for J2ME, and ran find bug against the project. Some of the bugs
identified were not really bugs, but artifacts of the limited JSDK
used in J2ME. For example, I used the expression
Boolean someValue = new Boolean(true);
And Find bugs said it should be changed to
Boolean someValue = Boolean.valueOf(true);
I'd suggest you write a class like
public class Bool
{
public static final Boolean TRUE=new Boolean(true);
public static final Boolean FALSE=new Boolean(false);
public static Boolean valueOf(boolean v)
{
if(v) return TRUE;
return FALSE;
}
}
and use that in place of the missing members of Boolean.
It's really a shame that they are missing (I just checked...) since they
save
memory if used (which seems very reasonable in the CLDC context...).
Using only the above class would also have the effect that you'd have
the false warning only at those two places of your code.
Hope this helps...
Jörn.
|
|