JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization

OwnerJonathan Giles
Created2015/04/01 01:16
Updated2016/10/17 21:50
Componentjavafx / controls
Discussionopenjfx dash dev at openjdk dot java dot net
Reviewed byAnton Tarasov, Kevin Rushforth, Leif Samuelsson, Victor Dyakov
Endorsed byKevin Rushforth


Define public APIs for the JavaFX UI controls and CSS functionality that is presently only available via internal APIs and will hence become inaccessible due to modularization.


Many developers who use the UI controls and CSS functionality of JavaFX have historically ignored the warnings to avoid the internal com.sun.* APIs. In many cases, to achieve a desired result, developers have no choice but to use these internal APIs. With the forthcoming release of Java 9, and in particular with the introduction of strong boundaries between modules in Project Jigsaw, developers will find that their code will no longer compile or run since the com.sun.* packages will no longer be accessible. The goal of this JEP is to define public APIs for the functionality presently offered by the internal APIs.


Given the implications of modularization, that is, the forthcoming inaccessibility of the com.sun.* packages, there is no way to do this in a manner that retains any degree of backward compatibility. It is, therefore, not a goal of this JEP to retain backward compatibility. This does not mean that we can break anything we like; our intention is to only introduce new API (and evolve existing private API) that is directly broken by the enforcement of module boundaries. All other existing APIs that are not impacted by modularization will remain the same.

Success Metrics

Success can be measured in two ways:


Without this work being done, many projects will need to significantly reduce the functionality that they offer, and for some projects this may prove fatal. For example, without access to the internal API that Scene Builder currently has, it may struggle to be viable---certainly its ability to offer functionality around CSS styling and manipulation of control properties will be severely undermined, and these are two of the core pieces of functionality of Scene Builder. The same argument holds for most other JavaFX-based projects with any degree of custom control or CSS implementation.


This JEP is broken down into two semi-related subprojects, each of which is important in reaching the final goal. There is no particular order to which these projects must be undertaken.

Project One: Make UI control skins into public APIs

At present all skins are located in This means that third parties who have extended a skin (e.g., the TextFieldSkin) to add additional functionality, to override an existing method, or otherwise to modify the visuals or behavior of the control skin, will be left without a functioning application in JDK 9. Of course, this is the fault of users who depended on non-public APIs, but we have long discussed making this API public so as to better enable third party modification of UI controls.

The intention is to move many JavaFX control skins into the appropriate public package, most probably There is no intent to also move the related behavior classes.

The vast bulk of this work is to review each existing skin class, ensuring the following:

This research is already quite far progressed in a separate sandbox repo, and whilst time-consuming, there are only a few classes of concern, such as utility classes, duplicated classes, and truly implementation-only classes, that need further analysis. On top of this, there is a handful of classes that may qualify for being brought into the javafx.scene.control package or, at the least, will need further consideration since they are not truly skins. These include FXVK (the virtual keyboard), ColorPalette, CustomColorDialog, DatePickerContent, and InputField. Finally, there are a few classes where, ideally, methods would be made private, except for the fact that other, implementation-only classes rely on this API. Solutions will be investigated for all of these issues, and no major concerns exist.

The intent of making the skins into public API in 9 is to ensure their continued availability. The API will be purposefully kept to the bare minimum and reduced as significantly as possible, with the intention to follow this up in subsequent releases with more useful APIs that developers request. As is well appreciated, APIs are (mostly) forever, so allowing for the public skin API to mature over a few update releases seems like the best course of action.

As of mid June, this project is at the point where almost all code is moved and cleaned up. The intention is to make this public in a JDK 9 build around mid-July to early August. The following is a list of all classes that have moved into as public API:

These classes, as of mid-June, are stripped of almost any API that is not inherited from SkinBase. Moving forward, the intention is to add back useful API as feedback is received based on early access builds. Some classes, such as the text input controls and virtualised controls, have additional API already to support their functionality.

Project Two: Review and make public relevant CSS APIs

As with Project One, this project relates to bringing out into the public APIs that currently reside in com.sun.* packages. Again, this will require code review to minimise the API, as well as additional unit tests and vastly more documentation.

The driver for this work will be to continue to allow for Scene Builder to compile in JDK 9, with the appropriate modifications.

As of mid June, this project is at the point where almost all code is moved and cleaned up. The intention is to make this public in a JDK 9 build around mid-July to early August. The following is a list of all classes that have moved into javafx.css as public API: class CascadingStyle implements Comparable<CascadingStyle> {    public Style getStyle() {    public CascadingStyle(final Style style, Set<PseudoClass> pseudoClasses,    public String getProperty() {    public Selector getSelector() {    public Rule getRule() {    public StyleOrigin getOrigin() {    public ParsedValueImpl getParsedValueImpl() { public class CompoundSelector extends Selector {    public List<SimpleSelector> getSelectors() {    public CompoundSelector(List<SimpleSelector> selectors, List<Combinator> relationships)    public Match createMatch() { class CssError {    public static void setCurrentScene(Scene scene) {    public final String getMessage() {    public CssError(String message) {    public final static class PropertySetError extends CssError {        public PropertySetError(CssMetaData styleableProperty, public class Declaration {    public ParsedValue getParsedValue() {    public String getProperty() {    public Rule getRule() { public class Rule {    public final ObservableList<Declaration> getDeclarations() {    public final ObservableList<Selector> getSelectors() {    public Stylesheet getStylesheet() {    public StyleOrigin getOrigin() { public class Selector {    public Rule getRule() {    public void setOrdinal(int ordinal) {    public int getOrdinal() {    public abstract Match createMatch();    public abstract boolean applies(Styleable styleable);    public abstract boolean applies(Styleable styleable, Set<PseudoClass>[] triggerStates, int bit);    public abstract boolean stateMatches(Styleable styleable, Set<PseudoClass> state);    public static Selector createSelector(final String cssSelector) {    protected void writeBinary(DataOutputStream os, StringStore stringStore) public class SimpleSelector extends Selector {    public String getName() {    public List<String> getStyleClasses() {    public Set<StyleClass> getStyleClassSet() {    public String getId() {    public NodeOrientation getNodeOrientation() { public class Size {    public Size(double value, SizeUnits units) {    public double getValue() {    public SizeUnits getUnits() {    public boolean isAbsolute() {    public double pixels(double multiplier, Font font) {    public double pixels(Font font) {    public double pixels() { public class Style {    public Selector getSelector() {    public Declaration getDeclaration() {    public Style(Selector selector, Declaration declaration) { class Stylesheet {    public String getUrl() {    public StyleOrigin getOrigin() {    public void setOrigin(StyleOrigin origin) {    public List<Rule> getRules() {    public List<FontFace> getFontFaces() {    public static Stylesheet loadBinary(URL url) throws IOException {    public static void convertToBinary(File source, File destination) throws IOException { public class CssParser {    public CssParser() {    public Stylesheet parse(final String stylesheetText) {    public Stylesheet parse(final URL url) throws IOException {    public Stylesheet parseInlineStyle(final Styleable node) {    public ParsedValueImpl parseExpr(String property, String expr) {    public static ObservableList<CssError> errorsProperty() {


The end result of these two projects is the creation of:


Testing will be limited to additional unit tests that have no special platform or hardware requirements.

Risks and Assumptions

The primary risk is that the scope of work exceeds what is anticipated. Some research has been done to better understand the requirements, but there is no denying that producing good APIs will require a decent investment of time.