Possible removal of public API in SimpleSelector

John Hendrikx john.hendrikx at gmail.com
Fri Jan 5 01:15:03 UTC 2024


In a new PR (https://github.com/openjdk/jfx/pull/1316) I've deprecated 
two methods for removal.

      SimpleSelector#getStyleClasses

      SimpleSelector#getStyleClassSet

I think these are safe to remove because even though they are public, 
and part of public API, the only way to reach them is by casting a 
`Selector` to `SimpleSelector` as `SimpleSelector`s cannot be publicly 
constructed (they have a package private constructor only).

The first method which returns a `List` is not used within FX, and seems 
to have been created to allow users to get the style classes as a List, 
but its unreachable without casting.  A search on Google using the 
quoted "javafx.css.SimpleSelector" (which you would find in an import) 
and this method name returns no results outside of SimpleSelector itself.

The second method was used by FX before the PR to get the style classes 
for use by the internal class `SelectorPartitioning`.  It is public so 
that this internal class can reach it.  It does this by doing an 
instanceof check (it gets the generic Selector class, and then tests if 
it is a CompoundSelector or SimpleSelector).  As this was the only user 
of this method (checked with Google search again), and the method is 
hard to reach (must do a cast), I think it is safe to remove it.

Please let me know if I missed anything.

--John



More information about the openjfx-dev mailing list