groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Milles (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8168) When using Interface: BigDecimal cannot be cast to Double
Date Thu, 27 Apr 2017 20:45:04 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-8168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15987629#comment-15987629
] 

Eric Milles commented on GROOVY-8168:
-------------------------------------

Use "1.0d" and you should be fine.

> When using Interface: BigDecimal cannot be cast to Double
> ---------------------------------------------------------
>
>                 Key: GROOVY-8168
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8168
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.10
>            Reporter: Artem
>
> Execute the following code. 
> {code}
> interface SomeOperation {
>     double calculate(int i)
> }
> SomeOperation operation = { return 1.0 }
> operation.calculate(2)
> {code}
> Results in exception:
> {code}
>  java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Double
> 	at com.sun.proxy.$Proxy21.calculate(Unknown Source)
> 	at SomeOperation$calculate.call(Unknown Source)
> 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
> 	at ideaGroovyConsole.run(ideaGroovyConsole.groovy:5)
> 	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:518)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:497)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:483)
> 	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169)
> 	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
> 	at console.run(console.txt:25)
> 	at groovy.ui.GroovyMain.processReader(GroovyMain.java:632)
> 	at groovy.ui.GroovyMain.processFiles(GroovyMain.java:540)
> 	at groovy.ui.GroovyMain.run(GroovyMain.java:382)
> 	at groovy.ui.GroovyMain.process(GroovyMain.java:370)
> 	at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)
> 	at groovy.ui.GroovyMain.main(GroovyMain.java:109)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:483)
> 	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
> 	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:483)
> 	at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:65)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message