groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Petteri Johansson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8560) Spread operator type conversion error
Date Thu, 26 Apr 2018 07:55:00 GMT

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

Petteri Johansson commented on GROOVY-8560:
-------------------------------------------

Ok got it :) and thanks for the superb help!

> Spread operator type conversion error
> -------------------------------------
>
>                 Key: GROOVY-8560
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8560
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.15
>            Reporter: Petteri Johansson
>            Priority: Minor
>
> Line 6 with spread operator throws runtime typecast exception:
> {code:java}
> class Test {
>     def test() {
>         byte [] b = [0, 0] as byte[]
>         Object [] oa = [b] as Object []
>         method( oa[0] )
>         method( *oa ) //Does not work
>     }
>     def method(byte[] bytes) {}
> }
> new Test().test()
> {code}
>  
> Result:
> Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object
'[0, 0]' with class 'java.util.ArrayList' to class 'java.lang.Byte'
>  org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[0,
0]' with class 'java.util.ArrayList' to class 'java.lang.Byte'
>  at Test.test(test.groovy:7)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message