Autoboxing
Little bug?
Have:
Boolean b = true;
Convert to boolean intention generates:
Boolean b = Boolean.valueOf(true);
should generate:
Boolean b = Boolean.TRUE;
Thx for the plugin!!!
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Please sign in to leave a comment.
Dani wrote:
Thanks for suggestion, I would call it RFE then a bug. :)
You can download a new version of the plugin.
/kesh
On Wed, 25 Jun 2003 12:18:03 -0400, kesh <dummy@dummy.com> wrote:
>
>> Little bug?
>>
>> Have:
>>
>> Boolean b = true;
>>
>> Convert to boolean intention generates:
>>
>> Boolean b = Boolean.valueOf(true);
>>
>> should generate:
>>
>> Boolean b = Boolean.TRUE;
>>
>> Thx for the plugin!!!
>>
>
>
>
Wow, really fast. Many thx.
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
If you're going to put in that optimization, calling Boolean.valueOf() is a better solution than allocating a new Boolean. It's a static method that does just what you would expect, testing it's value and returning Boolean.TRUE or Boolean.FALSE, as appropriate. No memory allocation needed.
Whoops, I'm an idiot. I had an old version where you used new Boolean(). Downloading the new one new.
Great plugin, BTW.
Boolean.valueOf() is better but it's Java 1.4 specific so it won't compile with 1.3.
Timur
Timur Zambalayev wrote:
>>If you're going to put in that optimization, calling
>>Boolean.valueOf() is a better solution than
>>allocating a new Boolean. It's a static method that
>>does just what you would expect, testing it's value
>>and returning Boolean.TRUE or Boolean.FALSE, as
>>appropriate. No memory allocation needed.
Good point. I've uploaded a new version of the plugin which fixes this
problem. Now Boolean.valueOf method is used only when the project's JDK
has version 1.4.x or higher.
Thanks,
/kesh
Jus't for curiosity what did you use?
Boolean boo = new Boolean(b);
or
Boolean boo = b ? Boolean.TRUE : Boolean.FALSE;
I can't say that I really care for either one, but the second one doesn't
create a new object.
If I really needed it, I would create:
public final class Booleans {
public static Boolean valueOf(boolean b) {
return b ? Boolean.TRUE : Boolean.FALSE;
}
}
I created several utility classes - Dates, Strings, ... - to do things like
this.