RFR: JDK-8304959: Public API in javafx.css.Match should not return private API class PseudoClassState [v7]

John Hendrikx jhendrikx at openjdk.org
Thu May 18 22:53:00 UTC 2023


On Thu, 18 May 2023 19:47:28 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

> Consider this example:
> 
> ```
>     @Test
>     public void testEquals() {
>         PseudoClassState a = new PseudoClassState();
>         StyleClassSet b = new StyleClassSet();
>         assertFalse(a.equals(b));
>     }
> ```

I'm aware that this is broken now, and still is broken after this PR.  It's fixed in #1076 and has this test case even.

It's worse than that tough, even `BitSet`s of the same type can fail equals (from #1076):

    @Test
    void shouldBeEqual() {
        StyleClassSet set1 = new StyleClassSet();
        StyleClassSet set2 = new StyleClassSet();

        set1.add(StyleClassSet.getStyleClass("abc"));
        set2.add(StyleClassSet.getStyleClass("abc"));

        assertEquals(set1, set2);

        for (int i = 0; i < 1000; i++) {
            // grow internal bit set array:
            set1.add(StyleClassSet.getStyleClass("" + i));

            assertNotEquals(set1, set2);
        }

        for (int i = 0; i < 1000; i++) {
            set1.remove(StyleClassSet.getStyleClass("" + i));
        }

        // still equal despite internal array sizes being different size:
        assertEquals(set1, set2);
    }

Do you want me to pull in more changes from #1076 unrelated to fixing the public API problem in Match?

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

PR Comment: https://git.openjdk.org/jfx/pull/1070#issuecomment-1553754076


More information about the openjfx-dev mailing list