You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2025/03/15 17:59:00 UTC

[jira] [Assigned] (GROOVY-8560) Spread operator type conversion error

     [ https://issues.apache.org/jira/browse/GROOVY-8560?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles reassigned GROOVY-8560:
-----------------------------------

    Assignee: Eric Milles

> 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
>            Assignee: Eric Milles
>            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
(v8.20.10#820010)