Description
This issue can be reproduce always by executing TableViewMouseInputTest using the following command:
```
/bin/sh gradlew -PSTUB_RUNTIME=../caches/modular-sdk -PFULL_TEST=true -PUSE_ROBOT=true --no-daemon --info --stacktrace cleanTest :controls:test --tests TableViewMouseInputTest -x :web:test --stacktrace 2>&1 | tee ~/`date +"test-%Y-%m%d-%H%M%S"`.log
```
output:
TableViewMouseInputTest > test_rt21444_down_row STANDARD_ERROR
Aug 02, 2022 11:06:00 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Caught 'java.lang.ClassCastException: class java.lang.String cannot be cast to class javafx.scene.paint.Paint (java.lang.String is in module java.base of loader 'bootstrap'; javafx.scene.paint.Paint is in module javafx.graphics@20-internal of loader 'app')' while converting value for '-fx-background-color' from rule '*.table-row-cell' in stylesheet file:/Users/angorya/Projects/jfx/build/shims/javafx.controls/com/sun/javafx/scene/control/skin/modena/modena.bss
Aug 02, 2022 11:06:00 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Caught 'java.lang.ClassCastException: class java.lang.String cannot be cast to class javafx.scene.paint.Paint (java.lang.String is in module java.base of loader 'bootstrap'; javafx.scene.paint.Paint is in module javafx.graphics@20-internal of loader 'app')' while converting value for '-fx-border-color' from rule '*.table-cell' in stylesheet file:/Users/angorya/Projects/jfx/build/shims/javafx.controls/com/sun/javafx/scene/control/skin/modena/modena.bss
I have seen similar messages when running a javafx application in the field. Also, similar issue was reported in stackoverflow:
https://stackoverflow.com/questions/27311222/javafx-getting-class-cast-exception-in-css-for-blend-mode
Also, see JDK-8088468
----------------------------------------------------
Minimal reproducable example:
### START ###
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class CssWarningBug extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Scene scene = new Scene(new StackPane(buildTableView()));
stage.setScene(scene);
stage.show();
}
private TableView<String> buildTableView() {
TableView<String> tableView = new TableView<>();
TableColumn<String, String> column = new TableColumn<>("column");
column.setCellValueFactory(param -> new SimpleStringProperty(param.getValue()));
column.setCellFactory(param -> new ScenePropertyTableCell<>());
tableView.getColumns().add(column);
tableView.getItems().addAll("item1", "item2", "item3");
return tableView;
}
private static class ScenePropertyTableCell<S> extends TableCell<S, String> {
public ScenePropertyTableCell() {
sceneProperty().addListener((obs, oldScene, newScene) -> {
if (newScene == null || newScene.getRoot().getProperties().containsKey("new.root")) {
return;
}
StackPane newRoot = new StackPane();
newRoot.getProperties().put("new.root", true);
Parent oldRoot = newScene.getRoot();
newScene.setRoot(newRoot);
// CLASS CAST EXCEPTION
// If this call is before newScene.setRoot(newRoot);, nothing will happen.
// Maybe because -fx-table-cell-border-color is not yet parsed because we changed the root?
newRoot.getChildren().setAll(oldRoot);
});
}
}
}
### END ###
```
/bin/sh gradlew -PSTUB_RUNTIME=../caches/modular-sdk -PFULL_TEST=true -PUSE_ROBOT=true --no-daemon --info --stacktrace cleanTest :controls:test --tests TableViewMouseInputTest -x :web:test --stacktrace 2>&1 | tee ~/`date +"test-%Y-%m%d-%H%M%S"`.log
```
output:
TableViewMouseInputTest > test_rt21444_down_row STANDARD_ERROR
Aug 02, 2022 11:06:00 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Caught 'java.lang.ClassCastException: class java.lang.String cannot be cast to class javafx.scene.paint.Paint (java.lang.String is in module java.base of loader 'bootstrap'; javafx.scene.paint.Paint is in module javafx.graphics@20-internal of loader 'app')' while converting value for '-fx-background-color' from rule '*.table-row-cell' in stylesheet file:/Users/angorya/Projects/jfx/build/shims/javafx.controls/com/sun/javafx/scene/control/skin/modena/modena.bss
Aug 02, 2022 11:06:00 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Caught 'java.lang.ClassCastException: class java.lang.String cannot be cast to class javafx.scene.paint.Paint (java.lang.String is in module java.base of loader 'bootstrap'; javafx.scene.paint.Paint is in module javafx.graphics@20-internal of loader 'app')' while converting value for '-fx-border-color' from rule '*.table-cell' in stylesheet file:/Users/angorya/Projects/jfx/build/shims/javafx.controls/com/sun/javafx/scene/control/skin/modena/modena.bss
I have seen similar messages when running a javafx application in the field. Also, similar issue was reported in stackoverflow:
https://stackoverflow.com/questions/27311222/javafx-getting-class-cast-exception-in-css-for-blend-mode
Also, see JDK-8088468
----------------------------------------------------
Minimal reproducable example:
### START ###
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class CssWarningBug extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Scene scene = new Scene(new StackPane(buildTableView()));
stage.setScene(scene);
stage.show();
}
private TableView<String> buildTableView() {
TableView<String> tableView = new TableView<>();
TableColumn<String, String> column = new TableColumn<>("column");
column.setCellValueFactory(param -> new SimpleStringProperty(param.getValue()));
column.setCellFactory(param -> new ScenePropertyTableCell<>());
tableView.getColumns().add(column);
tableView.getItems().addAll("item1", "item2", "item3");
return tableView;
}
private static class ScenePropertyTableCell<S> extends TableCell<S, String> {
public ScenePropertyTableCell() {
sceneProperty().addListener((obs, oldScene, newScene) -> {
if (newScene == null || newScene.getRoot().getProperties().containsKey("new.root")) {
return;
}
StackPane newRoot = new StackPane();
newRoot.getProperties().put("new.root", true);
Parent oldRoot = newScene.getRoot();
newScene.setRoot(newRoot);
// CLASS CAST EXCEPTION
// If this call is before newScene.setRoot(newRoot);, nothing will happen.
// Maybe because -fx-table-cell-border-color is not yet parsed because we changed the root?
newRoot.getChildren().setAll(oldRoot);
});
}
}
}
### END ###
Attachments
Issue Links
- duplicates
-
JDK-8198604 [CSS] Some of the javafx control unit tests log ClassCastException
- Resolved
- relates to
-
JDK-8088468 [CSS] WARNING: Caught 'java.lang.ClassCastException: javafx.scene.paint.LinearGradient cannot be cast to javafx.scene.paint.Color'
- Open
-
JDK-8097038 [CSS] -fx-selection-bar style causes Warning: Could not resolve 'a lookup value'
- Resolved
-
JDK-8268657 Looked-up color fails for -fx-background-color in JavaFX CSS file
- Open
-
JDK-8296825 [TestBug] Add a unit test for CSS style initialization
- Resolved
(2 links to)