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

Remove SimpleSelector and CompoundSelector classes

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • jfx24
    • javafx
    • None
    • source, binary, behavioral
    • low
    • Hide
      Software referencing the deprecated for removal types `SimpleSelector` and `CompoundSelector` will no longer compile. There is no risk removing the `writeBinary` method or changing the abstract state of `createMatch` as it was impossible to subclass `Selector`.
      Show
      Software referencing the deprecated for removal types `SimpleSelector` and `CompoundSelector` will no longer compile. There is no risk removing the `writeBinary` method or changing the abstract state of `createMatch` as it was impossible to subclass `Selector`.
    • Java API
    • JDK

      Summary

      The CompoundSelector and SimpleSelector which were deprecated for removal in 23 will be removed. Furthermore, the previously inaccessible Selector#writeBinary method is removed from the public API.

      Problem

      The classes and methods involved are part of internal functionality, to read and write binary stylesheets, that was only partially exposed . Their exposure severely limited our options to extend these classes without exposing further API that's should not be published. The feature was never exposed far enough to be useful to users of this API.

      Solution

      The previously deprecated classes will be moved to internal packages. To allow them to still subclass Selector, Selector will be made sealed and will permit SimpleSelector and CompoundSelector. This is a backwards compatible change due to Selector having a package private constructor previously.

      The protected writeBinary method of Selector will be removed and implemented internally. This method, although protected, could not be accessed due to the inability to create subtypes of Selector.

      Specification

      CompoundSelector moved to internal package:

      diff --git a/modules/javafx.graphics/src/main/java/javafx/css/CompoundSelector.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/css/CompoundSelector.java
      similarity index 80%
      rename from modules/javafx.graphics/src/main/java/javafx/css/CompoundSelector.java
      rename to modules/javafx.graphics/src/main/java/com/sun/javafx/css/CompoundSelector.java
      index d7c6614b71..c4422b8b20 100644
      --- a/modules/javafx.graphics/src/main/java/javafx/css/CompoundSelector.java
      +++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/css/CompoundSelector.java

      SimpleSelector moved to internal package:

      diff --git a/modules/javafx.graphics/src/main/java/javafx/css/SimpleSelector.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/css/SimpleSelector.java
      similarity index 82%
      rename from modules/javafx.graphics/src/main/java/javafx/css/SimpleSelector.java
      rename to modules/javafx.graphics/src/main/java/com/sun/javafx/css/SimpleSelector.java
      index ee049b1098..f5d0e26434 100644
      --- a/modules/javafx.graphics/src/main/java/javafx/css/SimpleSelector.java
      +++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/css/SimpleSelector.java

      Selector changes:

      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 ed7ea8733f..94069c6fc5 100644
      --- a/modules/javafx.graphics/src/main/java/javafx/css/Selector.java
      +++ b/modules/javafx.graphics/src/main/java/javafx/css/Selector.java
      @@ -40,16 +39,17 @@ import java.util.Set;
        *
        * @since 9
        */
      -abstract public class Selector {
      +public abstract sealed class Selector permits SimpleSelector, CompoundSelector {
      
           /**
      -     * Package scoped constructor.
      +     * Constructor for subclasses to call.
      +     *
      +     * @since 24
            */
      -    Selector() {
      +    protected Selector() {
           }
      
      @@ -106,7 +106,9 @@ abstract public class Selector {
            *
            * @return a match, never {@code null}
            */
      -    public abstract Match createMatch();
      +    public final Match createMatch() {
      +        return Match.of(this);
      +    }
      
           /**
            * Gets whether this {@code Selector} applies to the given {@code Styleable}.
      
      @@ -137,48 +139,11 @@ abstract public class Selector {
      -    /**
      -     * Writes {@code Selector} data in binary form to given {@code DataOutputStream}.
      -     * @param os {@code DataOutputStream} to write {@code Selector} data to
      -     * @param stringStore unused
      -     * @throws IOException if writing to {@code DataOutputStream} fails
      -     */
      -    @SuppressWarnings("removal")
      -    protected void writeBinary(DataOutputStream os, StyleConverter.StringStore stringStore)
      -        throws IOException {
      -        if (this instanceof SimpleSelector) {
      -            os.writeByte(TYPE_SIMPLE);
      -        } else {
      -            os.writeByte(TYPE_COMPOUND);
      -        }
      -    }

            jhendrikx John Hendrikx
            jhendrikx John Hendrikx
            Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: