java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

JDK Bug System | Webbug Group | 1 year ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 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
  2. 0

    Bug with JavaFX ComboBox?

    Stack Overflow | 10 months ago | purring pigeon
    java.lang.ClassCastException: java.lang.String cannot be cast to cache.CodeTableValue
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Help:basic RMI question

    Google Groups | 2 decades ago | Paolo De Lutiis
    java.lang.ClassCastException: serverPackage.ServerClass_Stub at clientPackage.myApplet.init(myApplet.java:line#) at sun.applet.AppletPanel.run(AppletPanel.java:273) at java.lang.Thread.
  5. 0

    Shared hosting Bungeecord problems.

    GitHub | 3 years ago | Arksenu
    java.lang.ClassCastException: bka cannot be cast to fs All my servers are set to onlinemode: false Here is my config.yml groups: arksenu: - admin disabled_commands: - find player_limit: -1 stats: 347d1d62-6fb6-4869-bd43-7d0745de8e3c permissions: default: - bungeecord.command.server - bungeecord.command.list admin: - bungeecord.command.ip - bungeecord.command.alert - bungeecord.command.end - bungeecord.command.reload listeners: - max_players: 18 fallback_server: hub host: 0.0.0.0:35289 bind_local_address: true ping_passthrough: false tab_list: GLOBAL_PING default_server: hub forced_hosts: pvp.md-5.net: hub tab_size: 60 force_default_server: true motd: ’Network’ query_enabled: false query_port: 25565 timeout: 30000 connection_throttle: 4000 servers: hub: address: 108.170.8.146:35289 restricted: false motd: test UvGames: address: 66.85.165.170:26200 restricted: false motd: test UvPrison: address: 66.85.128.90:25928 restricted: false motd: test ip_forward: false online_mode: true And here is my console message -> UpstreamBridge has disconnected disconnected with: Exception Connecting:RuntimeException : Server is online mode! @ net.md_5.bungee.ServerConnector:188

    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.Double cannot be cast to java.lang.Integer

      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$Listener.invalidated
      1. javafx.beans.property.ReadOnlyObjectWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyObjectWrapper.java:176)
      2. javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:142)
      3. javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
      4. javafx.beans.property.ObjectPropertyBase.access$000(ObjectPropertyBase.java:51)
      5. javafx.beans.property.ObjectPropertyBase$Listener.invalidated(ObjectPropertyBase.java:233)
      5 frames
    4. com.sun.javafx
      ExpressionHelper.fireValueChangedEvent
      1. com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:349)
      2. com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
      2 frames
    5. 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
    6. FXSampler
      Spinner.increment
      1. javafx.scene.control.SpinnerValueFactory.setValue(SpinnerValueFactory.java:150)
      2. javafx.scene.control.SpinnerValueFactory$DoubleSpinnerValueFactory.increment(SpinnerValueFactory.java:850)
      3. javafx.scene.control.Spinner.increment(Spinner.java:394)
      3 frames
    7. com.sun.javafx
      SpinnerBehavior.startSpinning
      1. com.sun.javafx.scene.control.behavior.SpinnerBehavior.increment(SpinnerBehavior.java:132)
      2. com.sun.javafx.scene.control.behavior.SpinnerBehavior.lambda$new$209(SpinnerBehavior.java:62)
      3. com.sun.javafx.scene.control.behavior.SpinnerBehavior.startSpinning(SpinnerBehavior.java:151)
      3 frames
    8. FXSampler
      SpinnerSkin.lambda$new$468
      1. com.sun.javafx.scene.control.skin.SpinnerSkin.lambda$new$468(SpinnerSkin.java:99)
      1 frame
    9. com.sun.javafx
      EventUtil.fireEvent
      1. com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
      2. com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
      3. com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
      4. com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
      5. com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      6. com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      7. com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      8. com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      9. com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      10. com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      11. com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      12. com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      13. com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
      14. com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
      14 frames
    10. javafx.event
      Event.fireEvent
      1. javafx.event.Event.fireEvent(Event.java:198)
      1 frame
    11. javafx.scene
      Scene$ScenePeerListener.mouseEvent
      1. javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
      2. javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
      3. javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
      4. javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
      4 frames
    12. com.sun.javafx
      GlassViewEventHandler$MouseEventNotification.run
      1. com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:352)
      2. com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275)
      2 frames
    13. Java RT
      AccessController.doPrivileged
      1. java.security.AccessController.doPrivileged(Native Method)
      1 frame
    14. com.sun.javafx
      GlassViewEventHandler.handleMouseEvent
      1. com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:388)
      2. com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
      3. com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:387)
      3 frames
    15. com.sun.glass
      GtkApplication.lambda$null$49
      1. com.sun.glass.ui.View.handleMouseEvent(View.java:555)
      2. com.sun.glass.ui.View.notifyMouse(View.java:937)
      3. com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
      4. com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
      4 frames
    16. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:745)
      1 frame