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

CSS PaintType converter causes ClassCastException

XMLWordPrintable

      Run the following test program. It will crash with a ClassCastException. Exception
      trace appended below.

      Jasper says this is a bug in the PaintType converter.

      import javafx.scene.*;
      import javafx.scene.control.*;
      import javafx.stage.Stage;

      Stage {
          title: "Transparent Border"
          width: 600
          height: 600
          scene: Scene {
              stylesheets: [ "{__DIR__}transparent.css" ]
              content: [
                  Separator {
                      styleClass: "myseparator"
                      layoutX: 50
                      layoutY: 50
                  }
                  Separator {
                      styleClass: "myseparator"
                      layoutX: 50
                      layoutY: 100
                      vertical: true
                  }
              ]
          }
      }

      ===== transparent.css =====

      /* this causes ClassCastException at runtime */
      .myseparator *.line {
          -fx-border-style: dotted;
          -fx-border-color: derive(-fx-background,-20%) transparent transparent transparent;
          -fx-border-width: 1px;
          -fx-padding: 3;
          -fx-background-color: null;
      }

      ===== exception trace =====

      java.lang.ClassCastException: java.lang.Float
              at com.sun.stylesheet.css.Type$PaintType.getParsedValue(Type.fx:633)
              at com.sun.stylesheet.css.Type$PaintType.getParsedValue(Type.fx:633)
              at com.sun.stylesheet.css.Type$PaintType.convert(Type.fx:620)
              at com.sun.stylesheet.css.Type$PaintType.convert(Type.fx:620)
              at com.sun.javafx.scene.layout.region.StrokeBorder$BorderPaintType.convert(StrokeBorder.fx:215)
              at com.sun.javafx.scene.layout.region.StrokeBorder$BorderPaintType.convert(StrokeBorder.fx:215)
              at com.sun.stylesheet.StyleHelper.lookup(StyleHelper.fx:297)
              at com.sun.stylesheet.StyleHelper.lookup(StyleHelper.fx:297)
              at com.sun.stylesheet.StyleHelper.lookup(StyleHelper.fx:250)
              at com.sun.stylesheet.StyleHelper.lookup(StyleHelper.fx:250)
              at com.sun.stylesheet.StyleHelper.transitionToState(StyleHelper.fx:153)
              at com.sun.stylesheet.StyleHelper.transitionToState(StyleHelper.fx:153)
              at javafx.scene.Node.impl_processCSS(Node.fx:3071)
              at javafx.scene.Node.impl_processCSS(Node.fx:3071)
              at javafx.scene.Parent.impl_processCSS(Parent.fx:856)
              at javafx.scene.Parent.impl_processCSS(Parent.fx:856)
              at javafx.scene.Parent.impl_processCSS(Parent.fx:859)
              at javafx.scene.Parent.impl_processCSS(Parent.fx:859)
              at javafx.scene.Parent.impl_processCSS(Parent.fx:859)
              at javafx.scene.Parent.impl_processCSS(Parent.fx:859)
              at javafx.scene.Parent.impl_processCSS(Parent.fx:859)
              at javafx.scene.Parent.impl_processCSS(Parent.fx:859)
              at javafx.scene.Scene.doCSSPass(Scene.fx:285)
              at javafx.scene.Scene.doCSSPass(Scene.fx:285)
              at javafx.scene.Scene.userInit$(Scene.fx:598)
              at javafx.scene.Scene.userInit$(Scene.fx:598)
              at com.sun.javafx.runtime.FXBase.complete$(FXBase.java:288)
              at TransparentBorder.javafx$run$(TransparentBorder.fx:16)
              at TransparentBorder.javafx$run$(TransparentBorder.fx:16)

            dgrieve David Grieve
            smarks Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: