RFR: 8353845: com.sun.javafx.css.BitSet.equals(null) throws NPE [v2]

John Hendrikx jhendrikx at openjdk.org
Wed Apr 9 12:54:49 UTC 2025


On Wed, 9 Apr 2025 12:27:31 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:

>> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   obj == null
>
> modules/javafx.graphics/src/main/java/com/sun/javafx/css/BitSet.java line 540:
> 
>> 538:             return false;
>> 539:         }
>> 540: 
> 
> Here is a suggestion to modify this source as:
> 
> 
> if (obj == null || getClass() != obj.getClass()) {
>     return false;
> }
> return equalsBitSet((BitSet<?>) obj);
> 
> and with this the call to `super.equals()` won't be necessary. It seems it was unnecessary earlier too. it might have been added only to avoid missing return error.

We have to respect the `Set` contract here, and just because the two sets are of different types does not mean they can't be equal.  A `HashSet<PseudoClass>` can still be equal to a `BitSet<PseudoClass>`.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1766#discussion_r2035300256


More information about the openjfx-dev mailing list