RFR: 7083187: Class CSS.CssValue is missing implementations of equals() and hashCode() [v10]

Phil Race prr at openjdk.org
Tue May 30 17:11:03 UTC 2023


On Tue, 23 May 2023 16:44:20 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Two CSS AttributeSet-s can be compared using the AttributeSet.isEqual() method which can fail due to missing implementation of equals method in CSS subclasses.
>> In this issue, even when two CSS AttributeSet has same 42 font size string value, Object equality fails.
>> Fixed by implementing the equality and hashCode method for CSS.FontSize class.
>> 
>> All jtreg/jck tests are ok
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Optimize fix

src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 2219:

> 2217:         public int hashCode() {
> 2218:             return Float.hashCode(value);
> 2219:         }

why isn't index and lu part of this ?

src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 2225:

> 2223:                 return val instanceof CSS.FontSize size
> 2224:                        && Objects.equals(size.svalue, svalue);
> 2225:         }

This is an anomaly. In all the other cases below you are using the local fields not the original parsed string.

src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 2920:

> 2918:         @Override
> 2919:         public boolean equals(Object val) {
> 2920:             return val instanceof CSS.BackgroundPosition bp

why isn't "relative" part of equals and hashCode()?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13405#discussion_r1210575727
PR Review Comment: https://git.openjdk.org/jdk/pull/13405#discussion_r1210575057
PR Review Comment: https://git.openjdk.org/jdk/pull/13405#discussion_r1210573415



More information about the client-libs-dev mailing list