[PATCH] unnecessary null check inside of java.lang.Boolean.valueOf(String)

Ivan Gerasimov ivan.gerasimov at oracle.com
Mon Mar 19 21:21:30 UTC 2018

On 3/19/18 12:32 PM, Martin Buchholz wrote:
>>        */
>>       public boolean equals(Object obj) {
>>           if (obj instanceof Boolean) {
>> - return value == ((Boolean)obj).booleanValue();
>> + return value == (Boolean) obj;
>>           }
> This is not correct, since we might have multiple Boolean objects that are
> equals, but not ==.
> Do we have a test that would catch this?
But isn't it autounboxing happening when a primitive value gets compared 
to a Boolean?
I suspect the bytecode would be the same, and if this is the case, I 
would prefer to keep the original line to avoid confusion.

With kind regards,
Ivan Gerasimov

More information about the core-libs-dev mailing list