Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8304994

Public API in javafx.css.Match should not return private API class PseudoClassState



    • CSR
    • Resolution: Approved
    • P3
    • jfx21
    • javafx
    • None
    • source, binary, behavioral
    • low
    • The returned type was never part of public API, and although it could be used, its usage is unsupported. Note that this is a binary incompatible change.
    • Java API
    • JDK



      Change the return type of javafx.css.Match.getPseudoClasses to Set<PseudoClass> instead of a non-public type.


      The method javafx.css.Match.getPseudoClasses erroneously returns the type PseudoClassState which is not part of the public CSS API. It was never intended to return this, but should have returned Set<PseudoClass>.


      Change the return type to use classes that are part of the public CSS API, Set<PseudoClass>.

      Alternatively, the class PseudoClassState could be moved to be part of the public API; this class however would need to be overhauled first as it was never intended to be published. It would be less consistent to do this as other class methods in the public CSS API already use Set<PseudoClass> when they wish to return the set of pseudo classes instead of this internal class.


      diff --git a/modules/javafx.graphics/src/main/java/javafx/css/Match.java b/modules/javafx.graphics/src/main/java/javafx/css/Match.java
      index 95288d12b4..5ee14a361c 100644
      --- a/modules/javafx.graphics/src/main/java/javafx/css/Match.java
      +++ b/modules/javafx.graphics/src/main/java/javafx/css/Match.java
      @@ -67,17 +70,19 @@ public final class Match implements Comparable<Match> {
            * Gets the {@code Selector}.
      -     * @return the {@code Selector}
      +     *
      +     * @return the {@code Selector}, never {@code null}
           public Selector getSelector() {
               return selector;
      -     * Gets the pseudo class state.
      -     * @return the pseudo class state
      +     * Gets the pseudo class states as an immutable set.
      +     *
      +     * @return the pseudo class state, never {@code null}
      -    public PseudoClassState getPseudoClasses() {
      +    public Set<PseudoClass> getPseudoClasses() {
               return pseudoClasses;
      diff --git a/modules/javafx.graphics/src/main/java/javafx/css/Selector.java b/modules/javafx.graphics/src/main/java/javafx/css/Selector.java
      index e1348158a8..2f6b87cb97 100644
      --- a/modules/javafx.graphics/src/main/java/javafx/css/Selector.java
      +++ b/modules/javafx.graphics/src/main/java/javafx/css/Selector.java
      @@ -93,7 +93,8 @@ abstract public class Selector {
            * Creates a {@code Match}.
      -     * @return match
      +     *
      +     * @return a match, never {@code null}
           public abstract Match createMatch();
      diff --git a/modules/javafx.graphics/src/main/java/javafx/css/SimpleSelector.java b/modules/javafx.graphics/src/main/java/javafx/css/SimpleSelector.java
      index e1348158a8..2f6b87cb97 100644
      --- a/modules/javafx.graphics/src/main/java/javafx/css/SimpleSelector.java
      +++ b/modules/javafx.graphics/src/main/java/javafx/css/SimpleSelector.java
      @@ -86,7 +86,7 @@ public List<String> getStyleClasses() {
      -     * Gets the {@code Set} of {@code StyleClass}es of the {@code Selector}.
      +     * Gets the immutable {@code Set} of {@code StyleClass}es of the {@code Selector}.
            * @return the {@code Set} of {@code StyleClass}es
           public Set<StyleClass> getStyleClassSet() {


        Issue Links



              jhendrikx John Hendrikx
              jhendrikx John Hendrikx
              Kevin Rushforth
              0 Vote for this issue
              3 Start watching this issue