java.lang.ClassCastException: Cannot cast java.math.BigDecimal to java.lang.Double

Apache's JIRA Issue Tracker | Jim Clarke | 5 years 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

    [GROOVY-5562] GroovyFX - Class Cast Exception on BigDecimal to double when using Groovy 2.0 Indy="true" - ASF JIRA

    apache.org | 1 year ago
    java.lang.ClassCastException: Cannot cast java.math.BigDecimal to java.lang.Double
  2. 0

    Setting indy="true" causes JavaFX binds to fail on failure to convert BigDecimal to double. This works ok when indy="false" ===== "hourAngleProperty.bind((hours() * 30.0) + (minutes() * 0.5))" this actually translates to this: hourAngleProperty.bind(hours().multiply(30.0).add(minutes().multiply(0.5))); where hourAngleProperty, hours() and minutes() are type javafx.beans.property.DoubleProperty. The problem is the 30.0 and 0.5 are treated as BigDecimal and with Indy, there seems to be no unboxing of BigDecimal to "double". If i do this: hourAngleProperty.bind((hours() * (double)30.0) + (minutes() * (double)0.5)) it works. But this error is all over the GroovyFX code base. ====== java.lang.ClassCastException: Cannot cast java.math.BigDecimal to java.lang.Double at java.lang.Class.cast(Class.java:3005) at sun.invoke.util.ValueConversions.primitiveConversion(ValueConversions.java:236) at sun.invoke.util.ValueConversions.unboxDouble(ValueConversions.java:118) at java.lang.invoke.MethodHandleImpl$GuardWithCatch.invoke_L2(MethodHandleImpl.java:1130) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:684) at Time.<init>(AnalogClockDemo.groovy:38) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186) at AnalogClockDemo$_run_closure1.doCall(AnalogClockDemo.groovy:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:904) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:809) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:792) at org.codehaus.groovy.runtime.InvokerHelper.invokeClosure(InvokerHelper.java:95) at groovyx.javafx.GroovyFX.start(GroovyFX.java:35) at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319) at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206) at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76) Exception in Application start method Exception in thread "main" java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403) at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47) at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.ClassCastException: Cannot cast java.math.BigDecimal to java.lang.Double at java.lang.Class.cast(Class.java:3005) at sun.invoke.util.ValueConversions.primitiveConversion(ValueConversions.java:236) at sun.invoke.util.ValueConversions.unboxDouble(ValueConversions.java:118) at java.lang.invoke.MethodHandleImpl$GuardWithCatch.invoke_L2(MethodHandleImpl.java:1130) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:684) at Time.<init>(AnalogClockDemo.groovy:38) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186) at AnalogClockDemo$_run_closure1.doCall(AnalogClockDemo.groovy:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:904) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:809) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:792) at org.codehaus.groovy.runtime.InvokerHelper.invokeClosure(InvokerHelper.java:95) at groovyx.javafx.GroovyFX.start(GroovyFX.java:35) at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319) at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206) at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76) Java Result: 1

    Apache's JIRA Issue Tracker | 5 years ago | Jim Clarke
    java.lang.ClassCastException: Cannot cast java.math.BigDecimal to java.lang.Double

    Root Cause Analysis

    1. java.lang.ClassCastException

      Cannot cast java.math.BigDecimal to java.lang.Double

      at java.lang.Class.cast()
    2. Java RT
      MethodHandleImpl$GuardWithCatch.invoke_L2
      1. java.lang.Class.cast(Class.java:3005)
      2. sun.invoke.util.ValueConversions.primitiveConversion(ValueConversions.java:236)
      3. sun.invoke.util.ValueConversions.unboxDouble(ValueConversions.java:118)
      4. java.lang.invoke.MethodHandleImpl$GuardWithCatch.invoke_L2(MethodHandleImpl.java:1130)
      4 frames
    3. Groovy
      IndyInterface.selectMethod
      1. org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:684)
      1 frame
    4. Unknown
      Time.<init>
      1. Time.<init>(AnalogClockDemo.groovy:38)
      1 frame
    5. Java RT
      Constructor.newInstance
      1. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      2. sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      3. sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      4. java.lang.reflect.Constructor.newInstance(Constructor.java:525)
      4 frames
    6. Groovy
      AbstractCallSite.callConstructor
      1. org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
      2. org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
      3. org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
      4. org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
      5. org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186)
      5 frames
    7. Unknown
      AnalogClockDemo$_run_closure1.doCall
      1. AnalogClockDemo$_run_closure1.doCall(AnalogClockDemo.groovy:64)
      1 frame
    8. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:601)
      4 frames
    9. Groovy
      InvokerHelper.invokeClosure
      1. org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      2. groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      3. org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
      4. groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:904)
      5. org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:809)
      6. org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:792)
      7. org.codehaus.groovy.runtime.InvokerHelper.invokeClosure(InvokerHelper.java:95)
      7 frames
    10. groovyx.javafx
      GroovyFX.start
      1. groovyx.javafx.GroovyFX.start(GroovyFX.java:35)
      1 frame
    11. com.sun.javafx
      PlatformImpl$4.run
      1. com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
      2. com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
      3. com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
      3 frames
    12. com.sun.glass
      InvokeLaterDispatcher$Future.run
      1. com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
      1 frame