We noticed that if one uses static setters in FXML, e.g. AnchorPane.bottomAnchor="0.0", there is a substantial performance impact on FXML parsing.
More than 90% of the execution time is spent in these two methods:
com.sun.javafx.fxml.BeanAdapter.getStaticSetterMethod(Class, String, Class, Class)
com.sun.javafx.fxml.BeanAdapter.getStaticGetterMethod(Class, String, Class)
a) Parsing an FXML with 100 stack panes in an AnchorPane with static setters takes ~100ms on average on my machine
b) Parsing an FXML with 100 stack panes in an AnchorPane without static setters takes ~8ms on average on my machine
c) Creating the same scene tree as in a) programmatically takes ~2ms on average on my machine
This is the FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.*?>
<AnchorPane>
<children>
<StackPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
<StackPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
...
<StackPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
Is that a bug or is it expected behaviour?