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] [Updated] (GROOVY-8560) Spread operator type conversion error
Date Wed, 25 Apr 2018 12:32:00 GMT

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

Petteri Johansson updated GROOVY-8560:
--------------------------------------
    Description: 
Line 6 with spread operator throws runtime typecast exception:

{{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()}}

 

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)

  was:
Line 7 with spread operator throws runtime typecast exception:

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()

 

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)


> 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:
> {{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()}}
>  
> 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