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);
- }
- }
- csr of
-
JDK-8323706 Remove SimpleSelector and CompoundSelector classes
-
- Resolved
-