java.lang.ClassCastException: java.lang.String cannot be cast to cache.CodeTableValue

  1. 0

    Bug with JavaFX ComboBox?

    Stack Overflow | 5 months ago | purring pigeon
    java.lang.ClassCastException: java.lang.String cannot be cast to cache.CodeTableValue
  2. 0

    FULL PRODUCT VERSION : java version "1.8.0_66" Java(TM) SE Runtime Environment (build 1.8.0_66-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux pc682 3.13.0-68-generic #111-Ubuntu SMP Fri Nov 6 18:17:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux A DESCRIPTION OF THE PROBLEM : An JavaFX Spinner<Integer> throws a "java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer" exception under Linux whereas it perfectly works under Windows. The problem seems to be that the JVM uses the order of the constructors of Spinner to decide whether to instantiate a Spinner<Double> or Spinner<Integer> and this constructor order seems to be interpreted differently in the Windows JVM and the Linux JVM. That's why a Java program with a Spinner<Integer> that runs nicely under Windows throws an exception under Linux. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Use the example code from the description, start the application and change the spinner value. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The Spinner should not throw an exception. ACTUAL - The Spinner throws the following exception (under Linux): Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361) at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81) at javafx.beans.property.ReadOnlyObjectWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyObjectWrapper.java:176) at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:142) at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112) at javafx.beans.property.ObjectPropertyBase.access$000(ObjectPropertyBase.java:51) at javafx.beans.property.ObjectPropertyBase$Listener.invalidated(ObjectPropertyBase.java:233) at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:349) at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81) at javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:105) at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112) at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146) at javafx.scene.control.SpinnerValueFactory.setValue(SpinnerValueFactory.java:150) at javafx.scene.control.SpinnerValueFactory$DoubleSpinnerValueFactory.increment(SpinnerValueFactory.java:850) at javafx.scene.control.Spinner.increment(Spinner.java:394) at com.sun.javafx.scene.control.behavior.SpinnerBehavior.increment(SpinnerBehavior.java:132) at com.sun.javafx.scene.control.behavior.SpinnerBehavior.lambda$new$209(SpinnerBehavior.java:62) at com.sun.javafx.scene.control.behavior.SpinnerBehavior.startSpinning(SpinnerBehavior.java:151) at com.sun.javafx.scene.control.skin.SpinnerSkin.lambda$new$468(SpinnerSkin.java:99) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Scene$MouseHandler.process(Scene.java:3757) at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762) at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:352) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:388) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389) at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:387) at com.sun.glass.ui.View.handleMouseEvent(View.java:555) at com.sun.glass.ui.View.notifyMouse(View.java:937) at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139) at java.lang.Thread.run(Thread.java:745) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- Here is a minimal example that shows the bug when you change the Spinner value: TestApplication.java -------------------- import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; import java.net.URL; public class TestApplication extends Application { @Override public void start(Stage stage) throws Exception { URL resource = getClass().getResource("test.fxml"); FXMLLoader loader = new FXMLLoader(resource); Parent root = loader.load(); stage.setScene(new Scene(root)); stage.show(); } public static void main(String[] args) { launch(args); } } TestController.java ------------------- import javafx.fxml.Initializable; import javafx.scene.control.Spinner; import java.net.URL; import java.util.ResourceBundle; public class TestController implements Initializable { public Spinner<Integer> smoothingSpinner; @Override public void initialize(URL location, ResourceBundle resources) { smoothingSpinner.valueProperty().addListener((observable, oldValue, newValue) -> { System.out.println(newValue); }); } } test.fxml --------- <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.Spinner?> <?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.VBox?> <VBox prefHeight="200.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="TestController"> <Spinner fx:id="smoothingSpinner" editable="true" min="0" max="100" initialValue="3" /> </VBox> ---------- END SOURCE ----------

    JDK Bug System | 1 year ago | Webbug Group
    java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Bug ID: JDK-6499662 "java.lang.ClassCastException: cannot be cast to java.lang.String" happens from time to time

    sun.com | 4 months ago
    java.lang.ClassCastException: cannot be cast to java.lang.String
  5. 0

    Bug ID: JDK-6499662 "java.lang.ClassCastException: cannot be cast to java.lang.String" happens from time to time

    sun.com | 4 months ago
    java.lang.ClassCastException: cannot be cast to java.lang.String

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      java.lang.String cannot be cast to cache.CodeTableValue

      at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent()
    2. com.sun.javafx
      ExpressionHelper.fireValueChangedEvent
      1. com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361)
      2. com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
      2 frames
    3. javafx.beans.property
      ObjectPropertyBase.set
      1. javafx.beans.property.ReadOnlyObjectPropertyBase.fireValueChangedEvent(ReadOnlyObjectPropertyBase.java:74)
      2. javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:102)
      3. javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
      4. javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
      4 frames
    4. FXSampler
      ComboBox.lambda$new$152
      1. javafx.scene.control.SelectionModel.setSelectedItem(SelectionModel.java:102)
      2. javafx.scene.control.ComboBox.lambda$new$152(ComboBox.java:249)
      2 frames
    5. com.sun.javafx
      ExpressionHelper.fireValueChangedEvent
      1. com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361)
      2. com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
      2 frames
    6. javafx.beans.property
      ObjectPropertyBase.set
      1. javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:105)
      2. javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
      3. javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
      3 frames
    7. FXSampler
      ComboBoxPopupControl.lambda$new$291
      1. javafx.scene.control.ComboBoxBase.setValue(ComboBoxBase.java:150)
      2. com.sun.javafx.scene.control.skin.ComboBoxPopupControl.setTextFromTextFieldIntoComboBoxValue(ComboBoxPopupControl.java:405)
      3. com.sun.javafx.scene.control.skin.ComboBoxPopupControl.lambda$new$291(ComboBoxPopupControl.java:82)
      3 frames
    8. com.sun.javafx
      ExpressionHelper.fireValueChangedEvent
      1. com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361)
      2. com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
      2 frames
    9. javafx.beans.property
      ReadOnlyBooleanPropertyBase.fireValueChangedEvent
      1. javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
      1 frame
    10. javafx.scene
      Scene$KeyHandler.lambda$new$11
      1. javafx.scene.Node$FocusedProperty.notifyListeners(Node.java:7718)
      2. javafx.scene.Node.setFocused(Node.java:7771)
      3. javafx.scene.Scene$KeyHandler.setWindowFocused(Scene.java:3932)
      4. javafx.scene.Scene$KeyHandler.lambda$new$11(Scene.java:3954)
      4 frames
    11. com.sun.javafx
      ExpressionHelper.fireValueChangedEvent
      1. com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
      2. com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
      2 frames
    12. javafx.beans.property
      BooleanPropertyBase.set
      1. javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
      2. javafx.beans.property.ReadOnlyBooleanWrapper.fireValueChangedEvent(ReadOnlyBooleanWrapper.java:103)
      3. javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
      4. javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144)
      4 frames
    13. javafx.stage
      Window.setFocused
      1. javafx.stage.Window.setFocused(Window.java:439)
      1 frame
    14. com.sun.javafx
      GlassWindowEventHandler.run
      1. com.sun.javafx.stage.WindowPeerListener.changedFocused(WindowPeerListener.java:59)
      2. com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      3. com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:40)
      3 frames
    15. Java RT
      AccessController.doPrivileged
      1. java.security.AccessController.doPrivileged(Native Method)
      1 frame
    16. com.sun.javafx
      GlassWindowEventHandler.handleWindowEvent
      1. com.sun.javafx.tk.quantum.GlassWindowEventHandler.lambda$handleWindowEvent$423(GlassWindowEventHandler.java:150)
      2. com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
      3. com.sun.javafx.tk.quantum.GlassWindowEventHandler.handleWindowEvent(GlassWindowEventHandler.java:148)
      3 frames
    17. com.sun.glass
      WinApplication.lambda$null$148
      1. com.sun.glass.ui.Window.handleWindowEvent(Window.java:1266)
      2. com.sun.glass.ui.Window.notifyFocus(Window.java:1245)
      3. com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      4. com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
      4 frames
    18. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:745)
      1 frame