classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Patch: convert new Boolean(X) to Boolean.valueOf(X)


From: David Daney
Subject: Re: [cp-patches] Patch: convert new Boolean(X) to Boolean.valueOf(X)
Date: Wed, 14 Sep 2005 14:26:01 -0700
User-agent: Mozilla Thunderbird 1.0.6-1.1.fc3 (X11/20050720)

Archie Cobbs wrote:
Mark Wielaard wrote:

While messing around with FindBugs, I came up with the following useful
patch.  It converts all "new Boolean(X)" instances to
"Boolean.valueOf(X)".  Ok?
[...]
-      return new Boolean(true);
+      return Boolean.valueOf(true);


OK, but if you know the actual value then using Boolean.TRUE and
Boolean.FALSE seems more appropriate then valueOf(). Could you make that
change?


That shouldn't be necessary .. the method inliner will
likely take care of that (Boolean.valueOf() is guaranteed
to return either Boolean.TRUE or Boolean.FALSE) so the
ultimate effect should be the same.


None of this is necessary.  But we do it anyway to make the code better.

For me Boolean.TRUE reads much more cleanly than Boolean.valueOf(true). I think it improbable that it is less efficient either.

David Daney




reply via email to

[Prev in Thread] Current Thread [Next in Thread]