RFR: 8274168: Avoid String.compareTo == 0 to check String equality in java.management [v2]

David Holmes david.holmes at oracle.com
Thu Sep 23 13:37:18 UTC 2021


On 23/09/2021 6:00 pm, Andrey Turbanov wrote:
> On Thu, 23 Sep 2021 04:26:07 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
> 
>>> I look at it this way, the code should really (IMHO) have been written as:
>>>
>>> int res = sval1.compareTo(sval2);
>>> switch(relOp) {
>>> case Query.GT: return res > 0;
>>> case ...
>>> }
>>>
>>>   and so the use of equals() instead would never have arisen. :)
>>
>> Yep, that works for me.
> 
> Ok. Done.

I'm not sure if Chris was suggesting to make a change or just saying 
that my argument "works for him" :) I certainly wasn't suggesting a need 
to change the code form.

David

> -------------
> 
> PR: https://git.openjdk.java.net/jdk/pull/5640
> 


More information about the serviceability-dev mailing list