<Swing Dev> RFR: 8049301: Suspicious use of string identity checks in JComponent.setUIProperty [v2]
Alexey Ivanov
aivanov at openjdk.java.net
Thu Sep 2 18:02:00 UTC 2021
On Fri, 30 Jul 2021 20:50:05 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
> > I believe it was an optimisation to make comparison as quick as possible. There are many places in Swing where property keys are compared as object identity rather than using `equals`. If this place is changed, probably all other such places need updating if they haven't been updated to `equals` yet.
>
> Probably it will be better to roll back this one, and carefully check the usage of "==" for possible replacement by the "equal". That possibility should be proved by some test cases.
It's the other way around: `equals` can always be used (but could be slower); however, `==` may produce incorrect results in some cases. Probably, such optimisation `==` vs `equals` doesn't make sense any more and we should replace all usages of `==` with `equals`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4943
More information about the swing-dev
mailing list